From 07db76012c0e652c47b394c35015476c7635ffc1 Mon Sep 17 00:00:00 2001 From: "Q.B" Date: Tue, 13 Sep 2022 09:31:09 +1000 Subject: [PATCH] Bump up to 5.0 and fix local config loading issue --- README.md | 9 +++--- build.gradle | 2 +- .../biocache/hubs/WebServicesService.groovy | 30 ++++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 110cf727..94fbfde6 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,11 @@ This application/plugin provides a web UI for a back-end service called [**bioca An example Grails application that uses this plugin, is the [**generic-hub**](https://github.com/AtlasOfLivingAustralia/generic-hub) app. There are other implementations listed in the [ALA Github repository](https://github.com/AtlasOfLivingAustralia?query=-hub) (all implementations have a suffix '-hub'). +## Updates +5.x support OIDC authentication + ## Versions -The grails4 branch contains the 1.5.x series of the plugin compatible with Grails 4.0.12. +5.x is based on Grails 4.0.12 and Java 11 The grails2 branch contains the 1.5.x series of the plugin compatible with Grails 2.x. @@ -24,10 +27,6 @@ To load and view you own occurrence record data, you'll need to install and run A full list of the configuration settings (and their default values) are found in `src/main/groovy/au/org/ala/biocache/hubs/defaultConfig.groovy`. -## Grails 4 - -Starting with verison 4.x - ## Grails 3 Starting with version 1.7 biocache-hubs has been migrated to run on Grails 3 and Java 8 diff --git a/build.gradle b/build.gradle index 6bd7c5c9..27845b25 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } } -version "4.1.0-SNAPSHOT" +version "5.0-SNAPSHOT" group "au.org.ala.plugins.grails" apply plugin:"eclipse" diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy index 17f14024..0be5eb78 100644 --- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy +++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy @@ -13,6 +13,7 @@ package au.org.ala.biocache.hubs +import grails.converters.JSON import grails.plugin.cache.CacheEvict import grails.plugin.cache.Cacheable @@ -437,20 +438,27 @@ class WebServicesService { JSONElement getJsonElements(String url, Boolean wsAuth = false, Boolean includeUser = false) { log.debug "(internal) getJson URL = " + url - Map result = webService.get(url, [:], ContentType.APPLICATION_JSON, wsAuth, includeUser) + def conn = new URL(url).openConnection() + if (conn instanceof HttpURLConnection) { + Map result = webService.get(url, [:], ContentType.APPLICATION_JSON, wsAuth, includeUser) - if (result.error) { + if (result.error) { - def error = "Failed to get json from web service (${url}) status ${result.statusCode} : ${result.error}" - log.error error - throw new RestClientException(error) - } + def error = "Failed to get json from web service (${url}) status ${result.statusCode} : ${result.error}" + log.error error + throw new RestClientException(error) + } - if (result.resp instanceof Collection) { - return new JSONArray(result.resp) - } - if (result.resp instanceof Map) { - return new JSONObject(result.resp) + if (result.resp instanceof Collection) { + return new JSONArray(result.resp) + } + if (result.resp instanceof Map) { + return new JSONObject(result.resp) + } + } else { + InputStream stream = conn.getInputStream() + JSONElement jsonOut = JSON.parse(stream, "UTF-8") + return jsonOut } def error = "Failed to get json from web service (${url}) : ${result}"