Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	grails-app/services/au/org/ala/bie/SearchService.groovy
  • Loading branch information
djtfmartin committed Aug 2, 2017
2 parents 612242e + 7d1d974 commit cd9d0c7
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 79 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sudo: false
branches:
only:
- master
- hotfix
before_install:
- wget -q https://raw.githubusercontent.com/AtlasOfLivingAustralia/travis-build-configuration/master/ala_common.sh
- chmod +x ala_common.sh
Expand Down
2 changes: 1 addition & 1 deletion application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Grails Metadata file
#Mon Sep 23 16:23:09 BST 2015
app.grails.version=2.5.1
app.grails.version=2.5.5
app.name=bie-index
app.version=1.3.0-SNAPSHOT
5 changes: 4 additions & 1 deletion grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ wordPress {
}
speciesList.url = "http://lists.ala.org.au/ws/speciesListItems/"
speciesList.params = "?includeKVP=true"
// Acceptable vernacular names to appear in autocomplete
//autoComplete.languages = 'en,en-AU,en-CA,en-GB,en-US'
autoComplete.languages = ''
// Location of conservation lists
conservationListsUrl = this.class.getResource("/default-conservation-lists.json").toString()
// Location of vernacular name lists (null for default)
Expand Down Expand Up @@ -198,6 +201,6 @@ log4j = {
'grails.app.taglib.org.grails.plugin.resource',
'grails.app.resourceMappers.org.grails.plugin.resource'

debug "grails.app",
info "grails.app",
"au.org.ala"
}
4 changes: 1 addition & 3 deletions grails-app/conf/UrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class UrlMappings {
"/ws/subgroups(.json)?"(controller: 'misc', action: 'speciesGroups')
"/subgroups.json"(controller: 'misc', action: 'speciesGroups')
"/subgroups"(controller: 'misc', action: 'speciesGroups')
"/updateImages" (controller: 'import'){ ///${updateImages}?
action = [POST:'updateImages']
}
"/updateImages" (controller: 'misc', action: 'updateImages')

"/"(view: "/index")
"500"(view: '/error')
Expand Down
24 changes: 13 additions & 11 deletions grails-app/controllers/au/org/ala/bie/ImportController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,20 @@ class ImportController {

}

def updateImages() {

def checkRequest = bieAuthService.checkApiKey(request.getHeader("Authorization"))

if (checkRequest.valid) {
// contain list of guids and images
List<Map> preferredImagesList = request.getJSON() //params.guidImageList
def updatedTaxa = importService.updateDocsWithPreferredImage(preferredImagesList)
asJson([success: true, updatedTaxa: updatedTaxa])
} else {
asJson([success: false, message: "Unauthorised access. Failed to updated Image in Bie" ])
/**
* Reads preferred images list in list tool and updates imageId if values have changed
* list DR is defined by config var ${imagesListsUrl} - property {lists}
*
* @return
*/
def loadPreferredImages() {
def online = BooleanUtils.toBooleanObject(params.online ?: "false")
Thread.start {
log.info("Starting loading preferred images...")
importService.loadPreferredImages(online)
log.info("Finished loading preferred images.")
}
asJson ([success:true] )
}

def loadImages() {
Expand Down
27 changes: 26 additions & 1 deletion grails-app/controllers/au/org/ala/bie/MiscController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import static org.codehaus.groovy.grails.web.servlet.HttpHeaders.LAST_MODIFIED

class MiscController {

def speciesGroupService, indexService
def speciesGroupService, indexService, bieAuthService, importService

def speciesGroups() {
try {
Expand Down Expand Up @@ -38,4 +38,29 @@ class MiscController {
}

}

def updateImages() {

def checkRequest = bieAuthService.checkApiKey(request.getHeader("Authorization"))

if (checkRequest.valid) {
try {
// contain list of guids and images
List<Map> preferredImagesList = request.getJSON()
def updatedTaxa = importService.updateDocsWithPreferredImage(preferredImagesList)
asJson([success: true, updatedTaxa: updatedTaxa])
} catch (Exception e) {
asJson([success: false, message: "Internal error occurred: " + e.getMessage() ])
}
} else {
asJson([success: false, message: "Unauthorised access. Failed to update Image in Bie" ])
}
}

private def asJson = { model ->
response.setContentType("application/json;charset=UTF-8")
model
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ class SearchController {
return null
}
def classification = searchService.getClassification(params.id)
render (classification as JSON)

if (!classification) {
response.sendError(404, "GUID ${params.id} not found")
} else {
render (classification as JSON)
}
}

/**
Expand Down
Loading

0 comments on commit cd9d0c7

Please sign in to comment.