Commit e6191a38 authored by acoburn's avatar acoburn
Browse files

transition to using jetty9, add mods transformation service

parent 2736421a
......@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<artifactId>camel-jetty9</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
......@@ -123,7 +123,6 @@
<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>
......
......@@ -39,7 +39,7 @@
<package>edu.amherst.acdc.idiomatic</package>
<restConfiguration component="restlet" port="{{rest.port}}"/>
<restConfiguration component="jetty" host="localhost" port="{{rest.port}}"/>
<route id="MinterRoute">
<description>Create a freshly minted ID</description>
......
......@@ -13,7 +13,7 @@
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${camel.version}">camel-restlet</feature>
<feature version="${camel.version}">camel-jetty9</feature>
<feature version="${camel.version}">camel-jackson</feature>
<feature version="${camel.version}">camel-sql</feature>
<feature version="${activemq.version}">activemq-camel</feature>
......@@ -54,4 +54,17 @@
<configfile finalname="/etc/edu.amherst.acdc.mint.cfg">mvn:edu.amherst.acdc/acrepo-mint-service/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-mods-xml-service" version="${project.version}" resolver="(orb)" start-level="50">
<details>Installs the MODS/XML translation service</details>
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${camel.version}">camel-jetty9</feature>
<feature version="${fcrepo-camel.version}">fcrepo-camel</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-mods-xml-service/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.mods.cfg">mvn:edu.amherst.acdc/acrepo-mods-xml-service/${project.version}/cfg/configuration</configfile>
</feature>
</features>
Camel Router Project for Blueprint (OSGi)
=========================================
To build this project use
mvn install
To run the project you can execute the following Maven goal
mvn camel:run
To deploy the project in OSGi. For example using Apache ServiceMix
or Apache Karaf. You can run the following command from its shell:
osgi:install -s mvn:edu.amherst.acdc/acrepo-mods-xml-service/1.0-SNAPSHOT
For more help see the Apache Camel documentation
http://camel.apache.org/
<?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>repository-services</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>acrepo-mods-xml-service</artifactId>
<packaging>bundle</packaging>
<name>RDF to MODS/XML transformation service</name>
<properties>
<osgi.private.packages>edu.amherst.acdc.mods</osgi.private.packages>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty9</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</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-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- Testing & Camel Plugin -->
<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-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<!-- to generate the MANIFEST-FILE of the bundle -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<!-- to run the example using mvn camel:run -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
</plugin>
<!-- 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.mods.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
# The location of the XSLT to convert RDF/XML to MODS/XML
mods.xslt=edu/amherst/acdc/mods/rdf2mods.xsl
<?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="edu.amherst.acdc.mods" update-strategy="reload">
<cm:default-properties>
<cm:property name="error.maxRedeliveries" value="10"/>
<cm:property name="rest.prefix" value="/mods"/>
<cm:property name="rest.port" value="10080"/>
<cm:property name="mods.xslt" value="edu/amherst/acdc/mods/rdf2mods.xsl"/>
<cm:property name="fcrepo.baseUrl" value="localhost:8080/fcrepo/rest"/>
</cm:default-properties>
</cm:property-placeholder>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" streamCache="false">
<route id="ModsTransformationRoute">
<from uri="jetty:http://0.0.0.0:{{rest.port}}{{rest.prefix}}?matchOnUriPrefix=true&amp;httpMethodRestrict=GET"/>
<setHeader headerName="CamelFcrepoIdentifier">
<simple>${headers[CamelHttpPath]}</simple>
</setHeader>
<log message="Fcrepo: ${headers[CamelFcrepoIdentifier]}"/>
<to uri="fcrepo:{{fcrepo.baseUrl}}?accept=application/rdf+xml"/>
<convertBodyTo type="org.w3c.dom.Document"/>
<!--<convertBodyTo type="java.lang.String"/>-->
<log message="Response: ${headers[CamelHttpResponseCode]}"/>
<log message="Body: ${body}"/>
<filter>
<simple>${headers[CamelHttpResponseCode]} == 200</simple>
<to uri="xslt:{{mods.xslt}}"/>
</filter>
</route>
</camelContext>
</blueprint>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
xmlns:dcterms='http://purl.org/dc/terms/'
xmlns:dc='http://purl.org/dc/elements/1.1/'
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs rdf rdfs dc dcterms"
version="1.0">
<xsl:output indent="yes" method="xml"></xsl:output>
<xsl:template match="/rdf:RDF/rdf:Description">
<mods:mods>
<xsl:for-each select="dc:title">
<mods:titleInfo>
<mods:title><xsl:value-of select="normalize-space(text())"/></mods:title>
</mods:titleInfo>
</xsl:for-each>
<xsl:for-each select="dc:subject">
<mods:subject authority="lcsh">
<mods:topic>
<xsl:value-of select="normalize-space(text())"/>
</mods:topic>
</mods:subject>
</xsl:for-each>
<xsl:for-each select="dcterms:abstract">
<xsl:if test="string-length(normalize-space(text()))">
<mods:abstract><xsl:value-of select="normalize-space(text())"/></mods:abstract>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="rdfs:comment">
<xsl:if test="string-length(normalize-space(text()))">
<mods:note><xsl:value-of select="normalize-space(text())"/></mods:note>
</xsl:if>
</xsl:for-each>
</mods:mods>
</xsl:template>
</xsl:stylesheet>
package edu.amherst.acdc.mods;
import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
import org.junit.Test;
/**
* @author acoburn
*/
public class RouteTest extends CamelBlueprintTestSupport {
@Override
protected String getBlueprintDescriptor() {
return "/OSGI-INF/blueprint/blueprint.xml";
}
@Test
public void testRoute() throws Exception {
// the route is timer based, so every 5th second a message is send
// we should then expect at least one message
getMockEndpoint("mock:result").expectedMinimumMessageCount(0);
// assert expectations
assertMockEndpointsSatisfied();
}
}
<?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="edu.amherst.acdc.mods" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.apache.camel" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.fcrepo.camel" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<root additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
......@@ -41,6 +41,7 @@
<module>acrepo-idiomatic</module>
<module>acrepo-mint-service</module>
<module>acrepo-karaf</module>
<module>acrepo-mods-xml-service</module>
</modules>
<dependencyManagement>
......@@ -57,7 +58,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<artifactId>camel-jetty9</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment