Commit a33e0a28 authored by acoburn's avatar acoburn
Browse files

working more or less

parent 8267e5bd
......@@ -27,42 +27,13 @@
</parent>
<artifactId>acrepo-idiomatic-pgsql</artifactId>
<packaging>bundle</packaging>
<packaging>pom</packaging>
<name>Postgresql Dataservice Bundle</name>
<description>OSGi dataservice connector for Postgres.</description>
<properties>
<osgi.export.packages>edu.amherst.acdc.pgsql*;version=${project.version}</osgi.export.packages>
</properties>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
<name>PostgreSQL DataService Connector</name>
<description>OSGi dataservice connector for PostgreSQL.</description>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
......@@ -75,7 +46,7 @@
<configuration>
<artifacts>
<artifact>
<file>src/main/cfg/edu.amherst.acdc.pgsql.cfg</file>
<file>src/main/cfg/edu.amherst.acdc.idiomatic.pgsql.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
......@@ -84,7 +55,6 @@
</execution>
</executions>
</plugin>
</plugins>
</build>
......
osgi.jdbc.driver.name=PostgreSQL JDBC Driver
osgi.jdbc.driver.class=org.postgresql.Driver
dataSourceName=idiomaticds
databaseName=idiomatic
serverName=localhost
portNumber=5432
user=
password=
pgsql.host=localhost
pgsql.port=5432
pgsql.database=idmapper
pgsql.username=
pgsql.password=
pgsql.ssl=false
pgsql.sslfactory=org.postgresql.ssl.NonValidatingFactory
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"
default-activation="lazy">
<cm:property-placeholder persistent-id="edu.amherst.acdc.idmapper.pgsql" update-strategy="reload" >
<cm:default-properties>
<cm:property name="pgsql.host" value="localhost"/>
<cm:property name="pgsql.port" value="5432"/>
<cm:property name="pgsql.database" value="idmapper"/>
<cm:property name="pgsql.username" value=""/>
<cm:property name="pgsql.password" value=""/>
<cm:property name="pgsql.ssl" value="false"/>
<cm:property name="pgsql.sslfactory" value="org.postgresql.ssl.NonValidatingFactory"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="dataService" class="org.postgresql.ds.PGPoolingDataSource" destroy-method="close">
<property name="serverName" value="${pgsql.host}"/>
<property name="portNumber" value="${pgsql.port}"/>
<property name="databaseName" value="${pgsql.database}"/>
<property name="user" value="${pgsql.username}"/>
<property name="password" value="${pgsql.password}"/>
<property name="initialConnections" value="2"/>
<property name="maxConnections" value="4"/>
<property name="ssl" value="${pgsql.ssl}"/>
<property name="sslfactory" value="${pgsql.sslfactory}"/>
</bean>
<service interface="javax.sql.DataSource" ref="dataService">
<service-properties>
<entry key="osgi.jndi.service.name" value="idmapperds"/>
</service-properties>
</service>
</blueprint>
......@@ -26,13 +26,15 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>acrepo-ideomatic</artifactId>
<artifactId>acrepo-idiomatic</artifactId>
<packaging>bundle</packaging>
<name>ID mapping service</name>
<description>Camel-based service for mapping public IDs to Fedora IDs</description>
<properties>
<osgi.export.packages>edu.amherst.acdc.idiomatic;version=${project.version}</osgi.export.packages>
<osgi.import.packages>javax.sql,*</osgi.import.packages>
</properties>
<dependencies>
......@@ -40,6 +42,11 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-jdbc</artifactId>-->
<!--<version>${spring.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
......@@ -47,7 +54,6 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
......@@ -58,21 +64,18 @@
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-kernel-api</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.4.1</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
......@@ -88,12 +91,6 @@
</dependency>
<!-- testing -->
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-idiomatic-pgsql</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-mint-service</artifactId>
......@@ -140,7 +137,7 @@
<configuration>
<artifacts>
<artifact>
<file>src/main/cfg/edu.amherst.acdc.idmapper.cfg</file>
<file>src/main/cfg/edu.amherst.acdc.idiomatic.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
......@@ -160,10 +157,6 @@
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
......@@ -74,6 +74,15 @@ public class EventRouter extends RouteBuilder {
.process(new IdProcessor())
.to("direct:update");
/**
* REST routing
*/
rest("{{rest.prefix}}")
.get("/{id}").to("direct:get")
.post("/").to("direct:minter")
.put("/{id}").to("direct:update")
.delete("/{id}").to("direct:delete");
/**
* Handle CRUD operations
*/
......
......@@ -8,27 +8,25 @@
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.idmapper" update-strategy="reload">
<cm:property-placeholder persistent-id="edu.amherst.acdc.idiomatic" 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="rest.prefix" value="idmapper"/>
<cm:property name="rest.prefix" value="idiomatic"/>
<cm:property name="rest.port" value="9080"/>
<cm:property name="id.property" value="dc:identifier"/>
<cm:property name="id.namespace" value="http://purl.org/dc/elements/1.1/"/>
</cm:default-properties>
</cm:property-placeholder>
<reference id="dataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=idmapperds)"/>
<reference id="databaseSource" interface="javax.sql.DataSource" availability="optional" filter="(osgi.jndi.service.name=idiomaticds)"/>
<reference id="minterService"
interface="org.fcrepo.kernel.api.services.functions.UniqueValueSupplier"
filter="(osgi.jndi.service.name=minter)"/>
<reference id="minterService" interface="org.fcrepo.kernel.api.services.functions.UniqueValueSupplier" />
<!-- component-wide configuration of jdbc -->
<bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="dataSource"/>
<property name="dataSource" ref="databaseSource"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
......@@ -39,23 +37,7 @@
<package>edu.amherst.acdc.idiomatic</package>
<restConfiguration bindingMode="auto" component="restlet"
contextPath="{{rest.prefix}}" port="{{rest.port}}"/>
<rest>
<post uri="/">
<to uri="direct:minter"/>
</post>
<get uri="/{id}">
<to uri="direct:get"/>
</get>
<put uri="/{id}">
<to uri="direct:update"/>
</put>
<delete uri="/{id}">
<to uri="direct:delete"/>
</delete>
</rest>
<restConfiguration bindingMode="auto" component="restlet" port="{{rest.port}}"/>
<route id="MinterRoute">
<description>Create a freshly minted ID</description>
......
......@@ -7,13 +7,13 @@
</encoder>
</appender>
<logger name="org.fcrepo.camel.audit" additivity="false" level="${fcrepo.log.camel.audit:-INFO}">
<logger name="edu.amherst.acdc.idiomatic" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.fcrepo.camel" additivity="false" level="${fcrepo.log.camel:-INFO}">
<logger name="org.apache.camel" additivity="false" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.fcrepo" additivity="false" level="${fcrepo.log:-INFO}">
<logger name="org.fcrepo.camel" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<root additivity="false" level="WARN">
......
......@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import edu.amherst.acdc.mint.MinterService;
import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
......@@ -31,9 +32,6 @@ import org.apache.camel.util.KeyValueHolder;
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.io.IOUtils;
import org.fcrepo.camel.JmsHeaders;
import org.postgresql.ds.PGPoolingDataSource;
import edu.amherst.acdc.mint.MinterService;
import org.junit.Test;
/**
......@@ -44,6 +42,8 @@ import org.junit.Test;
*/
public class RouteTest extends CamelBlueprintTestSupport {
private final int MINT_LENGTH = 7;
@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;
......@@ -74,8 +74,7 @@ public class RouteTest extends CamelBlueprintTestSupport {
@Override
protected void addServicesOnStartup(final Map<String, KeyValueHolder<Object, Dictionary>> services) {
services.put("dataSource", asService(new PGPoolingDataSource(), "name", "idmapperds"));
services.put("minterService", asService(new MinterService(7), "name", "minter"));
services.put("minterService", asService(new MinterService(MINT_LENGTH), "name", "minter"));
}
@Test
......@@ -100,10 +99,10 @@ public class RouteTest extends CamelBlueprintTestSupport {
template.sendBody("direct:minter", null);
template.sendBody("direct:minter", null);
final String id1 = getMockEndpoint("mock:result").getExchanges().get(0).getIn().getBody(String.class);
final String id2 = getMockEndpoint("mock:result").getExchanges().get(1).getIn().getBody(String.class);
assertEquals(7, id1.length());
assertEquals(7, id2.length());
final String id1 = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class);
final String id2 = resultEndpoint.getExchanges().get(1).getIn().getBody(String.class);
assertEquals(MINT_LENGTH, id1.length());
assertEquals(MINT_LENGTH, id2.length());
assertFalse(id1.equals(id2));
assertMockEndpointsSatisfied();
......@@ -137,7 +136,7 @@ public class RouteTest extends CamelBlueprintTestSupport {
context.start();
getMockEndpoint("mock:result").expectedMessageCount(2);
resultEndpoint.expectedMessageCount(2);
final Map<String, Object> headers = new HashMap<>();
headers.put(JmsHeaders.IDENTIFIER, "/foo/bar");
template.sendBodyAndHeaders(
......
......@@ -3,39 +3,69 @@
<repository>mvn:org.fcrepo.camel/fcrepo-camel/${fcrepo-camel.version}/xml/features</repository>
<repository>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</repository>
<repository>mvn:org.apache.activemq/activemq-karaf/${activemq.version}/xml/features</repository>
<repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/${pax-jdbc.version}/xml/features</repository>
<repository>mvn:org.fcrepo/fcrepo-karaf/${fcrepo.version}/xml/features</repository>
<feature name="acrepo-idiomatic" version="${project.version}" resolver="(obr)" start-level="50">
<details>Installs the id mapping service</details>
<feature>jndi</feature>
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${camel.version}">camel-jetty</feature>
<feature version="${camel.version}">camel-jdbc</feature>
<feature version="${camel.version}">camel-restlet</feature>
<feature version="${camel.version}">camel-jackson</feature>
<feature version="${camel.version}">camel-sql</feature>
<feature version="${activemq.version}">activemq-camel</feature>
<feature version="${fcrepo-camel.version}">fcrepo-camel</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-idiomatic/{project.version}</bundle>
<feature version="${fcrepo.version}">fcrepo-kernel-api</feature>
<bundle dependency="true">mvn:org.codehaus.woodstox/woodstox-core-asl/${woodstox.version}</bundle>
<bundle>mvn:edu.amherst.acdc/acrepo-idiomatic/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.idiomatic.cfg">mvn:edu.amherst.acdc/acrepo-idiomatic/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="other-pgsql" version="${project.version}" resolver="(obr)" start-level="50">
<details>Installs the id mapping service database</details>
<feature>jdbc</feature>
<feature>jndi</feature>
<feature>transaction</feature>
<bundle>mvn:org.postgresql/postgresql/${postgresql.version}</bundle>
<bundle>mvn:edu.amherst.acdc/other-pgsql/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.other.pgsql.cfg">mvn:edu.amherst.acdc/other-pgsql/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-idiomatic-pgsql" version="${project.version}" resolver="(obr)" start-level="50">
<details>Installs the id mapping service database</details>
<feature>jdbc</feature>
<feature>transaction</feature>
<feature>jndi</feature>
<feature>transaction</feature>
<feature>pax-jdbc-config</feature>
<feature>pax-jdbc-postgresql</feature>
<bundle dependency="true">wrap:mvn:postgresql/postgresql/${postgresql.version}</bundle>
<!--<bundle dependency="true">mvn:org.osgi/org.osgi.compendium/5.0.0</bundle>-->
<bundle>mvn:edu.amherst.acdc/acrepo-idiomatic-pgsql/{project.version}</bundle>
<bundle>mvn:org.postgresql/postgresql/${postgresql.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.idiomatic.pgsql.cfg">mvn:edu.amherst.acdc/acrepo-idiomatic-pgsql/${project.version}/cfg/configuration</configfile>
<configfile finalname="/etc/org.ops4j.datasource-idiomatic.cfg">mvn:edu.amherst.acdc/acrepo-idiomatic-pgsql/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-mint-service" version="${project.version}" resolver="(obr)" start-level="50">
<details>Installs the id minter</details>
<feature version="${fcrepo.version}">fcrepo-kernel-api</feature>
<bundle dependency="true">mvn:org.apache.commons/commons-lang3/${commons-lang.version}</bundle>
<bundle>mvn:edu.amherst.acdc/acrepo-mint-service/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.mint.cfg">mvn:edu.amherst.acdc/acrepo-mint-service/${project.version}/cfg/configuration</configfile>
......
......@@ -37,14 +37,6 @@
</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.fcrepo</groupId>
<artifactId>fcrepo-kernel-api</artifactId>
......
......@@ -18,7 +18,6 @@ package edu.amherst.acdc.mint;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
import org.apache.camel.Handler;
import org.fcrepo.kernel.api.services.functions.UniqueValueSupplier;
/**
......@@ -43,7 +42,6 @@ public class MinterService implements UniqueValueSupplier {
*
* @return the new ID
*/
@Handler
public String get() {
return randomAlphanumeric(length).toLowerCase();
}
......
......@@ -26,9 +26,13 @@
<fcrepo.version>4.3.1-SNAPSHOT</fcrepo.version>
<jsonld.version>0.6.0</jsonld.version>
<logback.version>1.1.2</logback.version>
<postgresql.version>9.1-901.jdbc4</postgresql.version>
<postgresql.version>9.4-1201-jdbc41</postgresql.version>
<slf4j.version>1.7.7</slf4j.version>
<junit.version>4.11</junit.version>
<woodstox.version>4.4.1</woodstox.version>
<pax-jdbc.version>0.7.0</pax-jdbc.version>
<spring.version>4.1.7.RELEASE</spring.version>
<osgi.import.packages>*</osgi.import.packages>
</properties>
<modules>
......@@ -50,6 +54,11 @@
<artifactId>camel-blueprint</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
......@@ -91,7 +100,12 @@
</exclusions>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>${woodstox.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</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