Commit c5d55734 authored by acoburn's avatar acoburn
Browse files

initial commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-parent</artifactId>
<version>4.3.1-SNAPSHOT</version>
</parent>
<groupId>edu.amherst.acdc</groupId>
<artifactId>repo-services</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Repository Services for use with Fedora</name>
<description>A collection of repository services for use with Fedora</description>
<properties>
<activemq.version>5.12.0</activemq.version>
<camel.version>2.15.2</camel.version>
<commons-lang.version>3.4</commons-lang.version>
<fcrepo-camel.version>4.3.0</fcrepo-camel.version>
<jsonld.version>0.6.0</jsonld.version>
<logback.version>1.1.2</logback.version>
<slf4j.version>1.7.7</slf4j.version>
<junit.version>4.11</junit.version>
</properties>
<modules>
<module>repo-id-mapper</module>
<module>repo-id-minter</module>
<module>repo-karaf</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>${activemq.version}</version>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
<version>${fcrepo-camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-blueprint</artifactId>
<version>${camel.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<defaultGoal>install</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${camel.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>${jacoco.agent.it.arg}</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>edu.amherst.acdc</groupId>
<artifactId>repo-services</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>repo-id-mapper</artifactId>
<packaging>bundle</packaging>
<name>ID mapping service</name>
<description>Camel-based service for mapping public IDs to Fedora IDs</description>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cassandraql</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-blueprint</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- reserve network ports for integration testing -->
<!-- add configuration file to artifact set for OSGi deployment -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/cfg/edu.amherst.acdc.idmapper.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
# The name of the container where internal audit events are created (if using
# http://github.com/fcrepo4-exts/fcrepo-audit). Events about
# resources in this container are ignored.
audit.container=/audit
# In the event of failure, the maximum number of times a redelivery will be attempted.
error.maxRedeliveries=10
# The baseUri to use for event URIs in the triplestore. A `UUID` will be appended
# to this value, forming, for instance: `http://example.com/event/{UUID}`
event.baseUri=http://example.com/event
# The connection URI used to connect to a local or remote ActiveMQ broker
jms.brokerUrl=tcp://localhost:61616
# The camel URI for the incoming message stream.
input.stream=activemq:topic:fedora
# The base URL of the triplestore being used.
triplestore.baseUrl=localhost:8080/fuseki/test/update
/**
* 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
*
* 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 edu.amherst.acdc.idmapper;
import org.apache.camel.builder.xml.Namespaces;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
/**
* A content router for handling JMS events.
*
* @author Aaron Coburn
* @author escowles
*/
public class EventRouter extends RouteBuilder {
private static final String CQL_INSERT = "insert into uris(fedora, public) values (?, ?)";
private static final String CQL_GET = "";
private static final String CQL_DELETE = "";
/**
* Configure the message route workflow.
*/
public void configure() throws Exception {
final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
ns.add("dc", "http://purl.org/dc/elements/1.1/");
/**
* A generic error handler (specific to this RouteBuilder)
*/
onException(Exception.class)
.maximumRedeliveries("{{error.maxRedeliveries}}")
.log("Event Routing Error: ${routeId}");
/**
* Process a message.
*/
from("{{input.stream}}")
.routeId("IdMapperRouter")
.to("direct:event");
from("direct:event")
.routeId("IdMappingEventRouter")
.log(LoggingLevel.INFO, "edu.amherst.acdc.idmapper",
"IdMapping Event: ${headers[org.fcrepo.jms.identifier]}")
.to("fcrepo:localhost:8080/rest?preferOmit=PreferContainment")
.filter(ns.xpath("/rdf:RDF/rdf:Description/dc:identifier"))
.split().xtokenize("//dc:identifier", ns)
.transform().xpath("/dc:identifier/@rdf:resource|/dc:identifier/text()", String.class, ns)
.log("Body: ${body}")
.process(new IdProcessor())
.to("jdbc:idmapper");
from("direct:get")
.routeId("IdMappingFetchRouter")
.log("${headers}")
.to("mock:jdbc:idmapper");
from("direct:put")
.routeId("IdMappingPutRouter")
.log("${headers}")
.to("mock:jdbc:idmapper");
from("direct:delete")
.routeId("IdMappingDeleteRouter")
.log("${headers}")
.to("mock:jdbc:idmapper");
}
}
/**
* 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
*
* 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 edu.amherst.acdc.idmapper;
/**
* @author acoburn
*/
public final class IdMapperHeaders {
//public static final String EVENT_BASE_URI = "CamelAmherstIdMapperEventBaseUri";
//public static final String EVENT_URI = "CamelAuditEventUri";
private IdMapperHeaders() {
// prevent instantiation
}
}
/**
* Copyright 2015 DuraSpace, Inc.
*
* 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
*
* 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 edu.amherst.acdc.idmapper;
import static org.fcrepo.camel.JmsHeaders.IDENTIFIER;
import java.util.Arrays;
import java.util.List;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
/**
* @author Aaron Coburn
*/
public class IdProcessor implements Processor {
/**
* Define how a message should be processed.
*
* @param exchange the current camel message exchange */
public void process(final Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final String id = in.getBody(String.class);
// update exchange
final List<String> data = Arrays.asList(in.getHeader(IDENTIFIER, String.class), id);
if (data.size() == 2) {
in.setBody(data);
} else {
in.setBody(null);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!-- OSGI blueprint property placeholder -->
<cm:property-placeholder persistent-id="org.fcrepo.camel.audit" update-strategy="reload">
<cm:default-properties>
<cm:property name="error.maxRedeliveries" value="10"/>
<cm:property name="jms.brokerUrl" value="tcp://localhost:61616"/>
<cm:property name="input.stream" value="activemq:topic:fedora"/>
<cm:property name="triplestore.baseUrl" value="localhost:8080/fuseki/test/update"/>
<!-- Base URI to be used in contructing the URI for the JMS event -->
<cm:property name="event.baseUri" value="http://example.com/event"/>
<cm:property name="audit.container" value="/audit"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="${jms.brokerUrl}"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<package>org.fcrepo.camel.audit.triplestore</package>
</camelContext>
</blueprint>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%p %d{HH:mm:ss.SSS} \(%c{0}\) %m%n</pattern>
</encoder>
</appender>
<logger name="org.fcrepo.camel.audit" additivity="false" level="${fcrepo.log.camel.audit:-INFO}">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.fcrepo.camel" additivity="false" level="${fcrepo.log.camel:-INFO}">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.fcrepo" additivity="false" level="${fcrepo.log:-INFO}">
<appender-ref ref="STDOUT"/>
</logger>
<root additivity="false" level="WARN">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF 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.
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>repo-services</artifactId>
<groupId>edu.amherst.acdc</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>edu.amherst.acdc</groupId>
<artifactId>repo-id-minter</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>repo-id-minter Blueprint Bundle</name>
<description>repo-id-minter OSGi blueprint bundle project.</description>
<properties>
<osgi.export.packages>edu.amhers.acdc.mint</osgi.export.packages>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- logging and testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- reserve network ports for integration testing -->
<!-- add configuration file to artifact set for OSGi deployment -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/cfg/edu.amherst.acdc.mint.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project><