Commit 95e8d204 authored by acoburn's avatar acoburn
Browse files

clean up response headers; switch to xslt 2.0

parent abc21b7f
......@@ -60,6 +60,7 @@
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${camel.version}">camel-jetty9</feature>
<feature version="${camel.version}">camel-saxon</feature>
<feature version="${fcrepo-camel.version}">fcrepo-camel</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-mods-xml-service/${project.version}</bundle>
......
......@@ -31,6 +31,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-saxon</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo.camel</groupId>
<artifactId>fcrepo-camel</artifactId>
......
......@@ -21,16 +21,25 @@
<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"/>
<from uri="jetty:http://0.0.0.0:{{rest.port}}{{rest.prefix}}?matchOnUriPrefix=true&amp;httpMethodRestrict=GET&amp;sendServerVersion=false"/>
<removeHeaders pattern="breadcrumbId"/>
<setHeader headerName="CamelFcrepoIdentifier">
<simple>${headers[CamelHttpPath]}</simple>
</setHeader>
<setHeader headerName="CamelFcrepoBaseUrl">
<simple>{{fcrepo.baseUrl}}</simple>
</setHeader>
<log message="Converting: ${headers[CamelFcrepoIdentifier]}"/>
<to uri="fcrepo:{{fcrepo.baseUrl}}?accept=application/rdf+xml"/>
<convertBodyTo type="org.w3c.dom.Document"/>
<to uri="fcrepo:{{fcrepo.baseUrl}}?accept=application/rdf+xml&amp;throwExceptionOnFailure=false"/>
<removeHeaders pattern="Accept"/>
<removeHeaders pattern="User-Agent"/>
<filter>
<simple>${headers[CamelHttpResponseCode]} == 200</simple>
<to uri="xslt:{{mods.xslt}}"/>
<setHeader headerName="Content-Type">
<constant>application/xml</constant>
</setHeader>
<convertBodyTo type="org.w3c.dom.Document"/>
<to uri="xslt:{{mods.xslt}}?saxon=true"/>
</filter>
</route>
</camelContext>
......
......@@ -7,35 +7,40 @@
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">
version="2.0">
<xsl:output indent="yes" method="xml"></xsl:output>
<xsl:param name="CamelFcrepoIdentifier"/>
<xsl:param name="CamelFcrepoBaseUrl"/>
<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:if test="ends-with(@rdf:about, concat($CamelFcrepoBaseUrl, $CamelFcrepoIdentifier))">
<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="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="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="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: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:if>
</xsl:template>
</xsl:stylesheet>
......@@ -28,6 +28,7 @@
<jsonld.version>0.6.0</jsonld.version>
<logback.version>1.1.2</logback.version>
<postgresql.version>9.4-1201-jdbc41</postgresql.version>
<saxon.version>9.6.0-7</saxon.version>
<slf4j.version>1.7.7</slf4j.version>
<junit.version>4.11</junit.version>
<woodstox.version>4.4.1</woodstox.version>
......@@ -61,6 +62,11 @@
<artifactId>camel-jetty9</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-saxon</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
......@@ -122,6 +128,7 @@
<version>${derby.version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
......
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