Commit 3e1e3319 authored by acoburn's avatar acoburn
Browse files

clean up JSON-LD service so that it acts like a real repo service

parent 82b5c759
......@@ -47,7 +47,7 @@
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-jsonld-cache</artifactId>
<artifactId>acrepo-jsonld-osgi</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -81,25 +81,14 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(), "acrepo-idiomatic",
"acrepo-idiomatic-pgsql", "acrepo-mint-service", "acrepo-xml-metadata",
"acrepo-jsonld-service", "acrepo-jsonld-cache", "acrepo-template-mustache"),
"acrepo-jsonld-service", "acrepo-jsonld-osgi", "acrepo-template-mustache"),
systemProperty("karaf.reindexing.port").value(reindexingPort),
systemProperty("fcrepo.port").value(fcrepoPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort),
editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort),
editConfigurationFilePut("etc/org.fcrepo.camel.indexing.triplestore.cfg", "fcrepo.baseUrl", fcrepoBaseUrl),
editConfigurationFilePut("etc/org.fcrepo.camel.indexing.triplestore.cfg", "triplestore.baseUrl",
triplestoreBaseUrl),
editConfigurationFilePut("etc/org.fcrepo.camel.indexing.solr.cfg", "fcrepo.baseUrl", fcrepoBaseUrl),
editConfigurationFilePut("etc/org.fcrepo.camel.indexing.solr.cfg", "input.stream", emptyTopic),
editConfigurationFilePut("etc/org.fcrepo.camel.reindexing.cfg", "fcrepo.baseUrl", fcrepoBaseUrl),
editConfigurationFilePut("etc/org.fcrepo.camel.reindexing.cfg", "rest.port", reindexingPort),
editConfigurationFilePut("etc/org.fcrepo.camel.serialization.cfg", "fcrepo.baseUrl", fcrepoBaseUrl),
editConfigurationFilePut("etc/org.fcrepo.camel.serialization.cfg", "serialization.descriptions",
"data/tmp/descriptions"),
editConfigurationFilePut("etc/org.fcrepo.camel.service.activemq.cfg", "jms.brokerUrl", brokerUrl)
editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort)
};
}
......@@ -112,7 +101,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-mint-service")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-xml-metadata")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-jsonld-service")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-jsonld-cache")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-jsonld-osgi")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-template-mustache")));
}
}
Repository JSON-LD compaction service
=====================================
This collection of camel routes exposes an HTTP endpoint for
generating compact JSON-LD serializations of Fedora resources.
It also automatically replicates these compact resources in
an external key-value system (this example uses Riak).
Building
--------
To build this project use
mvn install
Deploying in OSGi
-----------------
This projects can be deployed in an OSGi container. For example using
[Apache Karaf](http://karaf.apache.org) version 4.x or better, you can run the following
command from its shell:
feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
feature:install acrepo-jsonld-cache
Or by copying any of the compiled bundles into `$KARAF_HOME/deploy`.
Configuration
-------------
The application can be configured by creating the following configuration
file `$KARAF_HOME/etc/edu.amherst.acdc.jsonld.cache.cfg`. The following values
are available for configuration:
In the event of failure, the maximum number of times a redelivery will be attempted.
error.maxRedeliveries=10
The JMS broker URL
jms.brokerUrl=tcp://localhost:61616
The message broker event stream
activemq:topic:fedora
The base url of the fedora repository
fcrepo.baseUrl=localhost:8080/fcrepo/rest
The location of the JSON-LD context document
jsonld.context=https://acdc.amherst.edu/jsonld/context.json
The port on which the service is made availalbe
rest.port=13431
The riak hostname
riak.host=localhost:8098
The riak path prefix
riak.prefix=/buckets/fcrepo/keys
By editing this file, any currently running routes will be immediately redeployed
with the new values.
For more help see the [Apache Camel](http://camel.apache.org) documentation
<?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>
<artifactId>repository-services</artifactId>
<groupId>edu.amherst.acdc</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<artifactId>acrepo-jsonld-cache</artifactId>
<packaging>bundle</packaging>
<name>JSON-LD AppCache Workflow</name>
<properties>
<osgi.export.packages>edu.amherst.acdc.jsonld.cache;version=${project.version}</osgi.export.packages>
</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-jetty9</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-jsonld-service</artifactId>
<version>${project.version}</version>
</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>
</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>
<!-- 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.jsonld.cache.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>
</plugins>
</build>
</project>
/*
* Copyright 2016 Amherst College
*
* 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.jsonld.cache;
import java.io.IOException;
import java.net.URLEncoder;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
import org.fcrepo.camel.FcrepoHeaders;
/**
* @author Aaron Coburn
*/
public class RiakKeyBuilder implements Processor {
/**
* Define how the message should be processed.
*
* @param exchange the current camel message exchange
*/
public void process(final Exchange exchange) throws IOException {
final Message in = exchange.getIn();
final CamelContext ctx = exchange.getContext();
final StringBuilder key = new StringBuilder("/buckets/");
try {
final String prefix = ctx.resolvePropertyPlaceholders("{{riak.bucket}}");
key.append(prefix);
} catch (final Exception ex) {
throw new RuntimeCamelException("Could not resolve properties", ex);
}
key.append("/keys/");
key.append(URLEncoder.encode(
in.getHeader(FcrepoHeaders.FCREPO_IDENTIFIER, String.class), "UTF-8"));
in.removeHeader(Exchange.HTTP_URL);
in.setHeader(Exchange.HTTP_PATH, key.toString());
}
}
Repository JSON-LD handling service
===================================
This service transforms JSON-LD documents, either expanding or compacting them.
The service can be used with any camel route in an OSGi container.
Building
--------
To build this project use
mvn install
Deploying in OSGi
-----------------
Each of these projects can be deployed in an OSGi container. For example using
[Apache Karaf](http://karaf.apache.org) version 4.x or better, you can run the following
command from its shell:
feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
feature:install acrepo-jsonld-service
Or by copying any of the compiled bundles into `$KARAF_HOME/deploy`.
<?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>repository-services</artifactId>
<groupId>edu.amherst.acdc</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<artifactId>acrepo-jsonld-osgi</artifactId>
<packaging>bundle</packaging>
<name>JSON-LD expansion and compaction service bundle</name>
<description>Repository JSON-LD transformation service.</description>
<properties>
<osgi.export.packages>edu.amherst.acdc.jsonld;version=${project.version}</osgi.export.packages>
</properties>
<dependencies>
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</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>
<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>
Repository JSON-LD handling service
===================================
Repository JSON-LD compaction service
=====================================
This service transforms JSON-LD documents, either expanding or compacting them.
The service can be used with any camel route in an OSGi container.
This collection of camel routes exposes an HTTP endpoint for
generating compact JSON-LD serializations of Fedora resources.
It also automatically replicates these compact resources in
an external key-value system (this example uses Riak).
Building
--------
......@@ -14,12 +16,58 @@ To build this project use
Deploying in OSGi
-----------------
Each of these projects can be deployed in an OSGi container. For example using
This projects can be deployed in an OSGi container. For example using
[Apache Karaf](http://karaf.apache.org) version 4.x or better, you can run the following
command from its shell:
feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
feature:install acrepo-jsonld-service
feature:install acrepo-jsonld-cache
Or by copying any of the compiled bundles into `$KARAF_HOME/deploy`.
Configuration
-------------
The application can be configured by creating the following configuration
file `$KARAF_HOME/etc/edu.amherst.acdc.jsonld.cache.cfg`. The following values
are available for configuration:
In the event of failure, the maximum number of times a redelivery will be attempted.
error.maxRedeliveries=10
The JMS broker URL
jms.brokerUrl=tcp://localhost:61616
The message broker event stream
activemq:topic:fedora
The base url of the fedora repository
fcrepo.baseUrl=localhost:8080/fcrepo/rest
The location of the JSON-LD context document
jsonld.context=https://acdc.amherst.edu/jsonld/context.json
The port on which the service is made availalbe
rest.port=13431
The riak hostname
riak.host=localhost:8098
The riak path prefix
riak.prefix=/buckets/fcrepo/keys
By editing this file, any currently running routes will be immediately redeployed
with the new values.
For more help see the [Apache Camel](http://camel.apache.org) documentation
<?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.
-->
<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>
......@@ -29,49 +12,61 @@
<artifactId>acrepo-jsonld-service</artifactId>
<packaging>bundle</packaging>
<name>JSON-LD expansion and compaction service bundle</name>
<description>Repository JSON-LD transformation service.</description>
<name>JSON-LD AppCache Workflow</name>
<properties>
<osgi.export.packages>edu.amherst.acdc.jsonld;version=${project.version}</osgi.export.packages>
<osgi.export.packages>edu.amherst.acdc.jsonld.service;version=${project.version}</osgi.export.packages>
</properties>
<dependencies>
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<!-- logging and testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty9</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-jsonld-osgi</artifactId>
<version>${project.version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- Testing & Camel Plugin -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-blueprint</artifactId>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>