org.apache.camel.builder.xml.XPathBuilder Java Examples
The following examples show how to use
org.apache.camel.builder.xml.XPathBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientCamelSplitterParallelITest.java From hawkular-apm with Apache License 2.0 | 6 votes |
@Override public RouteBuilder getRouteBuilder() { XPathBuilder xPathBuilder = new XPathBuilder("/order/item"); return new RouteBuilder() { @Override public void configure() throws Exception { from("file:src/test/data/camel/splitter?noop=true") .split(xPathBuilder) .parallelProcessing() .setHeader("LineItemId") .xpath("/item/@id", String.class) .to("file:target/data/camel/splitter?fileName=" + "${in.header.LineItemId}-${date:now:yyyyMMddHHmmssSSSSS}.xml"); } }; }
Example #2
Source File: Expression.java From mdw with Apache License 2.0 | 5 votes |
private String evaluateXPath(String expression, Message message) { XPathBuilder xpath = XPathBuilder.xpath(expression); if (namespaces != null) xpath.setNamespaces(namespaces); return xpath.evaluate(camelContext, message.getBody(), String.class); }
Example #3
Source File: TriplestoreRouter.java From fcrepo-camel-toolbox with Apache License 2.0 | 4 votes |
/** * Configure the message route workflow. */ @Override public void configure() throws Exception { final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); ns.add("indexing", "http://fedora.info/definitions/v4/indexing#"); final XPathBuilder indexable = new XPathBuilder( String.format("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='%s']", "http://fedora.info/definitions/v4/indexing#Indexable")); indexable.namespaces(ns); /** * A generic error handler (specific to this RouteBuilder) */ onException(Exception.class) .maximumRedeliveries("{{error.maxRedeliveries}}") .log("Index Routing Error: ${routeId}"); /** * route a message to the proper queue, based on whether * it is a DELETE or UPDATE operation. */ from("{{input.stream}}") .routeId("FcrepoTriplestoreRouter") .process(new EventProcessor()) .choice() .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION), header(FCREPO_EVENT_TYPE).contains(DELETE))) .to("direct:delete.triplestore") .otherwise() .to("direct:index.triplestore"); /** * Handle re-index events */ from("{{triplestore.reindex.stream}}") .routeId("FcrepoTriplestoreReindex") .to("direct:index.triplestore"); /** * Based on an item's metadata, determine if it is indexable. */ from("direct:index.triplestore") .routeId("FcrepoTriplestoreIndexer") .filter(not(in(tokenizePropertyPlaceholder(getContext(), "{{filter.containers}}", ",").stream() .map(uri -> or( header(FCREPO_URI).startsWith(constant(uri + "/")), header(FCREPO_URI).isEqualTo(constant(uri)))) .collect(toList())))) .removeHeaders("CamelHttp*") .choice() .when(simple("{{indexing.predicate}} != 'true'")) .to("direct:update.triplestore") .otherwise() .to("fcrepo:{{fcrepo.baseUrl}}?preferInclude=PreferMinimalContainer&accept=application/rdf+xml") .choice() .when(indexable) .to("direct:update.triplestore") .otherwise() .to("direct:delete.triplestore"); /** * Remove an item from the triplestore index. */ from("direct:delete.triplestore") .routeId("FcrepoTriplestoreDeleter") .process(new SparqlDeleteProcessor()) .log(LoggingLevel.INFO, LOGGER, "Deleting Triplestore Object ${headers[CamelFcrepoUri]}") .to("{{triplestore.baseUrl}}?useSystemProperties=true"); /** * Perform the sparql update. */ from("direct:update.triplestore") .routeId("FcrepoTriplestoreUpdater") .setHeader(FCREPO_NAMED_GRAPH) .simple("{{triplestore.namedGraph}}") .to("fcrepo:{{fcrepo.baseUrl}}?accept=application/n-triples" + "&preferOmit={{prefer.omit}}&preferInclude={{prefer.include}}") .process(new SparqlUpdateProcessor()) .log(LoggingLevel.INFO, LOGGER, "Indexing Triplestore Object ${headers[CamelFcrepoUri]}") .to("{{triplestore.baseUrl}}?useSystemProperties=true"); }
Example #4
Source File: AuditSparqlIT.java From fcrepo-camel-toolbox with Apache License 2.0 | 4 votes |
@Override protected RouteBuilder createRouteBuilder() throws Exception { final Namespaces ns = new Namespaces("sparql", "http://www.w3.org/2005/sparql-results#"); final XPathBuilder xpath = new XPathBuilder( "//sparql:result/sparql:binding[@name='o']"); xpath.namespaces(ns); final XPathBuilder uriResult = new XPathBuilder( "/sparql:binding/sparql:uri"); uriResult.namespaces(ns); final XPathBuilder literalResult = new XPathBuilder( "/sparql:binding/sparql:literal"); literalResult.namespaces(ns); return new RouteBuilder() { public void configure() throws IOException { final String fuseki_url = "http4://localhost:" + Integer.toString(FUSEKI_PORT); from("direct:start") .setHeader(AuditHeaders.EVENT_BASE_URI, constant(EVENT_BASE_URI)) .process(new AuditSparqlProcessor()) .to(fuseki_url + "/fuseki/test/update") .to("mock:sparql.update"); from("direct:query") .to(fuseki_url + "/fuseki/test/query") .split(xpath) .choice() .when().xpath("/sparql:binding/sparql:uri", String.class, ns) .transform().xpath("/sparql:binding/sparql:uri/text()", String.class, ns) .to("mock:sparql.query") .when().xpath("/sparql:binding/sparql:literal", String.class, ns) .transform().xpath("/sparql:binding/sparql:literal/text()", String.class, ns) .to("mock:sparql.query"); from("direct:clear") .transform().constant("update=DELETE WHERE { ?s ?o ?p }") .setHeader(Exchange.CONTENT_TYPE).constant("application/x-www-form-urlencoded") .setHeader(Exchange.HTTP_METHOD).constant("POST") .to(fuseki_url + "/fuseki/test/update") .to("mock:sparql.update"); } }; }