From 62d935e100f4b34c7332de128bc7d85bfd1367e5 Mon Sep 17 00:00:00 2001 From: QBai <31238531+qifeng-bai@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:46:43 +1000 Subject: [PATCH] #275 Using Token in list deletion, instead of Api key --- .../services/au/org/ala/specieslist/HelperService.groovy | 6 +++--- .../services/au/org/ala/specieslist/QueryService.groovy | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/grails-app/services/au/org/ala/specieslist/HelperService.groovy b/grails-app/services/au/org/ala/specieslist/HelperService.groovy index cdbf39f4..d713555e 100644 --- a/grails-app/services/au/org/ala/specieslist/HelperService.groovy +++ b/grails-app/services/au/org/ala/specieslist/HelperService.groovy @@ -43,7 +43,7 @@ class HelperService { def grailsApplication - def localAuthService, authService, userDetailsService + def localAuthService, authService, userDetailsService, webService BieService bieService @@ -107,11 +107,11 @@ class HelperService { def deleteUrl = grailsApplication.config.collectory.baseURL +"/ws/dataResource/" + drId def http = new HTTPBuilder(deleteUrl) http.getClient().getParams().setParameter("http.socket.timeout", new Integer(5000)) - try { + http.setHeaders([Authorization: "Bearer ${webService.getTokenService().getAuthToken(false)}"]) + try { http.request(Method.DELETE) { requestContentType = ContentType.JSON - headers."Authorization" = "${grailsApplication.config.registryApiKey}" response.success = { resp -> def result = (resp.getEntity() != null ? EntityUtils.toString(resp.getEntity()) : "") log.info("${drId} has been deleted from ${grailsApplication.config.collectory.baseURL} with ${result}") diff --git a/grails-app/services/au/org/ala/specieslist/QueryService.groovy b/grails-app/services/au/org/ala/specieslist/QueryService.groovy index 74ba9050..f3356d3d 100755 --- a/grails-app/services/au/org/ala/specieslist/QueryService.groovy +++ b/grails-app/services/au/org/ala/specieslist/QueryService.groovy @@ -836,7 +836,7 @@ class QueryService { "group by kvp.key, kvp.value, kvp.vocabValue, kvp.itemOrder, kvp.key order by kvp.itemOrder, kvp.key, cnt desc", queryParameters) def timeStop = new Date() - log.info("Query KVP of " + fqs + "took " + TimeCategory.minus(timeStop, timeStart)) + log.info("Query KVP of ${fqs} took " + TimeCategory.minus(timeStop, timeStart)) //obtain the families from the common list facets def commonResults = SpeciesListItem.executeQuery("select sli.family, count(sli) as cnt from SpeciesListItem sli " + @@ -861,7 +861,7 @@ class QueryService { 'group by kvp.key, kvp.value, kvp.vocabValue, kvp.itemOrder order by kvp.itemOrder, kvp.key, cnt desc', queryParameters) def timeStop = new Date() - log.info("Query KVP of " + id + "took " + TimeCategory.minus(timeStop, timeStart)) + log.info("Query KVP of ${id} took " + TimeCategory.minus(timeStop, timeStart)) properties = results.findAll{it[1].length()1 } //obtain the families from the common list facets def commonResults = SpeciesListItem.executeQuery('select family, count(*) as cnt from SpeciesListItem ' +