From 897a3c859d5587f215e4f7accd8e5843f668b9f5 Mon Sep 17 00:00:00 2001 From: christopher-johnson Date: Sat, 26 Aug 2017 05:53:40 +0200 Subject: [PATCH 1/7] restricts UpdateListener filter by URI --- .gitignore | 1 + build.gradle | 236 ++++++++++++++++++ fcrepo-api-x-binding/build.gradle | 33 +++ fcrepo-api-x-execution/build.gradle | 2 + fcrepo-api-x-indexing/build.gradle | 30 +++ .../indexing/impl/ServiceIndexingRoutes.java | 1 - fcrepo-api-x-integration/build.gradle | 40 +++ .../org/fcrepo/apix/integration/KarafIT.java | 2 + .../apix/integration/ListenerUpdateIT.java | 135 ---------- fcrepo-api-x-jena/build.gradle | 30 +++ fcrepo-api-x-karaf/build.gradle | 4 + fcrepo-api-x-listener/build.gradle | 16 ++ .../apix/listener/impl/UpdateListener.java | 49 ++-- .../src/main/resources/message.json | 61 +++++ fcrepo-api-x-loader/build.gradle | 14 ++ fcrepo-api-x-model/build.gradle | 2 + fcrepo-api-x-ontology/build.gradle | 2 + fcrepo-api-x-registry/build.gradle | 32 +++ fcrepo-api-x-routing/build.gradle | 34 +++ fcrepo-api-x-test/build.gradle | 9 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54783 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 +++++++++++++ gradlew.bat | 84 +++++++ settings.gradle | 28 +++ 25 files changed, 861 insertions(+), 162 deletions(-) create mode 100644 build.gradle create mode 100644 fcrepo-api-x-binding/build.gradle create mode 100644 fcrepo-api-x-execution/build.gradle create mode 100644 fcrepo-api-x-indexing/build.gradle create mode 100644 fcrepo-api-x-integration/build.gradle delete mode 100644 fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/ListenerUpdateIT.java create mode 100644 fcrepo-api-x-jena/build.gradle create mode 100644 fcrepo-api-x-karaf/build.gradle create mode 100644 fcrepo-api-x-listener/build.gradle create mode 100644 fcrepo-api-x-listener/src/main/resources/message.json create mode 100644 fcrepo-api-x-loader/build.gradle create mode 100644 fcrepo-api-x-model/build.gradle create mode 100644 fcrepo-api-x-ontology/build.gradle create mode 100644 fcrepo-api-x-registry/build.gradle create mode 100644 fcrepo-api-x-routing/build.gradle create mode 100644 fcrepo-api-x-test/build.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore index c316a91..3b9f061 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ bin/ .gitignore .vagrant /tls +build/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..336c36d --- /dev/null +++ b/build.gradle @@ -0,0 +1,236 @@ +import net.researchgate.release.GitAdapter + +buildscript { + repositories { + mavenCentral() + jcenter() + } + dependencies { + classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1' + } +} + +plugins { + id 'com.github.hierynomus.license' version '0.13.1' + id 'net.researchgate.release' version '2.6.0' + id 'io.codearte.nexus-staging' version '0.9.0' + id 'com.palantir.docker' version '0.13.0' +} + +allprojects { + apply plugin: 'maven' + + group = 'cool.pandora' + + repositories { + jcenter() + mavenCentral() + mavenLocal() + } + + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs.add("-Xlint:unchecked") + options.compilerArgs.add("-Xlint:deprecation") + } + } + + release { + tagTemplate = '$name-$version' + scmAdapters = [ + GitAdapter + ] + + git { + requireBranch = 'master' + pushToRemote = 'origin' + pushToBranchPrefix = '' + commitVersionFileOnly = false + } + } + +} + +subprojects { + apply plugin: 'com.bmuschko.nexus' + apply plugin: 'java' + apply plugin: 'maven-publish' + apply plugin: 'signing' + apply plugin: 'jacoco' + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + + ext { + vendor = 'Pandora Ecosystem' + homepage = 'http://cool.pandora' + docURL = 'https://github.com/pan-dora/pandora-demo/wiki' + license = 'Apache 2' + + camelVersionRange = '[2.18,3)' + activemqVersionRange = '[5.14,6)' + fcrepoCamelVersionRange = '[4.5,5)' + fcrepoCamelToolboxVersionRange = '[4.7.1,5)' + + /* Dependencies */ + activemqVersion = '5.14.1' + camelVersion = '2.18.0' + commonsIoVersion = '2.5' + commonsLangVersion = '3.4' + derbyVersion = '10.12.1.1' + fcrepoCamelVersion = '4.5.0' + fcrepoCamelToolboxVersion = '4.7.1' + guavaVersion = '18.0' + hk2Version = '2.4.0' + httpclientVersion = '4.5.2' + httpcoreVersion = '4.4.5' + jacksonVersion = '2.9.0' + jenaVersion = '3.1.1' + junitVersion = '4.12' + jsonldVersion = '0.10.4' + logbackVersion = '1.2.3' + marmottaVersion = '3.3.0' + postgresqlVersion = '9.4.1208' + rdf4jVersion = '2.2.2' + saxonVersion = '9.6.0-7' + slf4jVersion = '1.7.25' + springVersion = '4.1.7.RELEASE' + woodstoxVersion = '4.4.1' + xercesVersion = '2.11.0' + + /* Transitive deps */ + cal10nVersion = '0.8.1' + commonsBeanutilsVersion = '1.8.3' + commonsCodecVersion = '1.10' + commonsCollectionsVersion = '3.2.1' + commonsCsvVersion = '1.4' + commonsDigesterVersion = '1.8' + commonsHttpclientVersion = '3.1' + commonsValidatorVersion = '1.4.0' + dexxVersion = '0.6' + fluentHcVersion = '4.5.2' + fcrepoClientVersion = '0.2.1' + httpclientCacheVersion = '4.3.5' + httpmimeVersion = '4.5.2' + httpcoreNioVersion = '4.4.4' + jaxenVersion = '1.1.6' + jdom2Version = '2.0.5' + jodaTimeVersion = '2.5' + jsonldSesameVersion = '0.5.1' + semarglVersion = '0.6.1' + sesameVersion = '2.7.13' + thriftVersion = '0.9.2' + + /* Testing */ + paxExamVersion = '4.9.1' + karafVersion = '4.0.5' + fcrepoVersion = '4.6.0' + fusekiVersion = '2.3.1' + xercesVersion = '2.11.0' + osgiVersion = '4.3.1' + + /* OSGi */ + defaultOsgiImports = 'org.osgi.service.blueprint;version="[1,2)",*' + projectOsgiVersion = project.version.replaceAll("-SNAPSHOT", ".SNAPSHOT") + } + + task sourceJar(type: Jar) { + classifier 'sources' + from sourceSets.main.allSource + } + + artifacts { + archives sourceJar + } + + jacoco { + toolVersion = "0.7.9" + } + + publishing { + publications { + maven(MavenPublication) { + from components.java + } + } + repositories { + maven { + url "$buildDir/maven" + } + } + } + + modifyPom { + //noinspection GroovyAssignabilityCheck + project { + name 'API-X' + description 'API-X' + url 'https://github.com/fcrepo4-labs/fcrepo-api-x/' + inceptionYear '2017' + + developers { + developer { + id 'christopher-johnson' + name 'Christopher Johnson' + email 'chjohnson @ (domain of organization url)' + organization '' + organizationUrl '' + roles { + role 'developer' + } + timezone '+1' + } + } + + scm { + connection 'scm:git:git://github.com/fcrepo4-labs/fcrepo-api-x.git' + developerConnection 'scm:git:git@github.com/fcrepo4-labs/fcrepo-api-x.git' + url 'https://github.com/fcrepo4-labs/fcrepo-api-x/' + tag 'HEAD' + } + + licenses { + license { + name 'Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0' + } + } + } + } + + nexusStaging { + packageGroup = "cool.pandora" + stagingProfileId = "4d5f13c386f543" + } + + nexus { + sign = true + repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' + } +} + +configurations { + buildToolsConfig +} + +def homeDir = System.getProperty('user.home') +def mavenLocal = new File(homeDir, ".m2/repository/cool/pandora") + +docker { + name 'pandorasystems/apix' + tags 'latest' + dockerfile file('messaging/latest/Dockerfile') + copySpec.from("${buildDir}/maven").into("repository/cool/pandora") + files "${projectDir}/cfg", "entrypoint.sh" + buildArgs([BUILD_VERSION: 'version']) + labels(['key': 'value']) + pull true + noCache true +} + +task copyTask(type: Copy) { + from mavenLocal + into 'build/maven' +} + diff --git a/fcrepo-api-x-binding/build.gradle b/fcrepo-api-x-binding/build.gradle new file mode 100644 index 0000000..d9c3f37 --- /dev/null +++ b/fcrepo-api-x-binding/build.gradle @@ -0,0 +1,33 @@ + +description = '' +dependencies { + compile project(':fcrepo-api-x-model') + compile(group: 'org.fcrepo.client', name: 'fcrepo-java-client', version:'0.2.1') { +exclude(module: '*') + } + compile(group: 'org.apache.httpcomponents', name: 'httpclient-osgi', version:'4.5.2') { +exclude(module: 'httpclient') +exclude(module: 'httpcore') +exclude(module: 'httpclient-cache') +exclude(module: 'httpmime') +exclude(module: 'fluent-hc') +exclude(module: 'commons-codec') + } + compile(group: 'org.apache.httpcomponents', name: 'httpcore-osgi', version:'4.4.5') { +exclude(module: 'httpcore') +exclude(module: 'httpcore-nio') + } + compile group: 'commons-io', name: 'commons-io', version:'2.5' + testCompile group: 'junit', name: 'junit', version:'4.12' + testCompile group: 'org.mockito', name: 'mockito-all', version:'1.10.19' + compile(group: 'org.slf4j', name: 'slf4j-api', version:'1.7.13') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } + compile(group: 'org.osgi', name: 'org.osgi.service.component.annotations', version:'1.3.0') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } +} diff --git a/fcrepo-api-x-execution/build.gradle b/fcrepo-api-x-execution/build.gradle new file mode 100644 index 0000000..408c4dc --- /dev/null +++ b/fcrepo-api-x-execution/build.gradle @@ -0,0 +1,2 @@ + +description = '' diff --git a/fcrepo-api-x-indexing/build.gradle b/fcrepo-api-x-indexing/build.gradle new file mode 100644 index 0000000..cb0425b --- /dev/null +++ b/fcrepo-api-x-indexing/build.gradle @@ -0,0 +1,30 @@ + +description = '' +dependencies { + compile project(':fcrepo-api-x-model') + testCompile group: 'org.apache.camel', name: 'camel-test-blueprint', version:'2.18.1' + testCompile group: 'junit', name: 'junit', version:'4.12' + testCompile group: 'org.mockito', name: 'mockito-all', version:'1.10.19' + testCompile group: 'ch.qos.logback', name: 'logback-classic', version:'1.2.3' + testCompile group: 'org.apache.servicemix.bundles', name: 'org.apache.servicemix.bundles.xerces', version:'2.11.0_1' + compile(group: 'org.fcrepo.camel', name: 'fcrepo-camel', version:'4.5.0') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } + compile(group: 'org.apache.camel', name: 'camel-core', version:'2.18.1') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } + compile(group: 'org.apache.camel', name: 'camel-http4', version:'2.18.1') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } + compile(group: 'org.slf4j', name: 'slf4j-api', version:'1.7.13') { + /* This dependency was originally in the Maven provided scope, but the project was not of type war. + This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency. + Please review and delete this closure when resolved. */ + } +} diff --git a/fcrepo-api-x-indexing/src/main/java/org/fcrepo/apix/indexing/impl/ServiceIndexingRoutes.java b/fcrepo-api-x-indexing/src/main/java/org/fcrepo/apix/indexing/impl/ServiceIndexingRoutes.java index 3c79340..f2cd2fd 100644 --- a/fcrepo-api-x-indexing/src/main/java/org/fcrepo/apix/indexing/impl/ServiceIndexingRoutes.java +++ b/fcrepo-api-x-indexing/src/main/java/org/fcrepo/apix/indexing/impl/ServiceIndexingRoutes.java @@ -144,7 +144,6 @@ public void configure() throws Exception { .setHeader(Exchange.HTTP_METHOD, constant("HEAD")) .setHeader(Exchange.HTTP_URI, header(FCREPO_URI)) .setHeader("Accept", constant("application/n-triples")) - // This is annoying, no easy way around .doTry() .to("http://get-servicedoc-uri?httpClient=#httpClient") diff --git a/fcrepo-api-x-integration/build.gradle b/fcrepo-api-x-integration/build.gradle new file mode 100644 index 0000000..ac74b66 --- /dev/null +++ b/fcrepo-api-x-integration/build.gradle @@ -0,0 +1,40 @@ +description = '' +dependencies { + compile project(':fcrepo-api-x-karaf') + compile project(':fcrepo-api-x-test') + compile group: 'org.jsoup', name: 'jsoup', version: '1.9.2' + compile(group: 'org.apache.jena', name: 'jena-osgi', version: '3.1.1') { + exclude(module: 'org.osgi.core') + } + compile(group: 'org.fcrepo.client', name: 'fcrepo-java-client', version: '0.2.1') { + exclude(module: '*') + } + compile group: 'org.apache.felix', name: 'org.apache.felix.framework', version: '5.4.0' + testCompile group: 'org.apache.camel.karaf', name: 'apache-camel', version: '2.18.1', classifier: 'features', ext: 'xml' + testCompile(group: 'org.apache.httpcomponents', name: 'httpclient-osgi', version: '4.5.2') { + exclude(module: 'httpclient') + exclude(module: 'httpcore') + exclude(module: 'httpclient-cache') + exclude(module: 'httpmime') + exclude(module: 'fluent-hc') + exclude(module: 'commons-codec') + } + testCompile project(':fcrepo-api-x-model') + testCompile project(':fcrepo-api-x-jena') + testCompile project(':fcrepo-api-x-routing') + testCompile group: 'org.apache.camel', name: 'camel-test', version: '2.18.1' + testCompile group: 'org.apache.karaf.features', name: 'standard', version: '4.0.7', classifier: 'features', ext: 'xml' + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-container-karaf', version: '4.9.2' + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam-junit4', version: '4.9.2' + testCompile group: 'org.ops4j.pax.exam', name: 'pax-exam', version: '4.9.2' + testCompile group: 'org.ops4j.pax.url', name: 'pax-url-aether', version: '2.5.1' + testCompile group: 'javax.inject', name: 'javax.inject', version: '1' + testCompile group: 'org.osgi', name: 'org.osgi.core', version: '5.0.0' + testCompile group: 'junit', name: 'junit', version: '4.12' + testCompile group: 'commons-io', name: 'commons-io', version: '2.5' + testCompile(group: 'org.fcrepo', name: 'fcrepo-webapp', version: '4.7.2') { + exclude(module: '*') + } + testCompile group: 'org.apache.jena', name: 'jena-fuseki-war', version: '2.4.1' + testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.13' +} diff --git a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/KarafIT.java b/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/KarafIT.java index d83804a..e0a9f90 100644 --- a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/KarafIT.java +++ b/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/KarafIT.java @@ -86,6 +86,8 @@ public interface KarafIT { URI serviceContainer = URI.create(System.getProperty("registry.service.container", "")); + URI extensionObjectContainer = URI.create(apixBaseURI + "/apix/extensions/objects"); + URI ontologyContainer = URI.create(System.getProperty("registry.ontology.container", "")); /** diff --git a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/ListenerUpdateIT.java b/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/ListenerUpdateIT.java deleted file mode 100644 index 7abbae9..0000000 --- a/fcrepo-api-x-integration/src/test/java/org/fcrepo/apix/integration/ListenerUpdateIT.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to DuraSpace under one or more contributor license agreements. - * See the NOTICE file distributed with this work for additional information - * regarding copyright ownership. - * - * DuraSpace licenses this file to you 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 - * - * http://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. - */ - -package org.fcrepo.apix.integration; - -import static org.fcrepo.apix.integration.KarafIT.attempt; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.ops4j.pax.exam.CoreOptions.maven; -import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; - -import java.net.URI; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; - -import org.fcrepo.apix.model.components.Updateable; - -import org.apache.camel.CamelContext; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.options.MavenUrlReference; -import org.ops4j.pax.exam.util.Filter; -import org.osgi.framework.BundleContext; - -/** - * Verifies that the listener updates updateable services. - * - * @author apb@jhu.edu - */ -@RunWith(PaxExam.class) -public class ListenerUpdateIT implements KarafIT { - - @Inject - public BundleContext cxt; - - @Rule - public TestName name; - - // Make sure the test doesn't start before the listener context has started. - @Inject - @Filter("(role=apix-listener)") - CamelContext camelContext; - - @Override - public String testClassName() { - return ListenerUpdateIT.class.getSimpleName(); - } - - @Override - public String testMethodName() { - return name.getMethodName(); - } - - @BeforeClass - public static void init() throws Exception { - KarafIT.createContainers(); - } - - @Override - public List