Skip to content

Commit

Permalink
add refresh SoftwareUserRepository feature
Browse files Browse the repository at this point in the history
  • Loading branch information
geektortoise committed Apr 29, 2020
1 parent 7af22b2 commit 751f829
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions grails-app/conf/SoftwareUserRepositoryUrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class SoftwareUserRepositoryUrlMappings {
"/api/software_user_repository/$id.$format"(controller: "restSoftwareUserRepository") {
action = [GET: "show", PUT: "update", DELETE: "delete"]
}
"/api/software_user_repository/$id/refresh.$format"(controller: "restSoftwareUserRepository") {
action = [GET: "refresh"]
}
"/api/software_user_repository/refresh_user_repositories.$format"(controller: "restSoftwareUserRepository") {
action = [GET: "refreshUserRepositories"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ class RestSoftwareUserRepositoryController extends RestController {
delete(softwareUserRepositoryService, JSON.parse("{id : $params.id}"), null)
}

@RestApiMethod(description = "Refresh the given software user repository")
@RestApiParams(params = [
@RestApiParam(name = "id", type = "long", paramType = RestApiParamType.PATH, description = "The software user repository id")
])
def refresh() {
def repo = softwareUserRepositoryService.read(params.long('id'))
if (repo) {
softwareUserRepositoryService.refresh(repo)
responseSuccess(["message": "Software repositories refreshing has been asked!"])
}
else {
responseNotFound("SoftwareUserRepository", params.id)
}
}

@RestApiMethod(description = "Refresh the software user repositories loaded by the software-router")
def refreshUserRepositories() {
responseSuccess(softwareUserRepositoryService.refreshRepositories())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ class SoftwareUserRepositoryService extends ModelService {
amqpQueueService.publishMessage(AmqpQueue.findByName("queueCommunication"), jsonBuilder.toString())
}

def refresh(def repo) {
def message = [requestType: "refreshRepository",
id: repo.id,
username: repo.username]

JsonBuilder jsonBuilder = new JsonBuilder()
jsonBuilder(message)

amqpQueueService.publishMessage(AmqpQueue.findByName("queueCommunication"), jsonBuilder.toString())
}

def refreshRepositories() {
def message = [requestType: "refreshRepositories"]

Expand Down

0 comments on commit 751f829

Please sign in to comment.