Commit 38311560 authored by acoburn's avatar acoburn
Browse files

shorten setHeader lines

parent 9718cd5a
......@@ -15,9 +15,10 @@
*/
package edu.amherst.acdc.idiomatic;
import static org.apache.camel.builder.PredicateBuilder.not;
import static edu.amherst.acdc.idiomatic.IdiomaticHeaders.FEDORA;
import static edu.amherst.acdc.idiomatic.IdiomaticHeaders.ID;
import static org.apache.camel.builder.PredicateBuilder.not;
import static org.fcrepo.camel.JmsHeaders.IDENTIFIER;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
......@@ -80,7 +81,7 @@ public class EventRouter extends RouteBuilder {
public void process(final Exchange ex) throws Exception {
ex.getIn().setHeader(ID, ex.getIn().getHeader(ID, String.class).replaceAll("^" + idPrefix, ""));
}})
.transform().simple("${header[org.fcrepo.jms.identifier]}")
.transform().header(IDENTIFIER)
.to("direct:update");
/**
......@@ -97,7 +98,7 @@ public class EventRouter extends RouteBuilder {
*/
from("direct:update")
.routeId("IdMappingUpdateRouter")
.setHeader(FEDORA).simple("${body}")
.setHeader(FEDORA).body()
.setHeader(Exchange.HTTP_RESPONSE_CODE).constant(400)
.filter(header(FEDORA))
.log(LoggingLevel.INFO, "Updating ${headers[" + ID + "]} with ${headers[" + FEDORA + "]}")
......
......@@ -47,7 +47,7 @@ public class EventRouter extends RouteBuilder {
.log("Event Routing Error: ${routeId}");
from("{{input.stream}}")
.setHeader(FCREPO_IDENTIFIER).simple("${headers[" + IDENTIFIER + "]}")
.setHeader(FCREPO_IDENTIFIER).header(IDENTIFIER)
.choice()
.when(header(EVENT_TYPE).isEqualTo(REPOSITORY + "NODE_REMOVED"))
.to("direct:delete")
......@@ -57,7 +57,7 @@ public class EventRouter extends RouteBuilder {
from("jetty:http://0.0.0.0:{{rest.port}}/jsonld?" +
"matchOnUriPrefix=true&sendServerVersion=false&httpMethodRestrict=GET,PUT,DELETE")
.routeId("JsonLdRouter")
.setHeader(FCREPO_IDENTIFIER).simple("${headers[" + HTTP_PATH + "]}")
.setHeader(FCREPO_IDENTIFIER).header(HTTP_PATH)
.choice()
.when(header(HTTP_METHOD).isEqualTo("GET")).to("direct:get")
.when(header(HTTP_METHOD).isEqualTo("PUT")).to("direct:update")
......
......@@ -16,6 +16,7 @@
package edu.amherst.acdc.template.mustache;
import static org.apache.camel.Exchange.CONTENT_TYPE;
import static org.apache.camel.Exchange.HTTP_PATH;
import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
import static org.apache.camel.Exchange.HTTP_URI;
import static org.apache.camel.Exchange.HTTP_URL;
......@@ -48,7 +49,7 @@ public class EventRouter extends RouteBuilder {
"matchOnUriPrefix=true&httpMethodRestrict=GET&sendServerVersion=false")
.routeId("TemplateTransformation")
.log("PATH: ${headers[CamelHttpPath]}")
.setHeader(FCREPO_IDENTIFIER).simple("${headers[CamelHttpPath]}")
.setHeader(FCREPO_IDENTIFIER).header(HTTP_PATH)
.removeHeader("breadcrumbId")
.removeHeader("Accept")
.removeHeader("User-Agent")
......
......@@ -15,6 +15,7 @@
*/
package edu.amherst.acdc.xml.metadata;
import static org.apache.camel.Exchange.HTTP_PATH;
import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
import static org.apache.camel.Exchange.CONTENT_TYPE;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_IDENTIFIER;
......@@ -65,7 +66,7 @@ public class EventRouter extends RouteBuilder {
.removeHeader("breadcrumbId")
.removeHeader("Accept")
.removeHeader("User-Agent")
.setHeader(FCREPO_IDENTIFIER).simple("${headers[CamelHttpPath]}")
.setHeader(FCREPO_IDENTIFIER).header(HTTP_PATH)
.setHeader(FCREPO_BASE_URL).simple("{{fcrepo.baseUrl}}")
.to("fcrepo:{{fcrepo.baseUrl}}?throwExceptionOnFailure=false");
......
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