diff --git a/.travis.yml b/.travis.yml index daca5306..c165ab15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: focal +arch: amd64 language: groovy jdk: - openjdk11 @@ -10,6 +12,7 @@ branches: - /^hotfix\/.*$/ services: - docker + - postgresql before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock @@ -21,14 +24,20 @@ cache: before_install: - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/1.29.1/docker-compose-`uname -s`-`uname -m` > docker-compose + - curl -L https://github.com/docker/compose/releases/download/v2.17.3/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin + - mkdir -p ~/.docker/cli-plugins/ + - cp docker-compose ~/.docker/cli-plugins/docker-compose + - sudo cp docker-compose /usr/local/bin - docker-compose -f elastic.yml up -d - 'export GRADLE_OPTS="-Dgrails.env=travis"' +install: + - 'travis_wait 30 ./gradlew clean' + - './gradlew assemble' + after_success: - - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && GRADLE_OPTS="-Dgrails.env=production" travis_retry ./gradlew clean assemble publish --stacktrace' + - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && GRADLE_OPTS="-Dgrails.env=production" travis_retry ./gradlew publish --stacktrace' after_script: - docker-compose -f elastic.yml kill diff --git a/build.gradle b/build.gradle index 9fefff62..0e13b7a7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,41 +1,51 @@ -buildscript { - repositories { - mavenLocal() - maven { url "https://nexus.ala.org.au/content/groups/public/" } - maven { url "https://repo.grails.org/grails/core" } - } - dependencies { - classpath "org.grails:grails-gradle-plugin:$grailsVersion" - classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0" - classpath "org.grails.plugins:hibernate5:7.0.5" - classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.3.2" - } -} - plugins { + id "groovy" + id "org.grails.grails-gsp" + id "org.grails.grails-web" + id "com.github.erdi.webdriver-binaries" + id "war" + id "idea" + id "com.bertramlabs.asset-pipeline" + id "application" + id "eclipse" + id "maven-publish" id "com.gorylenko.gradle-git-properties" version "2.3.2" - id "org.flywaydb.flyway" version "5.2.4" + id "org.flywaydb.flyway" version "9.4.0" } -version "2.0.4" +//buildscript { +// repositories { +// mavenLocal() +// maven { url "https://nexus.ala.org.au/content/groups/public/" } +// maven { url "https://plugins.gradle.org/m2/" } +// maven { url "https://repo.grails.org/grails/core" } +// } +// dependencies { +// classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion" +// classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.6" +// classpath "org.grails.plugins:hibernate5:7.3.0" +// classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.4.7" +// } +//} + +version "3.0.0" group "au.org.ala" -apply plugin:"eclipse" -apply plugin:"idea" -apply plugin:"war" -apply plugin:"org.grails.grails-web" -apply plugin:"com.github.erdi.webdriver-binaries" -apply plugin:"com.bertramlabs.asset-pipeline" -apply plugin:"org.grails.grails-gsp" -apply plugin: 'maven' -apply plugin: 'maven-publish' +//apply plugin:"eclipse" +//apply plugin:"idea" +//apply plugin:"war" +//apply plugin:"org.grails.grails-web" +//apply plugin:"com.github.erdi.webdriver-binaries" +//apply plugin:"org.grails.grails-gsp" +//apply plugin:"com.bertramlabs.asset-pipeline" +//apply plugin: 'maven-publish' //apply from: 'https://raw.githubusercontent.com/AtlasOfLivingAustralia/travis-build-configuration/master/travis_grails_publish.gradle' - -sourceCompatibility = 1.11 -targetCompatibility = 1.11 +// +//sourceCompatibility = 1.11 +//targetCompatibility = 1.11 //grails { @@ -45,141 +55,181 @@ targetCompatibility = 1.11 // } //} - repositories { mavenLocal() maven { url "https://nexus.ala.org.au/content/groups/public/" } - maven { url "https://repo.grails.org/grails/core" } mavenCentral() + maven { url "https://repo.grails.org/grails/core/" } } configurations { - developmentOnly - runtimeClasspath { - extendsFrom developmentOnly + all { + resolutionStrategy.force 'org.codehaus.groovy:groovy-xml:3.0.13' + resolutionStrategy.eachDependency { DependencyResolveDetails details-> + if (details.requested.group == 'org.seleniumhq.selenium') { + details.useVersion('4.14.1') + } + } } } +//configurations { +// developmentOnly +// runtimeClasspath { +// extendsFrom developmentOnly +// } +//} + configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } dependencies { - compile group: 'org.grails', name: 'grails-async' - compile group: 'org.grails', name: 'grails-async-gpars' + implementation group: 'org.grails', name: 'grails-async-gpars' - compile group: 'org.grails.plugins', name: 'grails-pretty-time', version: '4.0.0' - compile 'org.grails.plugins:csv:1.0.1' + implementation group: 'org.grails.plugins', name: 'grails-pretty-time', version: '4.0.0' + implementation 'org.grails.plugins:csv:1.0.1' - compile 'xml-apis:xml-apis:1.4.01' + implementation 'xml-apis:xml-apis:1.4.01' // TODO do we need these?? - compile 'com.opencsv:opencsv:5.6' - compile group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer', version: '20200713.1' + implementation 'com.opencsv:opencsv:5.7.1' + implementation group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer', version: '20211018.1' // ALA plugins - compile group: 'org.grails.plugins', name: 'ala-ws-plugin', version: '3.1.2', changing: true - compile group: 'org.grails.plugins', name: 'ala-bootstrap3', version: '4.1.0', changing: true - compile group: 'org.grails.plugins', name: 'ala-admin-plugin', version: '2.3.0', changing: true - compile group: 'org.grails.plugins', name: 'ala-auth', version: '5.1.1', changing: true - compile group: 'org.grails.plugins', name: 'ala-ws-security-plugin', version: '4.1.2', changing: true - compile group: 'au.org.ala.plugins.grails', name:'images-client-plugin', version: '1.1', changing: true + implementation group: 'org.grails.plugins', name: 'ala-auth', version: alaSecurityLibsVersion, changing: true + implementation group: 'org.grails.plugins', name: 'ala-ws-plugin', version: alaSecurityLibsVersion, changing: true + implementation group: 'org.grails.plugins', name: 'ala-ws-security-plugin', version: alaSecurityLibsVersion, changing: true + implementation group: 'org.grails.plugins', name: 'ala-bootstrap3', version: '4.1.0', changing: true + implementation group: 'org.grails.plugins', name: 'ala-admin-plugin', version: '2.3.0', changing: true + implementation group: 'au.org.ala.plugins.grails', name:'images-client-plugin', version: '1.1', changing: true // Added dependencies - runtime 'com.zaxxer:HikariCP:5.0.1' - compile 'org.grails.plugins:postgresql-extensions:7.0.0' - compile "org.flywaydb:flyway-core:5.2.4" - compile 'org.grails.plugins:cache-headers:2.0.2' - runtime 'org.codehaus.groovy:groovy-dateutil' - compile 'dk.glasius:external-config:2.0.1' - - compile 'org.grails.plugins:quartz:2.0.13' + runtimeOnly 'com.zaxxer:HikariCP:5.0.1' + implementation 'org.grails.plugins:postgresql-extensions:7.0.0' + implementation "org.flywaydb:flyway-core:9.4.0" + implementation 'org.grails.plugins:cache-headers:2.0.2' + runtimeOnly 'org.codehaus.groovy:groovy-dateutil' + implementation 'dk.glasius:external-config:3.1.1' + + implementation 'org.grails.plugins:quartz:2.0.13' implementation 'org.quartz-scheduler:quartz:2.2.1' // Is not pulled in by default - compile group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.7' - compile group: 'org.locationtech.jts', name: 'jts-core', version: '1.15.0' - compile "com.amazonaws:aws-java-sdk-s3:$amazonAwsSdkVersion" - compile 'org.javaswift:joss:0.10.4' - runtime 'org.postgresql:postgresql:42.3.3' + implementation group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.7' + implementation group: 'org.locationtech.jts', name: 'jts-core', version: '1.15.0' + implementation "com.amazonaws:aws-java-sdk-s3:$amazonAwsSdkVersion" + implementation 'org.javaswift:joss:0.10.4' + runtimeOnly 'org.postgresql:postgresql:42.5.4' - compile 'org.elasticsearch:elasticsearch:7.0.1' - compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.0.1' + implementation 'org.elasticsearch:elasticsearch:7.17.1' + implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.17.1' // override log4j in elasticsearch plugin // TODO remove this once no log4j vulnerable transitive deps are used. - runtime group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1' - runtime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1' - - compile 'org.imgscalr:imgscalr-lib:4.2' - compile 'org.apache.commons:commons-imaging:1.0-SNAPSHOT' - compile 'org.apache.tika:tika-core:2.0.0' - compile 'com.github.jai-imageio:jai-imageio-core:1.4.0' - compile 'au.org.ala:image-utils:1.9.0' - - compile 'net.lingala.zip4j:zip4j:2.9.1' - compile 'com.google.guava:guava:31.1-jre' - compile 'org.apache.avro:avro:1.11.0' +// runtimeOnly group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1' +// runtimeOnly group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1' + + implementation 'org.imgscalr:imgscalr-lib:4.2' + implementation 'org.apache.commons:commons-imaging:1.0-SNAPSHOT' + implementation 'org.apache.tika:tika-core:2.5.0' + implementation 'com.github.jai-imageio:jai-imageio-core:1.4.0' + implementation 'au.org.ala:image-utils:1.9.0' + + implementation 'net.lingala.zip4j:zip4j:2.10.0' + implementation 'com.google.guava:guava:31.1-jre' + implementation 'org.apache.avro:avro:1.11.0' implementation 'org.xerial.snappy:snappy-java:1.1.8.4' // Swagger - compile('au.org.ala.plugins:openapi:1.1.0') + implementation 'au.org.ala.plugins:openapi:1.1.0' // Google analytics requirement - compile 'com.google.api-client:google-api-client:1.33.2' - compile 'com.google.apis:google-api-services-analytics:v3-rev20190807-1.32.1' + implementation 'com.google.api-client:google-api-client:1.33.2' + implementation 'com.google.apis:google-api-services-analytics:v3-rev20190807-1.32.1' // Standard grails - developmentOnly("org.springframework.boot:spring-boot-devtools") - compile "org.springframework.boot:spring-boot-starter-logging" - compile "org.springframework.boot:spring-boot-autoconfigure" - compile "org.grails:grails-core" - compile "org.springframework.boot:spring-boot-starter-actuator" - compile "org.springframework.boot:spring-boot-starter-tomcat" - compile "org.grails:grails-web-boot" - compile "org.grails:grails-logging" - compile "org.grails:grails-plugin-rest" - compile "org.grails:grails-plugin-databinding" - compile "org.grails:grails-plugin-i18n" - compile "org.grails:grails-plugin-services" - compile "org.grails:grails-plugin-url-mappings" - compile "org.grails:grails-plugin-interceptors" - compile "org.grails.plugins:cache" - compile "org.grails.plugins:cache-ehcache:3.0.0" - compile "org.grails.plugins:async" - compile "org.grails.plugins:scaffolding" - compile "org.grails.plugins:events" - compile "org.grails.plugins:hibernate5" -// compile "org.hibernate:hibernate-core:5.4.18.Final" - compile "org.hibernate:hibernate-jcache" - runtime 'org.ehcache:ehcache' - - compile "org.grails.plugins:gsp" - compileOnly "io.micronaut:micronaut-inject-groovy" - console "org.grails:grails-console" - profile "org.grails.profiles:web" - runtime "org.glassfish.web:el-impl:2.1.2-b03" -// runtime "com.h2database:h2" -// runtime "org.apache.tomcat:tomcat-jdbc" - runtime "javax.xml.bind:jaxb-api:2.3.1" - runtime 'com.bertramlabs.plugins:asset-pipeline-grails:3.3.2' - testCompile "io.micronaut:micronaut-inject-groovy" - testCompile "org.grails:grails-gorm-testing-support" - testCompile "org.mockito:mockito-core" - testCompile "org.grails:grails-web-testing-support" - testCompile "org.grails.plugins:geb" - testCompile "org.seleniumhq.selenium:selenium-remote-driver:3.14.0" - testCompile "org.seleniumhq.selenium:selenium-api:3.14.0" - testCompile "org.seleniumhq.selenium:selenium-support:3.14.0" - testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0" - testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0" - - testCompile 'io.micronaut:micronaut-http-client' + implementation("org.grails:grails-core") + implementation("org.grails:grails-logging") + implementation("org.grails:grails-plugin-databinding") + implementation("org.grails:grails-plugin-i18n") + implementation("org.grails:grails-plugin-interceptors") + implementation("org.grails:grails-plugin-rest") + implementation("org.grails:grails-plugin-services") + implementation("org.grails:grails-plugin-url-mappings") + implementation("org.grails:grails-web-boot") + implementation("org.grails.plugins:gsp") + implementation("org.grails.plugins:hibernate5") + implementation("org.grails.plugins:scaffolding") + implementation("org.hibernate:hibernate-core:5.6.15.Final") + implementation("org.springframework.boot:spring-boot-autoconfigure") + implementation("org.springframework.boot:spring-boot-starter") + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-starter-logging") + implementation("org.springframework.boot:spring-boot-starter-tomcat") + implementation("org.springframework.boot:spring-boot-starter-validation") + compileOnly("io.micronaut:micronaut-inject-groovy") + console("org.grails:grails-console") + runtimeOnly("com.bertramlabs.plugins:asset-pipeline-grails:4.3.0") + runtimeOnly("com.h2database:h2") + runtimeOnly("javax.xml.bind:jaxb-api:2.3.1") + runtimeOnly("org.apache.tomcat:tomcat-jdbc") + runtimeOnly("org.fusesource.jansi:jansi:1.18") + runtimeOnly("org.glassfish.web:el-impl:2.2.1-b05") + testImplementation("io.micronaut:micronaut-inject-groovy") + testImplementation("org.grails:grails-gorm-testing-support") + testImplementation("org.grails:grails-web-testing-support") + testImplementation("org.grails.plugins:geb") + testImplementation("org.seleniumhq.selenium:selenium-api:4.14.1") + testImplementation("org.seleniumhq.selenium:selenium-remote-driver:4.14.1") + testImplementation("org.seleniumhq.selenium:selenium-support:4.14.1") + testImplementation("org.spockframework:spock-core") + testRuntimeOnly("org.seleniumhq.selenium:selenium-chrome-driver:4.14.1") + testRuntimeOnly("org.seleniumhq.selenium:selenium-firefox-driver:4.14.1") + testRuntimeOnly("org.seleniumhq.selenium:selenium-safari-driver:4.14.1") + testImplementation("io.micronaut:micronaut-http-client") + + implementation "org.grails.plugins:cache-ehcache:3.0.0" + implementation "org.hibernate:hibernate-jcache" + runtimeOnly 'org.ehcache:ehcache' + +// testImplementation 'io.micronaut:micronaut-http-client' // Testing - testCompile 'org.grails.plugins:embedded-postgres:1.1.2' - testCompile "com.opentable.components:otj-pg-embedded:0.13.0" // required transitive dependency from the plugin. - testCompile 'cloud.localstack:localstack-utils:0.2.20' - testCompile "com.amazonaws:aws-java-sdk:$amazonAwsSdkVersion" // full AWS SDK included in test scope for localstack config - testCompile 'com.palantir.docker.compose:docker-compose-rule-junit4:1.7.0' + testImplementation 'ru.vyarus:spock-junit5:1.0.1' + testImplementation 'io.zonky.test:embedded-postgres:2.0.3' + testImplementation enforcedPlatform('io.zonky.test.postgres:embedded-postgres-binaries-bom:11.19.0') +// testImplementation "com.opentable.components:otj-pg-embedded:1.0.1" // required transitive dependency from the plugin. + testImplementation 'cloud.localstack:localstack-utils:0.2.22' + testImplementation "com.amazonaws:aws-java-sdk:$amazonAwsSdkVersion" // full AWS SDK included in test scope for localstack config + testImplementation 'com.palantir.docker.compose:docker-compose-junit-jupiter:1.8.0' + +} + +application { + mainClass.set("au.org.ala.images.Application") +} + +java { + sourceCompatibility = JavaVersion.toVersion("11") +} + +tasks.withType(Test) { + useJUnitPlatform() + systemProperty "geb.env", System.getProperty('geb.env') + systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") + systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver" + systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver" +} +tasks.withType(War).configureEach { War war -> + war.dependsOn compileGroovyPages +} +webdriverBinaries { + chromedriver '110.0.5481.77' + geckodriver '0.32.2' + edgedriver '110.0.1587.57' +} +assets { + minifyJs = true + minifyCss = true } bootJar { @@ -197,36 +247,59 @@ springBoot { // layout = 'WAR' } -bootRun { - ignoreExitValue true - jvmArgs( - '-Dspring.output.ansi.enabled=always', - '-noverify', - '-XX:TieredStopAtLevel=1', - '-Xmx1024m') - sourceResources sourceSets.main - String springProfilesActive = 'spring.profiles.active' - systemProperty springProfilesActive, System.getProperty(springProfilesActive) -} +//bootRun { +// ignoreExitValue true +// jvmArgs( +// '-Dspring.output.ansi.enabled=always', +// '-noverify', +// '-XX:TieredStopAtLevel=1', +// '-Xmx1024m') +// sourceResources sourceSets.main +// String springProfilesActive = 'spring.profiles.active' +// systemProperty springProfilesActive, System.getProperty(springProfilesActive) +//} +// +//tasks.withType(GroovyCompile) { +// configure(groovyOptions) { +// forkOptions.jvmArgs = ['-Xmx1024m'] +// } +//} +// +//tasks.withType(Test) { +// useJUnitPlatform() +//} -tasks.withType(GroovyCompile) { - configure(groovyOptions) { - forkOptions.jvmArgs = ['-Xmx1024m'] - } -} +//webdriverBinaries { +// if (!System.getenv().containsKey('GITHUB_ACTIONS')) { +// chromedriver { +// version = '2.45.0' +// fallbackTo32Bit = true +// } +// geckodriver '0.30.0' +// } +//} +// +//tasks.withType(Test) { +// systemProperty "geb.env", System.getProperty('geb.env') +// systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") +// if (!System.getenv().containsKey('GITHUB_ACTIONS')) { +// systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver') +// systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver') +// } else { +// systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver" +// systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver" +// } +//} -tasks.withType(Test) { - systemProperty "geb.env", System.getProperty('geb.env') - systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") - systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver') - systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver') +test { + testLogging.showStandardStreams = true } -assets { - minifyJs = true - minifyCss = true - includes = ["fonts/*"] -} +//assets { +// minifyJs = true +// minifyCss = true +// +//} publishing { repositories { @@ -241,19 +314,6 @@ publishing { } publications { mavenJar(MavenPublication) { - pom.withXml { - def pomNode = asNode() - pomNode.dependencyManagement.replaceNode {} - - // simply remove dependencies without a version - // version-less dependencies are handled with dependencyManagement - // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions - pomNode.dependencies.dependency.findAll { - it.version.text().isEmpty() - }.each { - it.replaceNode {} - } - } artifact bootJar } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..d4fe250f --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,9 @@ +repositories { + mavenCentral() + maven { url "https://repo.grails.org/grails/core/" } +} +dependencies { + implementation("com.bertramlabs.plugins:asset-pipeline-gradle:4.3.0") + implementation("org.grails:grails-gradle-plugin:6.1.0") + implementation("org.grails.plugins:hibernate5:8.0.1") +} \ No newline at end of file diff --git a/elastic.yml b/elastic.yml index e03719b7..5c120bf6 100644 --- a/elastic.yml +++ b/elastic.yml @@ -7,6 +7,7 @@ services: environment: - cluster.name=docker-cluster - discovery.type=single-node + - cluster.routing.allocation.disk.threshold_enabled=false image: "docker.elastic.co/elasticsearch/elasticsearch:7.9.2" networks: - elasticsearch diff --git a/gradle.properties b/gradle.properties index 8600ecb3..5cc249f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,13 @@ #Mon Mar 02 16:40:48 AEDT 2020 -grailsVersion=4.1.1 -gorm.version=7.0.8.RELEASE +grailsVersion=6.1.0 +grailsGradlePluginVersion=6.1.0 +version=3.0.0 +org.gradle.caching=true org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M -amazonAwsSdkVersion=1.11.734 \ No newline at end of file +gormVersion=8.0.0 +#groovyVersion=3.0.11 +#gorm.version=7.3.2 +amazonAwsSdkVersion=1.12.418 +alaSecurityLibsVersion=6.2.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 0daf269d..afba1092 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5b0d53c4..b1624c47 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jul 19 17:05:22 AEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/gradlew b/gradlew index 4453ccea..65dcd68d 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save ( ) { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d6..6689b85b 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,19 +25,23 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,38 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 0c9f3441..3f416722 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -93,7 +93,8 @@ grails: convertEmptyStringsToNull: false server: - contextPath: '' + servlet: + context-path: '' --- flyway: @@ -138,6 +139,9 @@ environments: registerMbeans: true connectionTimeout: 5000 test: + grails: + config: + locations: [] flyway: baselineOnMigrate: false dataSource: @@ -155,43 +159,25 @@ environments: exportDir: '/tmp/image-service/exports' batchUpload: '/tmp/image-service/uploads' travis: - flyway: - baselineOnMigrate: false - dataSource: - embeddedPostgres: true - pooled: true - jmxExport: true - embeddedPort: 6543 - username: postgres - password: postgres - url: jdbc:postgresql://localhost:6543/postgres?autoReconnect=true&connectTimeout=0&useUnicode=true&characterEncoding=UTF-8 - imageservice: - imagestore: - root: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-store' - inbox: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-incoming' - exportDir: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-exports' - batchUpload: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-uploads' -# travis: -# flyway: -# baselineOnMigrate: false -# dataSource: -# dbCreate: update -# embeddedPostgres: false -# logSql: false -# embeddedPort: 5432 -# url: jdbc:postgresql://localhost/images_travis?autoReconnect=true&connectTimeout=0&useUnicode=true&characterEncoding=UTF-8 -# username: "postgres" -# password: "postgres" -# type: "com.zaxxer.hikari.HikariDataSource" -# properties: -# maximumPoolSize: 30 -# registerMbeans: true -# connectionTimeout: 5000 -# imageservice: -# imagestore: -# root: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-store' -# inbox: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-incoming' -# exportDir: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-exports' + grails: + config: + locations: [ ] + flyway: + baselineOnMigrate: false + dataSource: + embeddedPostgres: true + pooled: true + jmxExport: true + embeddedPort: 6543 + username: postgres + password: postgres + url: jdbc:postgresql://localhost:6543/postgres?autoReconnect=true&connectTimeout=0&useUnicode=true&characterEncoding=UTF-8 + imageservice: + imagestore: + root: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-store' + inbox: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-incoming' + exportDir: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-exports' + batchUpload: '/home/travis/build/AtlasOfLivingAustralia/image-service/temp-uploads' production: hibernate: dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect @@ -237,7 +223,14 @@ security: enabled: true # default for backwards compat with v1 fallbackToLegacyKeys: true # Reset to false once legacy api keys no longer supported discoveryUri: ${security.oidc.discoveryUri} - + apikey: + auth: + serviceUrl: https://auth.ala.org.au/apikey/ + ip: + whitelist: + - 127.0.0.1 + - 0:0:0:0:0:0:0:1 + - ::1 imageservice: imagestore: root: '/data/image-service/store' diff --git a/grails-app/conf/logback.groovy b/grails-app/conf/logback.groovy-old similarity index 100% rename from grails-app/conf/logback.groovy rename to grails-app/conf/logback.groovy-old diff --git a/grails-app/conf/logback.xml b/grails-app/conf/logback.xml new file mode 100644 index 00000000..1579093c --- /dev/null +++ b/grails-app/conf/logback.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + UTF-8 + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + + + + + ${loggingDir}/${appName}-indexing.log + + ${loggingDir}/${appName}-indexing.%i.log.gz + 1 + 4 + + + 10MB + + + + UTF-8 + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + + + + INFO + + + + + ${loggingDir}/${appName}-batch.log + + ${loggingDir}/${appName}-batch.%i.log.gz + 1 + 4 + + + 10MB + + + + UTF-8 + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + + + + + ${loggingDir}/${appName}-timings.log + + ${loggingDir}/${appName}-timings.%i.log.gz + 1 + 4 + + + 10MB + + + + UTF-8 + %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/grails-app/conf/spring/resources.groovy b/grails-app/conf/spring/resources.groovy index 96e7fedf..0927d996 100644 --- a/grails-app/conf/spring/resources.groovy +++ b/grails-app/conf/spring/resources.groovy @@ -5,7 +5,7 @@ import org.springframework.beans.factory.config.BeanDefinition // Place your Spring DSL code here beans = { - if (application.config.flyway.enabled) { + if (application.config.getProperty('flyway.enabled', Boolean)) { flywayDataSource(PGSimpleDataSource) { bean -> url = application.config.getProperty('flyway.jdbcUrl') ?: application.config.getProperty('dataSource.url') @@ -15,7 +15,7 @@ beans = { flywayConfiguration(ClassicConfiguration) { bean -> dataSource = ref('flywayDataSource') - table = application.config.flyway.table + table = application.config.getProperty('flyway.table') baselineOnMigrate = application.config.getProperty('flyway.baselineOnMigrate', Boolean, true) def outOfOrderProp = application.config.getProperty('flyway.outOfOrder', Boolean, false) outOfOrder = outOfOrderProp @@ -24,8 +24,8 @@ beans = { 'exportRoot': application.config.getProperty('imageservice.imagestore.exportDir', '/data/image-service/exports'), 'baseUrl': application.config.getProperty('grails.serverURL') ] - locationsAsStrings = application.config.flyway.locations ?: 'classpath:db/migration' - if (application.config.flyway.baselineVersion) baselineVersionAsString = application.config.flyway.baselineVersion.toString() + locationsAsStrings = application.config.getProperty('flyway.locations', List, ['classpath:db/migration']) + if (application.config.getProperty('flyway.baselineVersion')) baselineVersionAsString = application.config.getProperty('flyway.baselineVersion', String) } flyway(Flyway, ref('flywayConfiguration')) { bean -> diff --git a/grails-app/controllers/au/org/ala/images/AdminController.groovy b/grails-app/controllers/au/org/ala/images/AdminController.groovy index 9dbd3837..3d7f0a65 100644 --- a/grails-app/controllers/au/org/ala/images/AdminController.groovy +++ b/grails-app/controllers/au/org/ala/images/AdminController.groovy @@ -357,7 +357,7 @@ class AdminController { def reindexImages() { flash.message = "Reindexing scheduled. Monitor progress using the search interface." imageService.scheduleBackgroundTask(new ScheduleReindexAllImagesTask(imageService, elasticSearchService, - grailsApplication.config.elasticsearch.batchIndexSize)) + grailsApplication.config.getProperty('elasticsearch.batchIndexSize', Integer))) redirect(action:'tools') } @@ -523,8 +523,8 @@ class AdminController { } def checkForMissingImages(){ - imageService.scheduleBackgroundTask(new ScheduleMissingImagesBackgroundTask(imageStoreService, grailsApplication.config.imageservice.exportDir)) - flash.message = "Check for missing images started......Output: " + grailsApplication.config.imageservice.exportDir + "/missing-images.csv"; + imageService.scheduleBackgroundTask(new ScheduleMissingImagesBackgroundTask(imageStoreService, grailsApplication.config.getProperty('imageservice.exportDir'))) + flash.message = "Check for missing images started......Output: " + grailsApplication.config.getProperty('imageservice.exportDir') + "/missing-images.csv"; redirect(action:'tools', message: flash.message) } diff --git a/grails-app/controllers/au/org/ala/images/BatchController.groovy b/grails-app/controllers/au/org/ala/images/BatchController.groovy index a656ade5..cd3e6a67 100644 --- a/grails-app/controllers/au/org/ala/images/BatchController.groovy +++ b/grails-app/controllers/au/org/ala/images/BatchController.groovy @@ -83,7 +83,7 @@ class BatchController { // move zip file from tmp working directory to uploads directory File uploadDir = new File( - grailsApplication.config.imageservice.batchUpload + + grailsApplication.config.getProperty('imageservice.batchUpload') + "/tmp-" + System.currentTimeMillis() + "/") FileUtils.forceMkdir(uploadDir) File tmpFile = new File(uploadDir, zipFile.originalFilename) diff --git a/grails-app/controllers/au/org/ala/images/ImageController.groovy b/grails-app/controllers/au/org/ala/images/ImageController.groovy index 49dadeb0..69a816dd 100644 --- a/grails-app/controllers/au/org/ala/images/ImageController.groovy +++ b/grails-app/controllers/au/org/ala/images/ImageController.groovy @@ -766,7 +766,7 @@ class ImageController { response.sendError(404) return } - if (grailsApplication.config.analytics.trackLargeViewer.toBoolean()) { + if (grailsApplication.config.getProperty('analytics.trackLargeViewer', Boolean)) { analyticsService.sendAnalytics(imageInstance, 'imagelargeviewer', request.getHeader("User-Agent")) } [imageInstance: imageInstance, auxDataUrl: params.infoUrl] @@ -804,7 +804,7 @@ class ImageController { } private getUserIdForRequest(HttpServletRequest request) { - if (grailsApplication.config.security.cas.disableCAS.toBoolean()){ + if (grailsApplication.config.getProperty('security.cas.disableCAS', Boolean, false)){ return "-1" } authService.getUserId() diff --git a/grails-app/controllers/UrlMappings.groovy b/grails-app/controllers/au/org/ala/images/UrlMappings.groovy similarity index 99% rename from grails-app/controllers/UrlMappings.groovy rename to grails-app/controllers/au/org/ala/images/UrlMappings.groovy index c1d282a4..74bcd85c 100644 --- a/grails-app/controllers/UrlMappings.groovy +++ b/grails-app/controllers/au/org/ala/images/UrlMappings.groovy @@ -1,3 +1,5 @@ +package au.org.ala.images + class UrlMappings { static mappings = { diff --git a/grails-app/controllers/au/org/ala/images/WebServiceController.groovy b/grails-app/controllers/au/org/ala/images/WebServiceController.groovy index 55f878fe..3e8bf52c 100644 --- a/grails-app/controllers/au/org/ala/images/WebServiceController.groovy +++ b/grails-app/controllers/au/org/ala/images/WebServiceController.groovy @@ -3,7 +3,6 @@ package au.org.ala.images import au.ala.org.ws.security.RequireApiKey import au.org.ala.plugins.openapi.Path import au.org.ala.web.SSO -import au.org.ala.ws.security.ApiKeyInterceptor import com.google.common.base.Suppliers import grails.converters.JSON import grails.converters.XML @@ -32,8 +31,9 @@ import static io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY class WebServiceController { - static allowedMethods = [findImagesByMetadata: 'POST', getImageInfoForIdList: 'POST'] + static String LEGACY_API_KEY_HEADER_NAME = 'apiKey' + static allowedMethods = [findImagesByMetadata: 'POST', getImageInfoForIdList: 'POST'] def imageService def imageStoreService def tagService @@ -87,10 +87,10 @@ class WebServiceController { def deleteImageService() { def success = false - def userId = request.getHeader(ApiKeyInterceptor.API_KEY_HEADER_NAME) + def userId = request.remoteUser ?: request.getHeader(LEGACY_API_KEY_HEADER_NAME) if(!userId) { - response.sendError(HttpStatus.SC_BAD_REQUEST, "Must include API key") + response.sendError(HttpStatus.SC_BAD_REQUEST, "Must send authentication") } else { def message = "" def image = Image.findByImageIdentifier(params.imageID as String, [ cache: true]) @@ -236,7 +236,7 @@ class WebServiceController { def scheduleArtifactGeneration() { def imageInstance = Image.findByImageIdentifier(params.id as String, [ cache: true]) - def userId = request.getHeader(ApiKeyInterceptor.API_KEY_HEADER_NAME) + def userId = request.remoteUser ?: request.getHeader(LEGACY_API_KEY_HEADER_NAME) def results = [success: true] if (params.id && !imageInstance) { @@ -305,7 +305,7 @@ class WebServiceController { @SSO def scheduleKeywordRegeneration() { def imageInstance = Image.findByImageIdentifier(params.id as String, [ cache: true]) - def userId = request.getHeader(ApiKeyInterceptor.API_KEY_HEADER_NAME) + def userId = request.remoteUser ?: request.getHeader(LEGACY_API_KEY_HEADER_NAME) def results = [success:true] if (params.id && !imageInstance) { results.success = false @@ -1259,7 +1259,7 @@ class WebServiceController { private getUserIdForRequest(HttpServletRequest request) { //check for API access - if (grailsApplication.config.security.cas.disableCAS.toBoolean()){ + if (grailsApplication.config.getProperty('security.cas.disableCAS', Boolean, false)){ return "-1" } diff --git a/grails-app/services/au/org/ala/images/AnalyticsService.groovy b/grails-app/services/au/org/ala/images/AnalyticsService.groovy index 44b3b50a..776a1faa 100644 --- a/grails-app/services/au/org/ala/images/AnalyticsService.groovy +++ b/grails-app/services/au/org/ala/images/AnalyticsService.groovy @@ -3,13 +3,10 @@ package au.org.ala.images import com.google.api.client.googleapis.auth.oauth2.GoogleCredential import com.google.api.services.analytics.AnalyticsScopes import groovy.json.JsonSlurper -import groovyx.net.http.HTTPBuilder +import java.nio.charset.StandardCharsets import java.util.concurrent.Executors -import static groovyx.net.http.ContentType.URLENC -import static groovyx.net.http.Method.POST - class AnalyticsService { def collectoryService @@ -31,8 +28,8 @@ class AnalyticsService { def now = (new Date() + 1 ).format( 'yyyy-MM-dd' ) //do authentication.... - def googleApiBaseUrl = grailsApplication.config.analytics.baseURL - def googleViewID = URLEncoder.encode(grailsApplication.config.analytics.viewID, "UTF-8") + def googleApiBaseUrl = grailsApplication.config.getProperty('analytics.baseURL') + def googleViewID = URLEncoder.encode(grailsApplication.config.getProperty('analytics.viewID'), "UTF-8") REPORT_PERIODS.each { label, period -> def lastMonth = "${googleApiBaseUrl}?ids=${googleViewID}&start-date=30daysAgo&end-date=${now}&dimensions=ga%3AeventCategory&metrics=ga%3AuniqueEvents&filters=ga%3AeventAction%3D%3D${dataResourceUID}&access_token=${accessToken}" @@ -53,8 +50,8 @@ class AnalyticsService { if (getAccessToken()) { def now = (new Date() + 1).format('yyyy-MM-dd') - def googleApiBaseUrl = grailsApplication.config.analytics.baseURL - def googleViewID = URLEncoder.encode(grailsApplication.config.analytics.viewID, "UTF-8") + def googleApiBaseUrl = grailsApplication.config.getProperty('analytics.baseURL') + def googleViewID = URLEncoder.encode(grailsApplication.config.getProperty('analytics.viewID'), "UTF-8") REPORT_PERIODS.each { label, period -> def lastMonth = "${googleApiBaseUrl}?ids=${googleViewID}&start-date=${period}&end-date=${now}&dimensions=ga%3AeventAction&metrics=ga%3AuniqueEvents&&access_token=${getAccessToken()}" @@ -79,10 +76,10 @@ class AnalyticsService { } String getAccessToken(){ - def credentialFile = new File(grailsApplication.config.analytics.credentialsJson) + def credentialFile = new File(grailsApplication.config.getProperty('analytics.credentialsJson')) if (credentialFile.exists()) { GoogleCredential credential = GoogleCredential - .fromStream(new FileInputStream(grailsApplication.config.analytics.credentialsJson)) + .fromStream(new FileInputStream(grailsApplication.config.getProperty('analytics.credentialsJson'))) .createScoped(Collections.singleton(AnalyticsScopes.ANALYTICS_READONLY)); credential.refreshToken() return credential.getAccessToken() @@ -113,20 +110,20 @@ class AnalyticsService { ] analyticsExecutor.execute { - def http = new HTTPBuilder(queryURL) try { - http.request( POST ) { - uri.path = '/collect' - requestContentType = URLENC - body = requestBody - - response.success = { resp -> - log.debug("Analytics POST response status: {}", resp.statusLine) - } - - response.failure = { resp -> - log.error("analytics request failed = {}", resp.status) - } + HttpURLConnection connection = (HttpURLConnection) queryURL.toString().toURL().openConnection() + connection.requestMethod = 'POST' + connection.setRequestProperty('Content-Type', 'application/x-www-form-urlencoded') + def formBody = toFormBody(requestBody).getBytes(StandardCharsets.UTF_8) + connection.doOutput = true + connection.outputStream.withStream { + it.write(formBody) + } + def responseCode = connection.responseCode + if (responseCode < 300) { + log.debug("Analytics POST response status: {}", connection.responseMessage) + } else { + log.error("analytics request failed = {}", connection.responseMessage) } } catch (Exception e) { log.error('Unable to send analytics for {}', requestBody, e) @@ -134,4 +131,8 @@ class AnalyticsService { } } } + + private String toFormBody(Map form) { + form.collect { k,v -> URLEncoder.encode(k, "UTF-8")+'='+URLEncoder.encode(v, "UTF-8") }.join('&') + } } diff --git a/grails-app/services/au/org/ala/images/BatchService.groovy b/grails-app/services/au/org/ala/images/BatchService.groovy index 5850cd0f..bf4d27d6 100644 --- a/grails-app/services/au/org/ala/images/BatchService.groovy +++ b/grails-app/services/au/org/ala/images/BatchService.groovy @@ -128,7 +128,7 @@ class BatchService { try { new ZipFile(uploadedFile).extractAll(uploadedFile.parentFile.absolutePath) - File newDir = new File(grailsApplication.config.imageservice.batchUpload + "/" + upload.getId() + "/") + File newDir = new File(grailsApplication.config.getProperty('imageservice.batchUpload') + "/" + upload.getId() + "/") if (!newDir.deleteDir()) { log.warn("Couldn't delete existing directory {} for batch upload {}", newDir) } @@ -522,7 +522,7 @@ class BatchService { def purgeCompletedJobs(){ ZonedDateTime now = ZonedDateTime.now() - ZonedDateTime threeDaysAgo = now.minusDays(grailsApplication.config.purgeCompletedAgeInDays.toInteger()) + ZonedDateTime threeDaysAgo = now.minusDays(grailsApplication.config.getProperty('purgeCompletedAgeInDays', Long)) //remove batch files BatchFile.findAllByStatus(COMPLETE).each { diff --git a/grails-app/services/au/org/ala/images/CollectoryService.groovy b/grails-app/services/au/org/ala/images/CollectoryService.groovy index 61f3e2ed..a2195976 100644 --- a/grails-app/services/au/org/ala/images/CollectoryService.groovy +++ b/grails-app/services/au/org/ala/images/CollectoryService.groovy @@ -32,7 +32,7 @@ class CollectoryService { } //if there no collectory configured, move on - if(!grailsApplication.config.collectory.baseURL){ + if (!grailsApplication.config.getProperty('collectory.baseURL')) { return } @@ -54,7 +54,7 @@ class CollectoryService { _uidLookupCache.clear() } - def getResourceLevelMetadata(dataResourceUid){ + def getResourceLevelMetadata(dataResourceUid) { def metadata = [:] @@ -64,7 +64,7 @@ class CollectoryService { //lookup the resource UID if(!_lookupCache.containsKey(dataResourceUid)){ - def url = grailsApplication.config.collectory.baseURL + "/ws/dataResource/" + dataResourceUid + def url = grailsApplication.config.getProperty('collectory.baseURL') + "/ws/dataResource/" + dataResourceUid try { def js = new JsonSlurper() def json = js.parseText(new URL(url).text) @@ -90,7 +90,7 @@ class CollectoryService { //lookup the resource UID if(!_uidLookupCache.containsKey(uid)){ - def url = grailsApplication.config.collectory.baseURL + "/ws/lookup/name/" + uid + def url = grailsApplication.config.getProperty('collectory.baseURL') + "/ws/lookup/name/" + uid try { def js = new JsonSlurper() def json = js.parseText(new URL(url).text) diff --git a/grails-app/services/au/org/ala/images/ElasticSearchService.groovy b/grails-app/services/au/org/ala/images/ElasticSearchService.groovy index de4adeec..23db8704 100644 --- a/grails-app/services/au/org/ala/images/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/images/ElasticSearchService.groovy @@ -10,8 +10,6 @@ import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse import org.elasticsearch.action.delete.DeleteRequest import org.elasticsearch.action.search.SearchScrollRequest -import org.elasticsearch.common.unit.TimeValue -import org.elasticsearch.common.xcontent.XContentType import groovy.json.JsonOutput import grails.web.servlet.mvc.GrailsParameterMap import org.apache.http.HttpHost @@ -28,6 +26,7 @@ import org.elasticsearch.action.search.SearchType import org.elasticsearch.client.RequestOptions import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestHighLevelClient +import org.elasticsearch.core.TimeValue import org.elasticsearch.index.query.BoolQueryBuilder import org.elasticsearch.index.query.QueryBuilders import org.elasticsearch.index.query.QueryStringQueryBuilder @@ -39,6 +38,7 @@ import org.elasticsearch.search.aggregations.BucketOrder import org.elasticsearch.search.builder.SearchSourceBuilder import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder import org.elasticsearch.search.sort.SortOrder +import org.elasticsearch.xcontent.XContentType import javax.annotation.PreDestroy import java.util.regex.Pattern @@ -84,7 +84,7 @@ class ElasticSearchService { def reinitialiseIndex() { try { def ct = new CodeTimer("Index deletion") - def response = client.indices().delete(new DeleteIndexRequest(grailsApplication.config.elasticsearch.indexName), RequestOptions.DEFAULT) + def response = client.indices().delete(new DeleteIndexRequest(grailsApplication.config.getProperty('elasticsearch.indexName')), RequestOptions.DEFAULT) if (response.isAcknowledged()) { log.info "The index is removed" } else { @@ -212,14 +212,14 @@ class ElasticSearchService { addAdditionalIndexFields(data) def json = (data as JSON).toString() - IndexRequest request = new IndexRequest(grailsApplication.config.elasticsearch.indexName) + IndexRequest request = new IndexRequest(grailsApplication.config.getProperty('elasticsearch.indexName')) request.id(imageIdentifier) request.source(json, XContentType.JSON) IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT) } def bulkIndexImageInES(list){ - BulkRequest bulkRequest = new BulkRequest(grailsApplication.config.elasticsearch.indexName) + BulkRequest bulkRequest = new BulkRequest(grailsApplication.config.getProperty('elasticsearch.indexName')) list.each { data -> def indexRequest = new IndexRequest() addAdditionalIndexFields(data) @@ -278,7 +278,7 @@ class ElasticSearchService { def deleteImage(Image image) { if (image) { - DeleteResponse response = client.delete(new DeleteRequest(grailsApplication.config.elasticsearch.indexName, image.imageIdentifier), RequestOptions.DEFAULT) + DeleteResponse response = client.delete(new DeleteRequest(grailsApplication.config.getProperty('elasticsearch.indexName'), image.imageIdentifier), RequestOptions.DEFAULT) if (response.status() && response.status().status){ log.info(response.status().status.toString()) } @@ -287,7 +287,7 @@ class ElasticSearchService { QueryResults simpleImageSearch(List searchCriteria, GrailsParameterMap params) { log.debug "search params: ${params}" - SearchRequest request = buildSearchRequest(params, searchCriteria, grailsApplication.config.elasticsearch.indexName as String) + SearchRequest request = buildSearchRequest(params, searchCriteria, grailsApplication.config.getProperty('elasticsearch.indexName') as String) SearchResponse searchResponse = client.search(request, RequestOptions.DEFAULT) final imageList = searchResponse.hits.collect { hit -> hit.getSourceAsMap() } ?: [] QueryResults qr = new QueryResults() @@ -307,7 +307,7 @@ class ElasticSearchService { QueryResults simpleFacetSearch(List searchCriteria, GrailsParameterMap params) { log.debug "search params: ${params}" - SearchRequest request = buildFacetRequest(params, searchCriteria, params.facet, grailsApplication.config.elasticsearch.indexName as String) + SearchRequest request = buildFacetRequest(params, searchCriteria, params.facet, grailsApplication.config.getProperty('elasticsearch.indexName') as String) SearchResponse searchResponse = client.search(request, RequestOptions.DEFAULT) QueryResults qr = new QueryResults() @@ -337,7 +337,7 @@ class ElasticSearchService { def fields = null final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L)); - SearchRequest searchRequest = buildSearchRequest(params, searchCriteria, grailsApplication.config.elasticsearch.indexName as String) + SearchRequest searchRequest = buildSearchRequest(params, searchCriteria, grailsApplication.config.getProperty('elasticsearch.indexName') as String) searchRequest.scroll(scroll) SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT) @@ -391,7 +391,7 @@ class ElasticSearchService { */ QueryResults search(Map query, GrailsParameterMap params) { log.debug "search params: ${params}" - SearchRequest request = buildSearchRequest(JsonOutput.toJson(query), params, grailsApplication.config.elasticsearch.indexName as String) + SearchRequest request = buildSearchRequest(JsonOutput.toJson(query), params, grailsApplication.config.getProperty('elasticsearch.indexName') as String) SearchResponse searchResponse = client.search(request, RequestOptions.DEFAULT) final imageList = searchResponse.hits ? Image.findAllByImageIdentifierInList(searchResponse.hits*.id) ?: [] : [] QueryResults qr = new QueryResults() @@ -455,7 +455,7 @@ class ElasticSearchService { SearchSourceBuilder source = pagenateQuery(params).query(boolQueryBuilder) // request aggregations (facets) - grailsApplication.config.facets.each { facet -> + grailsApplication.config.getProperty('facets', List).each { facet -> source.aggregation(AggregationBuilders.terms(facet as String).field(facet as String).size(10)) } @@ -526,7 +526,7 @@ class ElasticSearchService { SearchSourceBuilder source = pagenateQuery(params).query(boolQueryBuilder) // request aggregations (facets) - source.aggregation(AggregationBuilders.terms(facet as String).field(facet as String).size(grailsApplication.config.elasticsearch.maxFacetSize.toInteger()).order(BucketOrder.key(true))) + source.aggregation(AggregationBuilders.terms(facet as String).field(facet as String).size(grailsApplication.config.getProperty('elasticsearch.maxFacetSize', Integer)).order(BucketOrder.key(true))) //ask for the total source.trackTotalHits(false) @@ -538,9 +538,9 @@ class ElasticSearchService { private SearchSourceBuilder pagenateQuery(Map params) { - int maxOffset = grailsApplication.config.elasticsearch.maxOffset as int - int maxPageSize = grailsApplication.config.elasticsearch.maxPageSize as int - int defaultPageSize = grailsApplication.config.elasticsearch.defaultPageSize as int + int maxOffset = grailsApplication.config.getProperty('elasticsearch.maxOffset', Integer) + int maxPageSize = grailsApplication.config.getProperty('elasticsearch.maxPageSize', Integer) + int defaultPageSize = grailsApplication.config.getProperty('elasticsearch.defaultPageSize', Integer) SearchSourceBuilder source = new SearchSourceBuilder() @@ -573,9 +573,9 @@ class ElasticSearchService { private def initialiseIndex() { try { - boolean indexExists = client.indices().exists(new org.elasticsearch.client.indices.GetIndexRequest(grailsApplication.config.elasticsearch.indexName), RequestOptions.DEFAULT) + boolean indexExists = client.indices().exists(new org.elasticsearch.client.indices.GetIndexRequest(grailsApplication.config.getProperty('elasticsearch.indexName')), RequestOptions.DEFAULT) if (!indexExists){ - CreateIndexRequest request = new CreateIndexRequest(grailsApplication.config.elasticsearch.indexName) + CreateIndexRequest request = new CreateIndexRequest(grailsApplication.config.getProperty('elasticsearch.indexName')) CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT) if (createIndexResponse.isAcknowledged()) { log.info "Successfully created index and mappings for images" @@ -583,8 +583,8 @@ class ElasticSearchService { log.info "UN-Successfully created index and mappings for images" } - PutMappingRequest putMappingRequest = new PutMappingRequest(grailsApplication.config.elasticsearch.indexName) - putMappingRequest.type(grailsApplication.config.elasticsearch.indexName as String) + PutMappingRequest putMappingRequest = new PutMappingRequest(grailsApplication.config.getProperty('elasticsearch.indexName')) + putMappingRequest.type(grailsApplication.config.getProperty('elasticsearch.indexName') as String) putMappingRequest.source( """{ "properties": { @@ -738,7 +738,7 @@ class ElasticSearchService { if (params?.max) { searchSourceBuilder.size(params.int("max")) } else { - searchSourceBuilder.size(grailsApplication.config.elasticsearch.maxPageSize) // probably way too many! + searchSourceBuilder.size(grailsApplication.config.getProperty('elasticsearch.maxPageSize', Integer)) // probably way too many! } if (params?.sort) { @@ -748,7 +748,7 @@ class ElasticSearchService { def ct = new CodeTimer("Index search") SearchRequest searchRequest = new SearchRequest() - searchRequest.indices(grailsApplication.config.elasticsearch.indexName as String) + searchRequest.indices(grailsApplication.config.getProperty('elasticsearch.indexName') as String) searchRequest.source(searchSourceBuilder) SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT) @@ -790,7 +790,7 @@ class ElasticSearchService { GetMappingsRequest request = new GetMappingsRequest(); request.indices("images") GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT) - Map properties = getMappingResponse.mappings().values().first().value.first().value.sourceAsMap().properties + Map properties = getMappingResponse.mappings().values().first().values().first().sourceAsMap().properties properties.keySet() } } diff --git a/grails-app/services/au/org/ala/images/ImageService.groovy b/grails-app/services/au/org/ala/images/ImageService.groovy index 8ddb688e..37fb5c71 100644 --- a/grails-app/services/au/org/ala/images/ImageService.groovy +++ b/grails-app/services/au/org/ala/images/ImageService.groovy @@ -23,8 +23,6 @@ import org.apache.commons.io.FilenameUtils import org.apache.commons.lang.StringUtils import org.apache.tika.mime.MimeType import org.apache.tika.mime.MimeTypes -import org.grails.plugins.codecs.MD5CodecExtensionMethods -import org.grails.plugins.codecs.SHA1CodecExtensionMethods import org.hibernate.FlushMode import org.hibernate.ScrollMode import org.springframework.beans.factory.annotation.Value @@ -257,14 +255,10 @@ SELECT return imageID } - boolean isImageServiceUrl(String url){ - boolean isRecognised = false - grailsApplication.config.imageServiceUrls.each { imageServiceUrl -> - if (url.startsWith(imageServiceUrl)) { - isRecognised = true - } - } - isRecognised + boolean isImageServiceUrl(String url) { + def imageServiceUrls = grailsApplication.config.getProperty('imageServiceUrls', List, []) + boolean isRecognised = imageServiceUrls.any { imageServiceUrl -> url.startsWith(imageServiceUrl) } + return isRecognised } /** @@ -514,14 +508,14 @@ SELECT try { lock.lock() - def md5Hash = MD5CodecExtensionMethods.encodeAsMD5(bytes) + def md5Hash = bytes.encodeAsMD5() //check for existing image using MD5 hash def image = Image.findByContentMD5Hash(md5Hash) def preExisting = false def isDuplicate = false if (!image) { - def sha1Hash = SHA1CodecExtensionMethods.encodeAsSHA1(bytes) + def sha1Hash = bytes.encodeAsSHA1() Long defaultStorageLocationID = settingService.getStorageLocationDefault() @@ -1021,7 +1015,7 @@ SELECT List listStagedImages() { def files = [] - def inboxLocation = grailsApplication.config.imageservice.imagestore.inbox as String + def inboxLocation = grailsApplication.config.getProperty('imageservice.imagestore.inbox') as String def inboxDirectory = new File(inboxLocation) inboxDirectory.eachFile { File file -> files << file @@ -1077,7 +1071,7 @@ SELECT } def pollInbox(String batchId, String userId) { - def inboxLocation = grailsApplication.config.imageservice.imagestore.inbox as String + def inboxLocation = grailsApplication.config.getProperty('imageservice.imagestore.inbox') as String def inboxDirectory = new File(inboxLocation) inboxDirectory.eachFile { File file -> @@ -1599,8 +1593,8 @@ SELECT * @return */ File exportIndexToFile(){ - FileUtils.forceMkdir(new File(grailsApplication.config.imageservice.exportDir)) - def exportFile = grailsApplication.config.imageservice.exportDir + "/images-index.csv" + FileUtils.forceMkdir(new File(grailsApplication.config.getProperty('imageservice.exportDir'))) + def exportFile = grailsApplication.config.getProperty('imageservice.exportDir') + "/images-index.csv" def file = new File(exportFile) file.withWriter("UTF-8") { writer -> eachRowToCSV(writer, """SELECT * FROM export_index;""", []) diff --git a/grails-app/services/au/org/ala/images/ImageStagingService.groovy b/grails-app/services/au/org/ala/images/ImageStagingService.groovy index 9260a8cc..487f6b6b 100644 --- a/grails-app/services/au/org/ala/images/ImageStagingService.groovy +++ b/grails-app/services/au/org/ala/images/ImageStagingService.groovy @@ -55,7 +55,7 @@ class ImageStagingService { } private String getStagingDirectory(String userId) { - def basedir = grailsApplication.config.imageservice.imagestore.staging as String + def basedir = grailsApplication.config.getProperty('imageservice.imagestore.staging') as String def userdir = new File(combine(basedir, userId)) if (!userdir.exists()) { userdir.mkdirs() diff --git a/grails-app/services/au/org/ala/images/ImageStoreService.groovy b/grails-app/services/au/org/ala/images/ImageStoreService.groovy index e065ac7d..b173f4bd 100644 --- a/grails-app/services/au/org/ala/images/ImageStoreService.groovy +++ b/grails-app/services/au/org/ala/images/ImageStoreService.groovy @@ -174,7 +174,7 @@ class ImageStoreService { private List generateThumbnailsImpl(byte[] imageBytes, Image image) { def t = new ImageThumbnailer() def imageIdentifier = image.imageIdentifier - int size = grailsApplication.config.imageservice.thumbnail.size as Integer + int size = grailsApplication.config.getProperty('imageservice.thumbnail.size') as Integer def thumbDefs = [ new ThumbDefinition(size, false, null, "thumbnail"), new ThumbDefinition(size, true, null, "thumbnail_square"), diff --git a/grails-app/taglib/au/org/ala/images/TwitterBootstrapTagLib.groovy b/grails-app/taglib/au/org/ala/images/TwitterBootstrapTagLib.groovy index 9374d4c3..a7933d6a 100644 --- a/grails-app/taglib/au/org/ala/images/TwitterBootstrapTagLib.groovy +++ b/grails-app/taglib/au/org/ala/images/TwitterBootstrapTagLib.groovy @@ -32,7 +32,7 @@ class TwitterBootstrapTagLib { */ def paginate = { attrs -> -// def configTabLib = grailsApplication.config.grails.plugins.twitterbootstrap.fixtaglib +// def configTabLib = grailsApplication.config.getProperty('grails.plugins.twitterbootstrap.fixtaglib') // if (!configTabLib) { // def renderTagLib = grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.UrlMappingTagLib') // renderTagLib.paginate.call(attrs) diff --git a/grails-app/views/admin/analytics.gsp b/grails-app/views/admin/analytics.gsp index fff0d92a..41135f69 100644 --- a/grails-app/views/admin/analytics.gsp +++ b/grails-app/views/admin/analytics.gsp @@ -17,7 +17,7 @@ -
No results for analytics. Check GA credentials are available at ${grailsApplication.config.analytics.credentialsJson}
+
No results for analytics. Check GA credentials are available at ${grailsApplication.config.getProperty('analytics.credentialsJson')}

- total views: ${resultsPeriod.value.totalEvents}

diff --git a/grails-app/views/admin/batchUploads.gsp b/grails-app/views/admin/batchUploads.gsp index e69cce32..4d8dca82 100644 --- a/grails-app/views/admin/batchUploads.gsp +++ b/grails-app/views/admin/batchUploads.gsp @@ -221,7 +221,7 @@

Uploads (${results.size()})

- Uploads with a COMPLETE will be removed from this list in ${grailsApplication.config.purgeCompletedAgeInDays} + Uploads with a COMPLETE will be removed from this list in ${grailsApplication.config.getProperty('purgeCompletedAgeInDays')} days.

diff --git a/grails-app/views/admin/dashboard.gsp b/grails-app/views/admin/dashboard.gsp index e198d365..b8b1f2e7 100644 --- a/grails-app/views/admin/dashboard.gsp +++ b/grails-app/views/admin/dashboard.gsp @@ -17,7 +17,7 @@
${flash.errorMessage}
- +
WARNING: CAS authentication disabled - this means admin functions are exposed!
diff --git a/grails-app/views/admin/index.gsp b/grails-app/views/admin/index.gsp index 54f4ef69..68f056da 100644 --- a/grails-app/views/admin/index.gsp +++ b/grails-app/views/admin/index.gsp @@ -2,7 +2,7 @@ - Admin | ${grailsApplication.config.skin.orgNameLong} + Admin | ${grailsApplication.config.getProperty('skin.orgNameLong')} diff --git a/grails-app/views/admin/localIngest.gsp b/grails-app/views/admin/localIngest.gsp index 568c5297..fdc08346 100644 --- a/grails-app/views/admin/localIngest.gsp +++ b/grails-app/views/admin/localIngest.gsp @@ -31,7 +31,7 @@ Refresh file list -

File List - Reading local server directory: ${grailsApplication.config.imageservice.imagestore.inbox}

+

File List - Reading local server directory: ${grailsApplication.config.getProperty('imageservice.imagestore.inbox')}

diff --git a/grails-app/views/admin/tools.gsp b/grails-app/views/admin/tools.gsp index a7788ca8..cee1a96c 100644 --- a/grails-app/views/admin/tools.gsp +++ b/grails-app/views/admin/tools.gsp @@ -24,7 +24,7 @@ - Imports image files from the designated incoming server directory ("${grailsApplication.config.imageservice.imagestore.inbox}") + Imports image files from the designated incoming server directory ("${grailsApplication.config.getProperty('imageservice.imagestore.inbox')}") diff --git a/grails-app/views/error.gsp b/grails-app/views/error.gsp index d6f7460b..9d7e90c1 100644 --- a/grails-app/views/error.gsp +++ b/grails-app/views/error.gsp @@ -2,7 +2,7 @@ <g:if env="development">Grails Runtime Exception</g:if><g:else>Error</g:else> - + diff --git a/grails-app/views/image/_coreImageMetadataFragment.gsp b/grails-app/views/image/_coreImageMetadataFragment.gsp index 79445110..fe1d601e 100644 --- a/grails-app/views/image/_coreImageMetadataFragment.gsp +++ b/grails-app/views/image/_coreImageMetadataFragment.gsp @@ -6,7 +6,7 @@ - + ${resourceLevel.name} @@ -209,10 +209,10 @@ for (var i = 0; i < occurrences.length; ++i) { var occurrenceId = occurrences[i].uuid - ul.append($('
  • ').append($('').attr('href', '${grailsApplication.config.biocache.baseURL}/occurrences/' + encodeURIComponent(occurrenceId)).text(occurrenceId))); + ul.append($('
  • ').append($('').attr('href', '${grailsApplication.config.getProperty('biocache.baseURL')}/occurrences/' + encodeURIComponent(occurrenceId)).text(occurrenceId))); } if (startIndex + pageSize < totalRecords) { - ul.append($('
  • ').append($('...'))); + ul.append($('
  • ').append($('...'))); } $('#occurrences_container').append(ul); }).always(function() { diff --git a/grails-app/views/image/details.gsp b/grails-app/views/image/details.gsp index ed808a11..b0b68bc7 100644 --- a/grails-app/views/image/details.gsp +++ b/grails-app/views/image/details.gsp @@ -3,7 +3,7 @@ - + ${mediaTitle} - ${imageInstance.title ? imageInstance.title : imageInstance.imageIdentifier} diff --git a/grails-app/views/image/stagedImages.gsp b/grails-app/views/image/stagedImages.gsp index c1dcca48..098c3221 100644 --- a/grails-app/views/image/stagedImages.gsp +++ b/grails-app/views/image/stagedImages.gsp @@ -2,8 +2,8 @@ - - <g:message code="staged.images.image.service.title" /> | ${grailsApplication.config.skin.orgNameLong} + + <g:message code="staged.images.image.service.title" /> | ${grailsApplication.config.getProperty('skin.orgNameLong')}