@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");
    }
@ 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 ) ; onException ( Exception . class ) . maximumRedeliveries ( "{{error.maxRedeliveries}}" ) . log ( "Index Routing Error: ${routeId}" ) ; 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" ) ; from ( "{{triplestore.reindex.stream}}" ) . routeId ( "FcrepoTriplestoreReindex" ) . to ( "direct:index.triplestore" ) ; 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" ) ; from ( "direct:delete.triplestore" ) . routeId ( "FcrepoTriplestoreDeleter" ) . process ( new SparqlDeleteProcessor ( ) ) . log ( LoggingLevel . INFO , LOGGER , "Deleting Triplestore Object ${headers[CamelFcrepoUri]}" ) . to ( "{{triplestore.baseUrl}}?useSystemProperties=true" ) ; 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" ) ; }
Configure the message route workflow.