Skip to content

Commit

Permalink
update dot navigation of grails configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
brucehyslop committed Mar 3, 2023
1 parent ac99a86 commit e623802
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AssertionsController {
def assertions(String id) {
JSONArray userAssertions = webServicesService.getUserAssertions(id)
JSONArray qualityAssertions = webServicesService.getQueryAssertions(id)
Boolean hasClubView = request.isUserInRole("${grailsApplication.config.clubRoleForHub}")
Boolean hasClubView = request.isUserInRole("${grailsApplication.config.getProperty('clubRoleForHub')}")
String userAssertionStatus = webServicesService.getRecord(id, hasClubView)?.raw.userAssertionStatus
Map combined = [userAssertions: userAssertions ?: [], assertionQueries: qualityAssertions ?: [], userAssertionStatus: userAssertionStatus ?: ""]
render combined as JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class OccurrenceController {
filteredFacets = postProcessingService.getFilteredFacets(defaultFacets)
}

final facetsDefaultSelectedConfig = grailsApplication.config.facets.defaultSelected
final facetsDefaultSelectedConfig = grailsApplication.config.getProperty('facets.defaultSelected')
if (!userFacets && facetsDefaultSelectedConfig) {
userFacets = facetsDefaultSelectedConfig.trim().split(",")
log.debug "facetsDefaultSelectedConfig = ${facetsDefaultSelectedConfig}"
Expand All @@ -105,7 +105,7 @@ class OccurrenceController {

String[] requestedFacets = userFacets ?: filteredFacets

if (grailsApplication.config.facets.includeDynamicFacets?.toString()?.toBoolean()) {
if (grailsApplication.config.getProperty('facets.includeDynamicFacets', Boolean, false)) {
// Sandbox only...
time("sandbox only facets") {
dynamicFacets = webServicesService.getDynamicFacets(requestParams.q)
Expand Down Expand Up @@ -161,7 +161,7 @@ class OccurrenceController {
}

def hasImages = postProcessingService.resultsHaveImages(searchResults)
if (grailsApplication.config.alwaysshow.imagetab?.toString()?.toBoolean()) {
if (grailsApplication.config.getProperty('alwaysshow.imagetab', Boolean, false)) {
hasImages = true
}

Expand Down Expand Up @@ -261,11 +261,11 @@ class OccurrenceController {


List taxaQueries = (ArrayList<String>) params.list("taxa") // will be list for even one instance
log.debug "skin.useAlaBie = ${grailsApplication.config.skin.useAlaBie}"
log.debug "skin.useAlaBie = ${grailsApplication.config.getProperty('skin.useAlaBie')}"
log.debug "taxaQueries = ${taxaQueries} || q = ${requestParams.q}"

if (grailsApplication.config.skin.useAlaBie?.toString()?.toBoolean() &&
grailsApplication.config.bieService.baseUrl && taxaQueries && taxaQueries[0]) {
if (grailsApplication.config.getProperty('skin.useAlaBie', Boolean, false) &&
grailsApplication.config.getProperty('bieService.baseUrl') && taxaQueries && taxaQueries[0]) {
// check for list with empty string
// taxa query - attempt GUID lookup
List guidsForTaxa = webServicesService.getGuidsForTaxa(taxaQueries)
Expand Down Expand Up @@ -364,9 +364,9 @@ class OccurrenceController {

try {
String userId = authService?.getUserId()
Boolean hasClubView = request.isUserInRole("${grailsApplication.config.clubRoleForHub}")
Boolean hasClubView = request.isUserInRole("${grailsApplication.config.getProperty('clubRoleForHub')}")
JSONObject record = webServicesService.getRecord(id, hasClubView)
log.debug "hasClubView = ${hasClubView} || ${grailsApplication.config.clubRoleForHub}"
log.debug "hasClubView = ${hasClubView} || ${grailsApplication.config.getProperty('clubRoleForHub')}"

// if backend can't find the record, a JSON error with a field 'message' will be returned
// TODO: backend can refine the response to put like errorType into returned JSON
Expand Down Expand Up @@ -465,7 +465,7 @@ class OccurrenceController {
metadataForOutlierLayers: postProcessingService.getMetadataForOutlierLayers(record, layersMetaData),
environmentalSampleInfo : postProcessingService.getLayerSampleInfo(ENVIRO_LAYER, record, layersMetaData),
contextualSampleInfo : postProcessingService.getLayerSampleInfo(CONTEXT_LAYER, record, layersMetaData),
skin : grailsApplication.config.skin.layout
skin : grailsApplication.config.getProperty('skin.layout')
])
} else {
if (record?.message == 'Unrecognised UID') {
Expand All @@ -492,7 +492,7 @@ class OccurrenceController {
String[] parts = soundUrl.split("imageId=")
if (parts.length >= 2) {
log.debug("image id = " + parts[1])
mediaDTO.alternativeFormats.'detailLink' = "${grailsApplication.config.images.baseUrl}/image/${parts[1].encodeAsURL()}"
mediaDTO.alternativeFormats.'detailLink' = "${grailsApplication.config.getProperty('images.baseUrl')}/image/${parts[1].encodeAsURL()}"
mediaDTO.metadata = webServicesService.getImageMetadata(parts[1])
}
}
Expand Down Expand Up @@ -592,7 +592,7 @@ class OccurrenceController {
*/
def exploreYourArea() {
def radius = params.radius?:5
Map radiusToZoomLevelMap = grailsApplication.config.exploreYourArea.zoomLevels // zoom levels for the various radius sizes
Map radiusToZoomLevelMap = grailsApplication.config.getProperty('exploreYourArea.zoomLevels', Map) // zoom levels for the various radius sizes

def lat = params.latitude
def lng = params.longitude
Expand All @@ -606,8 +606,8 @@ class OccurrenceController {
lat = location.latitude
lng = location.longitude
} else {
lat = grailsApplication.config.exploreYourArea.lat
lng = grailsApplication.config.exploreYourArea.lng
lat = grailsApplication.config.getProperty('exploreYourArea.lat')
lng = grailsApplication.config.getProperty('exploreYourArea.lng')
}
}

Expand All @@ -616,8 +616,8 @@ class OccurrenceController {
longitude : lng,
radius : radius,
zoom : radiusToZoomLevelMap.get(radius?.toString()),
location : grailsApplication.config.exploreYourArea.location,
speciesPageUrl: grailsApplication.config.bie.baseUrl + "/species/"
location : grailsApplication.config.getProperty('exploreYourArea.location'),
speciesPageUrl: grailsApplication.config.getProperty('bie.baseUrl') + "/species/"
]
}

Expand Down Expand Up @@ -658,17 +658,17 @@ class OccurrenceController {
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMMM yyyy")
//set the properties of the query
fg.title = "This document was generated on " + sdf.format(new Date())
String serverName = grailsApplication.config.serverName ?: grailsApplication.config.security.cas.appServerName
String serverName = grailsApplication.config.getProperty('serverName') ?: grailsApplication.config.getProperty('security.cas.appServerName')
String contextPath = request.contextPath
fg.link = serverName + contextPath + "/occurrences/search?" + request.getQueryString()
//log.info "FG json = " + fg.getJson()

try {
JSONElement fgPostObj = webServicesService.postJsonElements(grailsApplication.config.fieldguide.url + "/generate", fg.getMap())
JSONElement fgPostObj = webServicesService.postJsonElements(grailsApplication.config.getProperty('fieldguide.url') + "/generate", fg.getMap())
//log.info "fgFileId = ${fgFileId}"

if (fgPostObj.fileId) {
response.sendRedirect(grailsApplication.config.fieldguide.url + "/guide/" + fgPostObj.fileId)
response.sendRedirect(grailsApplication.config.getProperty('fieldguide.url') + "/guide/" + fgPostObj.fileId)
} else {
flash.message = "No field guide found for requested taxa."
render view: '../error'
Expand Down Expand Up @@ -736,7 +736,7 @@ class OccurrenceController {

// profile details expand/collapse will be kept for whole session
private def getProfileDetailExpandState(userPref, HttpServletRequest request) {
def expandKey = "${grailsApplication.config.dataquality.expandKey}"
def expandKey = "${grailsApplication.config.getProperty('dataquality.expandKey')}"
def rawCookie = PostProcessingService.getCookieValue(request.getCookies(), expandKey, null)

// if already have expand/collapse settings, use it to overwrite user preference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class ProxyController {
stringMyHostName += ":" + httpServletRequest.getServerPort();
}
stringMyHostName += httpServletRequest.getContextPath();
httpServletResponse.sendRedirect(stringLocation.replace(getProxyHostAndPort() + (grailsApplication.config.proxy.proxyPath ?: ''), stringMyHostName));
httpServletResponse.sendRedirect(stringLocation.replace(getProxyHostAndPort() + grailsApplication.config.getProperty('proxy.proxyPath', String, ''), stringMyHostName));
log.debug "SC_MULTIPLE_CHOICES && SC_NOT_MODIFIED"
return;
} else if (intProxyResponseCode == HttpServletResponse.SC_NOT_MODIFIED) {
Expand Down Expand Up @@ -312,7 +312,7 @@ class ProxyController {

private String getProxyURL(HttpServletRequest httpServletRequest, String pathInfo) {
// Set the protocol to HTTP
String stringProxyURL = grailsApplication.config.biocache.baseUrl
String stringProxyURL = grailsApplication.config.getProperty('biocache.baseUrl')
// String stringProxyURL = (grailsApplication.config.proxy.proxyScheme?:'http:https://') + getProxyHostAndPort()
// String proxyPath = grailsApplication.config.proxy.proxyPath
// // Check if we are proxying to a path other that the document root
Expand Down Expand Up @@ -343,7 +343,7 @@ class ProxyController {
}

private String getProxyHostAndPort() {
String biocacheServiceUrl = grailsApplication.config.biocache.baseUrl
String biocacheServiceUrl = grailsApplication.config.getProperty('biocache.baseUrl')
def hostAndPort = (biocacheServiceUrl =~ /:\/\/(.*?)\//)[0][1]
// def proxyPort = grailsApplication.config.proxy.proxyPort?:80
// String hostAndPort = "${grailsApplication.config.proxy.proxyHost}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GeoIpService {
void init() {
//
// Path to "GeoIP2-City.mmdb"
String filePath = grailsApplication.config.geopip.database.path
String filePath = grailsApplication.config.getProperty('geopip.database.path')

// A File object pointing to your GeoIP2 or GeoLite2 database
File fileDatabase = new File(filePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ class PostProcessingService {
def LinkedHashMap getAllFacets(List defaultFacets) {
LinkedHashMap<String, Boolean> facetsMap = new LinkedHashMap<String, Boolean>()
List orderedFacets = []
List facetsToInclude = grailsApplication.config.facets?.include?.split(',') ?: []
List facetsToExclude = grailsApplication.config.facets?.exclude?.split(',') ?: []
List facetsToHide = grailsApplication.config.facets?.hide?.split(',') ?: []
List customOrder = grailsApplication.config.facets?.customOrder?.split(',') ?: []
List facetsToInclude = grailsApplication.config.getProperty('facets.include', List, [])
List facetsToExclude = grailsApplication.config.getProperty('facets.exclude', List, [])
List facetsToHide = grailsApplication.config.getProperty('facets.hide', List, [])
List customOrder = grailsApplication.config.getProperty('facets.customOrder', List, [])
List allFacets = new ArrayList(defaultFacets)
allFacets.addAll(facetsToInclude)

Expand Down Expand Up @@ -422,7 +422,7 @@ class PostProcessingService {
//log.debug "record = ${record as JSON}"
String stateProvince = ""
String stateKey = ""
Map statesListsPaths = grailsApplication.config.stateConservationListPath ?: [:]
Map statesListsPaths = grailsApplication.config.getProperty('stateConservationListPath', Map, [:])
// conservation list is state based, so first we need to know the state
modifiedRecord.get("Location")?.each {
if (it.name == "stateProvince") {
Expand All @@ -437,7 +437,7 @@ class PostProcessingService {
List statusValues = statusValue.tokenize(",").unique( false ) // remove duplicate values
statusValue = (statusValues.size() == 2) ? statusValues[1] : statusValues.join(", ") // only show 'sourceStatus' if 2 values are present

String specieslistUrl = "${grailsApplication.config.speciesList.baseURL}${statesListsPaths[stateKey]}"
String specieslistUrl = "${grailsApplication.config.getProperty('speciesList.baseURL')}${statesListsPaths[stateKey]}"
it.processed = "<a href=\"${specieslistUrl}\" target=\"_lists\">${stateProvince}: ${statusValue}</a>"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QualityService {
def apiClient = new ApiClient()
apiClient.adapterBuilder.baseUrl(dataQualityBaseUrl)
apiClient.okBuilder.addInterceptor { chain ->
def request = chain.request().newBuilder().addHeader('User-Agent', "${grailsApplication.config.info.app.name}/${grailsApplication.config.info.app.version}").build()
def request = chain.request().newBuilder().addHeader('User-Agent', "${grailsApplication.config.getProperty('info.app.name')}/${grailsApplication.config.getProperty('info.app.version')}").build()
chain.proceed(request)
}
api = apiClient.createService(QualityServiceRpcApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UserDataService {

if (userId && grailsApplication.config.userdetails.baseUrl) {
try {
def resp = webService.get(grailsApplication.config.userdetails.baseUrl + '/property/getProperty' +
def resp = webService.get(grailsApplication.config.getProperty('userdetails.baseUrl') + '/property/getProperty' +
"?alaId=${userId}&name=${URLEncoder.encode(NAME_PREFIX + type, "UTF-8")}")

if (resp?.resp && resp?.resp[0]?.value && resp?.resp[0]?.value) {
Expand All @@ -46,8 +46,8 @@ class UserDataService {

// return value indicates if set succeeds
boolean set(userId, type, data) {
if (userId && grailsApplication.config.userdetails.baseUrl) {
def response = webService.post(grailsApplication.config.userdetails.baseUrl + '/property/saveProperty', null,
if (userId && grailsApplication.config.getProperty('userdetails.baseUrl')) {
def response = webService.post(grailsApplication.config.getProperty('userdetails.baseUrl') + '/property/saveProperty', null,
[alaId: userId, name: NAME_PREFIX + type, value: (data as JSON).toString()])

return response?.statusCode == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class UserService {
Map getUserPref(String userId, HttpServletRequest request) {
def pref = [:]
if (dataQualityEnabled) {
def prefKey = "${grailsApplication.config.dataquality.prefkey}"
def prefKey = grailsApplication.config.getProperty('dataquality.prefkey', String, '')
if (userId != null) { // retrieve data from userdetails
pref = userDataService.get(userId, prefKey)
} else { // use cookie
Expand Down
Loading

0 comments on commit e623802

Please sign in to comment.