From cd85cb0e1a23d1149bdbb6abe2ba2dfd254e55c5 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 13 Feb 2024 11:57:49 +0000 Subject: [PATCH 01/10] Initial commit of solr basic auth functionality --- README.md | 2 ++ .../solr/FcrepoSolrIndexingConfig.java | 13 ++++++++++ .../camel/indexing/solr/SolrRouter.java | 25 ++++++++++++++----- .../fcrepo/camel/indexing/solr/RouteTest.java | 2 ++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f55d1a00..4ccde0ac 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ indexes objects into an external Solr server. | solr.indexing.predicate | When true, check that resource is of type http://fedora.info/definitions/v4/indexing#Indexable; otherwise do not index it. | false | | solr.ldpath.service.baseUrl | The LDPath service base url | http://localhost:9085/ldpath | | solr.filter.containers | A comma-separate list of containers that should be ignored by the indexer | http://localhost:8080/fcrepo/rest/audit | +| solr.username | Optional username for a Solr server protected with Basic Auth. Must be used in combination with solr.password | | +| solr.password | Optional password for a Solr server protected with Basic Auth. Must be used in combination with solr.username | | ### Repository Indexer (Triplestore) diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java index dbcfd665..15ee7b24 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java @@ -61,6 +61,12 @@ static class SolrIndexingEnabled extends ConditionOnPropertyTrue { @Value("${solr.baseUrl:http://localhost:8983/solr/collection1}") private String solrBaseUrl; + @Value("${solr.username:}") + private String solrUsername; + + @Value("${solr.password:}") + private String solrPassword; + public boolean isCheckHasIndexingTransformation() { return checkHasIndexingTransformation; } @@ -97,6 +103,13 @@ public String getSolrBaseUrl() { return solrBaseUrl; } + public String getSolrUsername() { + return solrUsername; + } + + public String getSolrPassword() { + return solrPassword; + } @Bean(name = "http") public HttpComponent http() { diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 096acdf0..296a947c 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -8,10 +8,13 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.support.builder.Namespaces; +import org.apache.camel.builder.PredicateBuilder; +import org.apache.camel.Predicate; import org.fcrepo.camel.processor.EventProcessor; +import org.fcrepo.camel.common.processor.AddBasicAuthProcessor; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; - +import org.apache.commons.lang3.StringUtils; import static java.util.stream.Collectors.toList; import static org.apache.camel.Exchange.CONTENT_TYPE; import static org.apache.camel.Exchange.HTTP_METHOD; @@ -58,7 +61,10 @@ public void configure() throws Exception { ns.add("indexing", "http://fedora.info/definitions/v4/indexing#"); ns.add("ldp", "http://www.w3.org/ns/ldp#"); - + final String solrUsername = config.getSolrUsername(); + final String solrPassword = config.getSolrPassword(); + final Predicate useSolrAuth = PredicateBuilder.constant( + "true".equals(!StringUtils.isEmpty(solrUsername) && !StringUtils.isEmpty(solrPassword))); /* * A generic error handler (specific to this RouteBuilder) */ @@ -74,8 +80,8 @@ public void configure() throws Exception { .routeId("FcrepoSolrRouter") .process(new EventProcessor()) .choice() - .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION), - header(FCREPO_EVENT_TYPE).contains(DELETE))) + .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION), + header(FCREPO_EVENT_TYPE).contains(DELETE))) .log(LoggingLevel.TRACE, "Received message from Fedora routing to delete.solr") .to("direct:delete.solr") .otherwise() @@ -101,8 +107,8 @@ public void configure() throws Exception { header(FCREPO_URI).isEqualTo(constant(uri)))) .collect(toList())))) .choice() - .when(and(simple(config.isIndexingPredicate() + " != 'true'"), - simple(config.isCheckHasIndexingTransformation() + " != 'true'"))) + .when(and(simple(config.isIndexingPredicate() + " != 'true'"), + simple(config.isCheckHasIndexingTransformation() + " != 'true'"))) .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()) .to("direct:update.solr") .otherwise() @@ -172,6 +178,7 @@ public void configure() throws Exception { .otherwise() .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}"); + /* * Send the transformed resource to Solr */ @@ -180,6 +187,12 @@ public void configure() throws Exception { .removeHeaders("CamelHttp*") .setHeader(HTTP_METHOD).constant("POST") .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) + .choice() + .when(useSolrAuth) + .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) + .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) + .otherwise() + .log(LoggingLevel.INFO, logger, "No Solr Auth provided") .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); } diff --git a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java index 642250ca..5cec9434 100644 --- a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java +++ b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java @@ -81,6 +81,8 @@ public static void beforeClass() { System.setProperty("solr.baseUrl", solrURL); System.setProperty("solr.reindex.stream", "seda:reindex"); System.setProperty("solr.fcrepo.checkHasIndexingTransformation", "true"); + System.setProperty("solr.username", "solr"); + System.setProperty("solr.password", "solrRocks"); } From 77d1bc81f081e3cd8718a17f173c6df6900acdc9 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 15 Feb 2024 13:00:46 +0000 Subject: [PATCH 02/10] reducing log level of solr indexer when using auth --- .../main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 296a947c..19d7eb59 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -192,7 +192,7 @@ public void configure() throws Exception { .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) .otherwise() - .log(LoggingLevel.INFO, logger, "No Solr Auth provided") + .log(LoggingLevel.DEBUG, logger, "No Solr Auth provided") .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); } From e71b893920b8a75e2f71c94a472f1a07fd8ad6ff Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 15 Feb 2024 16:00:44 +0000 Subject: [PATCH 03/10] FCREPO-3834 Enable Camel toolbox to send xml records to Solr indexing service (#191) * replacing ldpath service with XSLT processing solr indexer * no longer need HTTP_URI * added properties for new solr xsl transforms to docker-compose properties file * returning config to original state rather than my dev stack * adding fields to solr xsl --------- Co-authored-by: Dan Field --- README.md | 45 +--- .../configuration.properties | 3 +- fcrepo-camel-toolbox-app/pom.xml | 6 - .../solr/FcrepoSolrIndexingConfig.java | 7 - .../camel/indexing/solr/SolrRouter.java | 38 +-- .../camel/indexing/solr/default_transform.xsl | 22 ++ .../fcrepo/camel/indexing/solr/RouteTest.java | 10 +- .../src/test/resources/indexable.rdf | 2 +- fcrepo-ldpath/my.ldpath | 130 ---------- fcrepo-ldpath/pom.xml | 219 ---------------- .../fcrepo/camel/ldpath/ClientFactory.java | 123 --------- .../camel/ldpath/FcrepoLdPathConfig.java | 113 --------- .../fcrepo/camel/ldpath/FedoraEndpoint.java | 46 ---- .../fcrepo/camel/ldpath/FedoraProvider.java | 115 --------- .../org/fcrepo/camel/ldpath/LDPathRouter.java | 93 ------- .../fcrepo/camel/ldpath/LDPathWrapper.java | 92 ------- .../org/fcrepo/camel/ldpath/default.ldpath | 130 ---------- .../org/fcrepo/camel/ldpath/options.ttl | 11 - .../org/fcrepo/camel/ldpath/RouteTest.java | 200 --------------- .../camel/ldpath/RouteWithFunctionsTest.java | 238 ------------------ .../src/test/resources/container.ttl | 8 - .../src/test/resources/logback-test.xml | 22 -- .../test/resources/test-with-functions.ldpath | 6 - fcrepo-ldpath/src/test/resources/test.ldpath | 5 - pom.xml | 42 +--- 25 files changed, 46 insertions(+), 1680 deletions(-) create mode 100644 fcrepo-indexing-solr/src/main/resources/org/fcrepo/camel/indexing/solr/default_transform.xsl delete mode 100644 fcrepo-ldpath/my.ldpath delete mode 100644 fcrepo-ldpath/pom.xml delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FcrepoLdPathConfig.java delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraEndpoint.java delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraProvider.java delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathRouter.java delete mode 100644 fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java delete mode 100644 fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/default.ldpath delete mode 100644 fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/options.ttl delete mode 100644 fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteTest.java delete mode 100644 fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteWithFunctionsTest.java delete mode 100644 fcrepo-ldpath/src/test/resources/container.ttl delete mode 100644 fcrepo-ldpath/src/test/resources/logback-test.xml delete mode 100644 fcrepo-ldpath/src/test/resources/test-with-functions.ldpath delete mode 100644 fcrepo-ldpath/src/test/resources/test.ldpath diff --git a/README.md b/README.md index f55d1a00..c17330b4 100644 --- a/README.md +++ b/README.md @@ -128,12 +128,11 @@ indexes objects into an external Solr server. | :--- | :---| :---- | | solr.indexing.enabled | Enables/disables the SOLR indexing service. Disabled by default | false | | solr.fcrepo.checkHasIndexingTransformation | When true, check for an indexing transform in the resource matadata. | true | -| solr.fcrepo.defaultTransform | The solr default ldpath transform when none is provide in resource metadata. | null | +| solr.fcrepo.defaultTransform | The solr default XSL transform when none is provide in resource metadata. | null | | solr.input.stream | The JMS topic or queue serving as the message source | broker:topic:fedora | | solr.reindex.stream | The JMS topic or queue serving as the reindex message source | broker:queue:solr.reindex | | solr.commitWithin | Milliseconds within which commits should occur | 10000 | | solr.indexing.predicate | When true, check that resource is of type http://fedora.info/definitions/v4/indexing#Indexable; otherwise do not index it. | false | -| solr.ldpath.service.baseUrl | The LDPath service base url | http://localhost:9085/ldpath | | solr.filter.containers | A comma-separate list of containers that should be ignored by the indexer | http://localhost:8080/fcrepo/rest/audit | @@ -157,48 +156,6 @@ indexes objects into an external triplestore. | triplestore.prefer.include | A list of [valid prefer values](https://fedora.info/2021/05/01/spec/#additional-prefer-values) defining predicates to be included | null | | triplestore.prefer.omit | A list of [valid prefer values](https://fedora.info/2021/05/01/spec/#additional-prefer-values) defining predicates to be omitted. | http://www.w3.org/ns/ldp#PreferContainment | -### LDPath Service - -This application implements an LDPath service on repository -resources. This allows users to dereference and follow URI -links to arbitrary lengths. Retrieved triples are cached locally -for a specified period of time. - -More information about LDPath can be found at the [Marmotta website](http://marmotta.apache.org/ldpath/language.html). - -Note: The LDPath service requires an LDCache backend, such as `fcrepo-service-ldcache-file`. - -#### Usage -The LDPath service responds to `GET` and `POST` requests using any accessible resources as a context. - -For example, a request to -`http://localhost:9086/ldpath/?context=http://localhost/rest/path/to/fedora/object` -will apply the appropriate ldpath program to the specified resource. Note: it is possible to -identify non-Fedora resources in the context parameter. - -A `GET` request can include a `ldpath` parameter, pointing to the URL location of an LDPath program: - - `curl http://localhost:9086/ldpath/?context=http://localhost/rest/path/to/fedora/object&ldpath=http://example.org/ldpath` - -Otherwise, it will use a simple default ldpath program. - -A `POST` request can also be accepted by this endpoint. The body of a `POST` request should contain -the entire `LDPath` program. The `Content-Type` of the request should be either `text/plain` or -`application/ldpath`. - - `curl -XPOST -H"Content-Type: application/ldpath" -d @program.txt http://localhost:9086/ldpath/?context=http://localhost/rest/path/to/fedora/object - -#### Properties -| Name | Description| Default Value | -| :--- | :---| :---- | -| ldpath.fcrepo.cache.timeout | The timeout in seconds for the ldpath cache | 0 | -| ldpath.rest.prefix | The LDPath rest endpoint prefix | no | /ldpath| -| ldpath.rest.port| The LDPath rest endpoint port | no | 9085 | -| ldpath.rest.host| The LDPath rest endpoint host | no | localhost | -| ldpath.cache.timeout | LDCache timeout in seconds | no | 86400 | -| ldpath.ldcache.directory | LDCache directory | no | ldcache/ | -| ldpath.transform.path | The LDPath transform file path | classpath:org/fcrepo/camel/ldpath/default.ldpath | - ### Reindexing Service This application implements a reindexing service so that diff --git a/docker-compose/camel-toolbox-config/configuration.properties b/docker-compose/camel-toolbox-config/configuration.properties index f2ef00ff..d1417131 100644 --- a/docker-compose/camel-toolbox-config/configuration.properties +++ b/docker-compose/camel-toolbox-config/configuration.properties @@ -1,10 +1,11 @@ fcrepo.baseUrl=http://fcrepo:8080/fcrepo/rest -fcrepo.authHost=fcrepo +fcrepo.authHost=localhost jms.brokerUrl=tcp://fcrepo:61616 solr.indexing.enabled=true solr.baseUrl=http://solr:8983/solr/fcrepo +solr.fcrepo.defaultTransform=org/fcrepo/camel/indexing/solr/default_transform.xsl triplestore.indexing.enabled=true triplestore.baseUrl=http://fuseki:3030/fcrepo diff --git a/fcrepo-camel-toolbox-app/pom.xml b/fcrepo-camel-toolbox-app/pom.xml index a398c093..27f1d1ce 100644 --- a/fcrepo-camel-toolbox-app/pom.xml +++ b/fcrepo-camel-toolbox-app/pom.xml @@ -48,12 +48,6 @@ ${project.parent.version} - - ${project.parent.groupId} - fcrepo-ldpath - ${project.parent.version} - - ${project.parent.groupId} fcrepo-fixity diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java index dbcfd665..d2c520d4 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java @@ -52,9 +52,6 @@ static class SolrIndexingEnabled extends ConditionOnPropertyTrue { @Value("${solr.indexing.predicate:false}") private boolean indexingPredicate; - @Value("${solr.ldpath.service.baseUrl:http://localhost:9085/ldpath}") - private String ldpathServiceBaseUrl; - @Value("${solr.filter.containers:http://localhost:8080/fcrepo/rest/audit}") private String filterContainers; @@ -85,10 +82,6 @@ public boolean isIndexingPredicate() { return indexingPredicate; } - public String getLdpathServiceBaseUrl() { - return ldpathServiceBaseUrl; - } - public String getFilterContainers() { return filterContainers; } diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 096acdf0..dd2c0cf0 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -16,7 +16,6 @@ import static org.apache.camel.Exchange.CONTENT_TYPE; import static org.apache.camel.Exchange.HTTP_METHOD; import static org.apache.camel.Exchange.HTTP_QUERY; -import static org.apache.camel.Exchange.HTTP_URI; import static org.apache.camel.builder.PredicateBuilder.and; import static org.apache.camel.builder.PredicateBuilder.in; import static org.apache.camel.builder.PredicateBuilder.not; @@ -104,6 +103,7 @@ public void configure() throws Exception { .when(and(simple(config.isIndexingPredicate() + " != 'true'"), simple(config.isCheckHasIndexingTransformation() + " != 'true'"))) .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()) + .log(LoggingLevel.INFO, "sending to update_solr") .to("direct:update.solr") .otherwise() .to( @@ -136,41 +136,26 @@ public void configure() throws Exception { .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); - from("direct:external.ldpath").routeId("FcrepoSolrLdpathFetch") - .removeHeaders("CamelHttp*") - .setHeader(HTTP_URI).header(INDEXING_TRANSFORMATION) - .setHeader(HTTP_METHOD).constant("GET") - .to("http://localhost/ldpath"); - - from("direct:transform.ldpath").routeId("FcrepoSolrTransform") - .removeHeaders("CamelHttp*") - .setHeader(HTTP_URI).simple(config.getLdpathServiceBaseUrl()) - .setHeader(HTTP_QUERY).simple("context=${headers.CamelFcrepoUri}") - .to("http://localhost/ldpath"); /* * Handle update operations */ from("direct:update.solr").routeId("FcrepoSolrUpdater") .log(LoggingLevel.INFO, logger, "Indexing Solr Object ${header.CamelFcrepoUri}") - .setBody(constant(null)) .setHeader(INDEXING_URI).simple("${header.CamelFcrepoUri}") // Don't index the transformation itself .filter().simple("${header.CamelIndexingTransformation} != ${header.CamelIndexingUri}") .choice() - .when(header(INDEXING_TRANSFORMATION).startsWith("http")) - .log(LoggingLevel.INFO, logger, - "Fetching external LDPath program from ${header.CamelIndexingTransformation}") - .to("direct:external.ldpath") - .setHeader(HTTP_METHOD).constant("POST") - .to("direct:transform.ldpath") - .to("direct:send.to.solr") - .when(or(header(INDEXING_TRANSFORMATION).isNull(), header(INDEXING_TRANSFORMATION).isEqualTo(""))) - .setHeader(HTTP_METHOD).constant("GET") - .to("direct:transform.ldpath") - .to("direct:send.to.solr") - .otherwise() - .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}"); + .when(header(INDEXING_TRANSFORMATION).isNotNull()) + .log(LoggingLevel.INFO, logger, + "Sending RDF for Transform with with XSLT from ${header.CamelIndexingTransformation}") + .toD("xslt:${header.CamelIndexingTransformation}") + .to("direct:send.to.solr") + .when(or(header(INDEXING_TRANSFORMATION).isNull(), header(INDEXING_TRANSFORMATION).isEqualTo(""))) + .log(LoggingLevel.INFO, logger,"No Transform supplied") + .to("direct:send.to.solr") + .otherwise() + .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}"); /* * Send the transformed resource to Solr @@ -178,6 +163,7 @@ public void configure() throws Exception { from("direct:send.to.solr").routeId("FcrepoSolrSend") .log(LoggingLevel.INFO, logger, "sending to solr...") .removeHeaders("CamelHttp*") + .setHeader(CONTENT_TYPE).constant("text/xml") .setHeader(HTTP_METHOD).constant("POST") .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); diff --git a/fcrepo-indexing-solr/src/main/resources/org/fcrepo/camel/indexing/solr/default_transform.xsl b/fcrepo-indexing-solr/src/main/resources/org/fcrepo/camel/indexing/solr/default_transform.xsl new file mode 100644 index 00000000..ccffec08 --- /dev/null +++ b/fcrepo-indexing-solr/src/main/resources/org/fcrepo/camel/indexing/solr/default_transform.xsl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java index 642250ca..799160c9 100644 --- a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java +++ b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java @@ -77,7 +77,7 @@ public static void beforeClass() { System.setProperty("solr.reindex.stream", "seda:bar"); System.setProperty("error.maxRedeliveries", "10"); System.setProperty("fcrepo.baseUrl", baseURL); - System.setProperty("solr.fcrepo.defaultTransform", "http://localhost/ldpath/program"); + System.setProperty("solr.fcrepo.defaultTransform", "org/fcrepo/camel/indexing/solr/default_transform.xsl"); System.setProperty("solr.baseUrl", solrURL); System.setProperty("solr.reindex.stream", "seda:reindex"); System.setProperty("solr.fcrepo.checkHasIndexingTransformation", "true"); @@ -214,7 +214,7 @@ public void testPrepareRouterIndexable() throws Exception { deleteEndpoint.setAssertPeriod(ASSERT_PERIOD_MS); updateEndpoint.expectedMessageCount(1); updateEndpoint.expectedHeaderReceived("CamelIndexingTransformation", - "http://localhost/ldpath/default"); + "org/fcrepo/camel/indexing/solr/default_transform.xsl"); template.sendBodyAndHeaders( IOUtils.toString(loadResourceAsStream("indexable.rdf"), "UTF-8"), @@ -245,7 +245,7 @@ public void testPrepareRouterContainer() throws Exception { updateEndpoint.setAssertPeriod(ASSERT_PERIOD_MS); deleteEndpoint.expectedMessageCount(1); deleteEndpoint.expectedHeaderReceived("CamelIndexingTransformation", - "http://localhost/ldpath/program"); + "org/fcrepo/camel/indexing/solr/default_transform.xsl"); template.sendBodyAndHeaders( IOUtils.toString(loadResourceAsStream("container.rdf"), "UTF-8"), @@ -271,10 +271,6 @@ public void testUpdateRouter() throws Exception { a.mockEndpointsAndSkip("http*"); }); - AdviceWith.adviceWith(context, "FcrepoSolrTransform", a -> { - a.mockEndpointsAndSkip("http*"); - }); - final var solrUpdateEndPoint = MockEndpoint.resolve(context, "mock:" + solrURL + "/update"); solrUpdateEndPoint.expectedMessageCount(1); solrUpdateEndPoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST"); diff --git a/fcrepo-indexing-solr/src/test/resources/indexable.rdf b/fcrepo-indexing-solr/src/test/resources/indexable.rdf index 2481ac54..4abaa76e 100644 --- a/fcrepo-indexing-solr/src/test/resources/indexable.rdf +++ b/fcrepo-indexing-solr/src/test/resources/indexable.rdf @@ -11,6 +11,6 @@ - + diff --git a/fcrepo-ldpath/my.ldpath b/fcrepo-ldpath/my.ldpath deleted file mode 100644 index 2832eeca..00000000 --- a/fcrepo-ldpath/my.ldpath +++ /dev/null @@ -1,130 +0,0 @@ -@prefix fedora : -@prefix pcdm : -@prefix ore : -@prefix iana : -@prefix acl : -@prefix dcterms : - -id = . :: xsd:string ; - -created_l = fedora:created :: xsd:dateTime ; -createdBy_s = fedora:createdBy :: xsd:string ; -hasParent_s = fedora:hasParent :: xsd:string ; -hasVersions_s = fedora:hasVersions :: xsd:anyURI ; -lastModified_l = fedora:lastModified :: xsd:dateTime ; -lastModifiedBy_s = fedora:lastModifiedBy :: xsd:string ; -numberOfChildren_l = fedora:numberOfChildren :: xsd:integer ; - -type_ss = rdf:type :: xsd:anyURI ; -label = rdfs:label :: xsd:string ; -comment = rdfs:comment :: xsd:string ; -sameAs = owl:sameAs :: xsd:anyURI ; - -altLabel = skos:altLabel :: xsd:string ; -broadMatch = skos:broadMatch :: xsd:anyURI ; -broader = skos:broader :: xsd:anyURI ; -broaderTransitive = skos:broaderTransitive :: xsd:anyURI ; -changeNote = skos:changeNote :: xsd:string ; -closeMatch = skos:closeMatch :: xsd:string ; -definition = skos:definition :: xsd:string ; -editorialNote = skos:editorialNote :: xsd:string ; -exactMatch = skos:exactMatch :: xsd:anyURI ; -example = skos:example :: xsd:string ; -hiddenLabel = skos:hiddenLabel :: xsd:string ; -historyNote = skos:historyNote :: xsd:string ; -inScheme = skos:inScheme :: xsd:anyURI ; -mappingRelation = skos:mappingRelation :: xsd:anyURI ; -member = skos:member :: xsd:anyURI ; -memberList = skos:memberList :: xsd:anyURI ; -narrowMatch = skos:narrowMatch :: xsd:anyURI ; -narrower = skos:narrower :: xsd:anyURI ; -narrowerTransitive = skos:narrowerTrasitive :: xsd:anyURI ; -notation = skos:notation :: xsd:string ; -note = skos:note :: xsd:string ; -prefLabel = skos:prefLabel :: xsd:string ; -related = skos:related :: xsd:anyURI ; -relatedMatch = skos:relatedMatch :: xsd:anyURI ; -scopeNote = skos:scopeNote :: xsd:string ; -semanticRelation = skos:semanticRelation :: xsd:anyURI ; -topConceptOf = skos:topConceptOf :: xsd:anyURI ; - -abstract = dcterms:abstract :: xsd:string ; -accessRights = dcterms:accessRights :: xsd:string ; -accrualMethod = dcterms:accrualMethod :: xsd:string ; -accrualPeriodicity = dcterms:accrualPeriodicity :: xsd:string ; -accrualPolicy = dcterms:accrualPolicy :: xsd:string ; -alternative = dcterms:alternative :: xsd:string ; -audience = dcterms:audience :: xsd:string ; -available = dcterms:available :: xsd:string ; -bibliographicCitation = dcterms:bibliographicCitation :: xsd:string ; -conformsTo = dcterms:conformsTo :: xsd:string ; -contributor = dc:contributor | dcterms:contributor :: xsd:string ; -coverage = dc:coverage | dcterms:coverage :: xsd:string ; -creator = dc:creator | dcterms:creator :: xsd:string ; -date = dc:date | dcterms:date :: xsd:dateTime ; -dateAccepted = dcterms:dateAccepted :: xsd:dateTime ; -dateCopyrighted = dcterms:dateCopyrighted :: xsd:dateTime ; -dateSubmitted = dcterms:dateSubmitted :: xsd:dateTime ; -description = dc:description | dcterms:description :: xsd:string ; -educationLevel = dcterms:educationLevel :: xsd:string ; -extent = dcterms:extent :: xsd:string ; -format = dc:format | dcterms:format :: xsd:string ; -hasFormat = dcterms:hasFormat :: xsd:string ; -hasPart = dcterms:hasPart :: xsd:string ; -hasVersion = dcterms:hasVersion :: xsd:string ; -identifier = dc:identifier | dcterms:identifier :: xsd:string ; -instructionalMethod = dcterms:instructionalMethod :: xsd:string ; -isFormatOf = dcterms:isFormatOf :: xsd:string ; -isPartOf = dcterms:isPartOf :: xsd:string ; -isReferencedBy = dcterms:isReferencedBy :: xsd:string ; -isReplacedBy = dcterms:isReplacedBy :: xsd:string ; -isRequiredBy = dcterms:isRequiredBy :: xsd:string ; -issued = dcterms:issued :: xsd:string ; -isVersionOf = dcterms:isVersionOf :: xsd:string ; -language = dc:language | dcterms:language :: xsd:string ; -license = dcterms:license :: xsd:string ; -mediator = dcterms:mediator :: xsd:string ; -medium = dcterms:medium :: xsd:string ; -modified = dcterms:modified :: xsd:string ; -provenance = dcterms:provenance :: xsd:string ; -publisher = dc:publisher | dcterms:publisher :: xsd:string ; -references = dcterms:references :: xsd:string ; -relation = dc:relation | dcterms:relation :: xsd:string ; -replaces = dcterms:replaces :: xsd:string ; -requires = dcterms:requires :: xsd:string ; -rights = dc:rights | dcterms:rights :: xsd:string ; -rightsHolder = dcterms:rightsHolder :: xsd:string ; -source = dc:source | dcterms:source :: xsd:string ; -spatial = dcterms:spatial :: xsd:string ; -subject = dc:subject | dcterms:subject :: xsd:string ; -tableOfContents = dcterms:tableOfContents :: xsd:string ; -temporal = dcterms:temporal :: xsd:string ; -title = dc:title | dcterms:title :: xsd:string ; -valid = dcterms:valid :: xsd:string ; - -fileOf = pcdm:fileOf :: xsd:anyURI ; -hasFile = pcdm:hasFile :: xsd:anyURI ; -hasMember = pcdm:hasMember :: xsd:anyURI ; -hasRelatedObject = pcdm:hasRelatedObject :: xsd:anyURI ; -memberOf = pcdm:memberOf :: xsd:anyURI ; -relatedObjectOf = pcdm:relatedObjectOf :: xsd:anyURI ; - -aggregates = ore:aggregates :: xsd:anyURI ; -isAggregatedBy = ore:isAggregatedBy :: xsd:anyURI ; -proxyFor = ore:proxyFor :: xsd:anyURI ; -proxyIn = ore:proxyIn :: xsd:anyURI ; - -first = iana:first :: xsd:anyURI ; -last = iana:last :: xsd:anyURI ; -next = iana:next :: xsd:anyURI ; -prev = iana:prev :: xsd:anyURI ; -describes = iana:describes :: xsd:anyURI ; -describedBy = iana:describedBy :: xsd:anyURI ; - -accessControl = acl:accessControl :: xsd:anyURI ; -accessTo = acl:accessTo :: xsd:anyURI ; -accessToClass = acl:accessToClass :: xsd:anyURI ; -agent = acl:agent :: xsd:string ; -agentClass = acl:agentClass :: xsd:anyURI ; -mode = acl:mode :: xsd:anyURI ; - diff --git a/fcrepo-ldpath/pom.xml b/fcrepo-ldpath/pom.xml deleted file mode 100644 index 68ff18e0..00000000 --- a/fcrepo-ldpath/pom.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - 4.0.0 - - - fcrepo-camel-toolbox - org.fcrepo.camel - 6.1.0-SNAPSHOT - - - fcrepo-ldpath - jar - - Fedora LDPath Service - Camel-based LDPath service - - - - - - - org.apache.camel - camel-core - - - org.apache.camel - camel-jackson - ${camel.version} - - - - org.apache.camel - camel-jetty - - - - org.apache.camel - camel-jetty-common - - - - org.apache.camel - camel-http - - - - org.apache.camel - camel-http-common - - - - ${project.parent.groupId} - fcrepo-camel-common - ${project.parent.version} - - - - ant - ant - 1.6.5 - - - org.apache.camel - camel-support - - - - org.apache.marmotta - ldcache-api - - - - org.apache.marmotta - ldcache-backend-file - - - - org.apache.camel - camel-spring-javaconfig - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - compile - - - - javax.xml.bind - jaxb-api - - - com.sun.xml.bind - jaxb-core - - - - org.apache.marmotta - ldpath-core - - - - org.apache.marmotta - ldpath-backend-linkeddata - - - - org.apache.marmotta - ldcache-api - - - - org.apache.marmotta - ldclient-provider-xml - - - - org.apache.marmotta - ldclient-provider-rdf - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - - org.semarglproject - semargl-sesame - 0.6.1 - - - - org.openrdf.sesame - sesame-rio-api - 2.9.0 - - - - org.fcrepo.client - fcrepo-java-client - ${fcrepo-java-client.version} - - - - org.apache.marmotta - ldcache-backend-file - - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - test - - - - - org.apache.camel - camel-test-spring - - - - - - install - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - fcrepo.dynamic.ldpath.port - ${fcrepo.dynamic.ldpath.port} - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - fcrepo.dynamic.ldpath.port - - - - - - - diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java deleted file mode 100644 index 9e9d4197..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/ClientFactory.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; - -import java.util.List; - -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.Credentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.HttpClients; -import org.apache.marmotta.ldclient.api.endpoint.Endpoint; -import org.apache.marmotta.ldclient.api.provider.DataProvider; -import org.apache.marmotta.ldclient.endpoint.rdf.LinkedDataEndpoint; -import org.apache.marmotta.ldclient.model.ClientConfiguration; -import org.apache.marmotta.ldclient.provider.rdf.CacheProvider; -import org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider; -import org.apache.marmotta.ldclient.provider.rdf.RegexUriProvider; -import org.apache.marmotta.ldclient.provider.rdf.SPARQLProvider; - -/** - * A convenience factory for creating a ClientConfiguration object - * @author acoburn - * @since Aug 5, 2016 - */ -public class ClientFactory { - - - /** - * Configure a linked data client suitable for use with a Fedora Repository. - * @param endpoint Endpoint to enable on the client - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final Endpoint endpoint) { - return createClient(singletonList(endpoint), emptyList()); - } - - /** - * Configure a linked data client suitable for use with a Fedora Repository. - * @param provider Provider to enable on the client - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final DataProvider provider) { - return createClient(null, null, emptyList(), singletonList(provider)); - } - - - /** - * Configure a linked data client suitable for use with a Fedora Repository. - * @param endpoint Endpoint to enable on the client - * @param provider Provider to enable on the client - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final Endpoint endpoint, final DataProvider provider) { - return createClient(singletonList(endpoint), singletonList(provider)); - } - - /** - * Configure a linked data client suitable for use with a Fedora Repository. - * @param endpoints additional endpoints to enable on the client - * @param providers additional providers to enable on the client - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final List endpoints, final List providers) { - return createClient(null, null, endpoints, providers); - } - - /** - * Configure a linked data client suitable for use with a Fedora Repository. - * @param authScope the authentication scope - * @param credentials the credentials - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final AuthScope authScope, final Credentials credentials) { - return createClient(authScope, credentials, emptyList(), emptyList()); - } - - /** - * Create a linked data client suitable for use with a Fedora Repository. - * @param authScope the authentication scope - * @param credentials the credentials - * @param endpoints additional endpoints to enable on the client - * @param providers additional providers to enable on the client - * @return a configuration for use with an LDClient - */ - public static ClientConfiguration createClient(final AuthScope authScope, final Credentials credentials, - final List endpoints, final List providers) { - - final ClientConfiguration client = new ClientConfiguration(); - - if (credentials != null && authScope != null) { - final CredentialsProvider credsProvider = new BasicCredentialsProvider(); - credsProvider.setCredentials(authScope, credentials); - client.setHttpClient(HttpClients.custom() - .setDefaultCredentialsProvider(credsProvider) - .useSystemProperties().build()); - } - - // manually add default Providers and Endpoints - client.addProvider(new LinkedDataProvider()); - client.addProvider(new CacheProvider()); - client.addProvider(new RegexUriProvider()); - client.addProvider(new SPARQLProvider()); - client.addEndpoint(new LinkedDataEndpoint()); - - // add any injected endpoints/providers - endpoints.forEach(client::addEndpoint); - providers.forEach(client::addProvider); - - return client; - } - - private ClientFactory() { - // prevent instantiation - } - -} diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FcrepoLdPathConfig.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FcrepoLdPathConfig.java deleted file mode 100644 index 68b07da6..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FcrepoLdPathConfig.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.Credentials; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.marmotta.ldcache.api.LDCachingBackend; -import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend; -import org.apache.marmotta.ldcache.model.CacheConfiguration; -import org.apache.marmotta.ldcache.services.LDCache; -import org.apache.marmotta.ldclient.api.endpoint.Endpoint; -import org.apache.marmotta.ldclient.api.provider.DataProvider; -import org.apache.marmotta.ldpath.api.functions.SelectorFunction; -import org.apache.marmotta.ldpath.backend.linkeddata.LDCacheBackend; -import org.fcrepo.camel.common.config.BasePropsConfig; -import org.fcrepo.client.FcrepoHttpClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.nio.file.Path; -import java.util.List; -import java.util.Set; - -import static java.util.Collections.EMPTY_SET; - -/** - * A configuration class for the LDPath service - * - * @author dbernstein - */ -@Configuration -public class FcrepoLdPathConfig extends BasePropsConfig { - - @Value("${ldpath.fcrepo.cache.timeout:0}") - private long fcrepoCacheTimeout; - - @Value("${ldpath.rest.prefix:/ldpath}") - private String restPrefix; - - @Value("${ldpath.rest.host:localhost}") - private String restHost; - - @Value("${ldpath.rest.port:9085}") - private int restPort; - - @Value("${ldpath.cache.timeout:86400}") - private int cacheTimeout; - - @Value("${ldpath.ldcache.directory:ldcache/}") - private Path ldCacheDirectory; - - @Value("${ldpath.transform.path:classpath:org/fcrepo/camel/ldpath/default.ldpath}") - private String ldpathTransformPath; - - public String getRestHost() { - return restHost; - } - - public int getRestPort() { - return restPort; - } - - public String getRestPrefix() { - return restPrefix; - } - - public String getLdpathTransformPath() { - return ldpathTransformPath; - } - - @Bean("ldpath") - public LDPathWrapper ldpath() throws Exception { - final var fcrepoBaseUrl = getFcrepoBaseUrl(); - final var fcrepoAuthHost = getFcrepoAuthHost(); - final var fcrepoUsername = getFcrepoUsername(); - final var fcrepoPassword = getFcrepoPassword(); - - final AuthScope authScope; - if (fcrepoAuthHost == null || fcrepoAuthHost.isBlank()) { - authScope = new AuthScope(AuthScope.ANY); - } else { - authScope = new AuthScope(new HttpHost(fcrepoAuthHost)); - } - final Credentials credentials = new UsernamePasswordCredentials(fcrepoUsername, fcrepoPassword); - final List endpoints = List.of(new FedoraEndpoint(fcrepoBaseUrl, fcrepoCacheTimeout)); - final var fcrepoHttpClientBuilder = new FcrepoHttpClientBuilder(fcrepoUsername, fcrepoPassword, fcrepoAuthHost); - final List providers = List.of(new FedoraProvider(fcrepoHttpClientBuilder)); - final var client = ClientFactory.createClient(authScope, credentials, endpoints, providers); - final var config = new CacheConfiguration(client); - config.setDefaultExpiry(cacheTimeout); - final LDCachingBackend ldCachingBackend = new LDCachingFileBackend(ldCacheDirectory.toFile()); - ldCachingBackend.initialize(); - final LDCache ldCache = new LDCache(config, ldCachingBackend); - final var backend = new LDCacheBackend(ldCache); - return new LDPathWrapper(backend, createSelectorFunctions()); - } - - protected Set createSelectorFunctions() { - return EMPTY_SET; - } - - @Bean - public LDPathRouter ldPathRouter() { - return new LDPathRouter(); - } - -} diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraEndpoint.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraEndpoint.java deleted file mode 100644 index e893e1dd..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraEndpoint.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import org.apache.marmotta.commons.http.ContentType; -import org.apache.marmotta.ldclient.api.endpoint.Endpoint; - -/** - * @author acoburn - * @since Aug 5, 2016 - */ -public class FedoraEndpoint extends Endpoint { - - /** - * Create a Fedora endpoint to be used with the Marmotta LDClient - * Note: the baseUrl defined here is used by the LDClient to determine - * what rules to apply when dereferencing URIs that start with the - * given namespace. - * - * @param namespace the namespace for the Fedora endpoint (e.g. http://localhost:8080/fcrepo/rest/) - */ - public FedoraEndpoint(final String namespace) { - this(namespace, 0L); - } - - /** - * Create a Fedora endpoint to be used with the Marmotta LDClient - * Note: the baseUrl defined here is used by the LDClient to determine - * what rules to apply when dereferencing URIs that start with the - * given namespace. - * - * @param namespace the namespace for the Fedora endpoint (e.g. http://localhost:8080/fcrepo/rest/) - * @param timeout the length of time (in seconds) to cache the data - */ - public FedoraEndpoint(final String namespace, final Long timeout) { - super("Fedora Repository", FedoraProvider.PROVIDER_NAME, namespace + ".*", null, timeout); - setPriority(PRIORITY_HIGH); - addContentType(new ContentType("application", "rdf+xml", 0.8)); - addContentType(new ContentType("text", "turtle", 1.0)); - addContentType(new ContentType("text", "n3", 0.8)); - addContentType(new ContentType("application", "ld+json", 0.5)); - } -} diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraProvider.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraProvider.java deleted file mode 100644 index bdef1e3c..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/FedoraProvider.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import static org.slf4j.LoggerFactory.getLogger; - -import org.apache.marmotta.ldclient.api.endpoint.Endpoint; -import org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider; -import org.fcrepo.client.FcrepoHttpClientBuilder; -import org.fcrepo.client.FcrepoLink; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.slf4j.Logger; - - -/** - * An extension Linked Data provider to support Binary nodes in Fedora. - * - * @author Mohamed Mohideen Abdul Rasheed - */ -public class FedoraProvider extends LinkedDataProvider { - - private static final Logger LOGGER = getLogger(FedoraProvider.class); - - public static final String PROVIDER_NAME = "Fedora"; - - private final HttpClient httpClient; - - private final String NON_RDF_SOURCE_URI = "http://www.w3.org/ns/ldp#NonRDFSource"; - - /** - * FedoraProvider - * @param builder FcrepoHttpClientBuilder for building HttpClient - */ - public FedoraProvider(final FcrepoHttpClientBuilder builder) { - Objects.requireNonNull(builder); - httpClient = builder.build(); - } - - /* - * Return the name of this data provider. To be used e.g. in the configuration and in log messages. - */ - @Override - public String getName() { - return PROVIDER_NAME; - } - - /* - * Return the describedBy URL for NonRdfSource resources. Return the resourseUri otherwise. - */ - @Override - public List buildRequestUrl(final String resourceUri, final Endpoint endpoint) { - LOGGER.debug("Processing: " + resourceUri); - Objects.requireNonNull(resourceUri); - try { - final Optional nonRdfSourceDescUri = - getNonRDFSourceDescribedByUri(resourceUri); - if ( nonRdfSourceDescUri.isPresent() ) { - return Collections.singletonList(nonRdfSourceDescUri.get()); - } - } catch (final IOException ex) { - throw new UncheckedIOException(ex); - } - return Collections.singletonList(resourceUri); - } - - /* - * Get the describedBy Uri if the resource has a NON_RDF_SOURCE_URI link header. - */ - private Optional getNonRDFSourceDescribedByUri(final String resourceUri) throws IOException { - Optional nonRdfSourceDescUri = Optional.empty(); - final Header[] links = getLinkHeaders(resourceUri); - if ( links != null ) { - String descriptionUri = null; - boolean isNonRDFSource = false; - for ( final Header h : links ) { - final FcrepoLink link = new FcrepoLink(h.getValue()); - if ( link.getRel().equals("describedby") ) { - descriptionUri = link.getUri().toString(); - } else if ( link.getUri().toString().contains(NON_RDF_SOURCE_URI)) { - isNonRDFSource = true; - } - } - LOGGER.debug("isNonRDFSource: " + isNonRDFSource); - if (isNonRDFSource && descriptionUri != null) { - nonRdfSourceDescUri = Optional.of(descriptionUri); - } - } - return nonRdfSourceDescUri; - } - - /* - * Get the link headers for the resource at the given Uri. - */ - private Header[] getLinkHeaders(final String resourceUri) throws IOException { - final HttpHead request = new HttpHead(resourceUri); - final HttpResponse response = httpClient.execute(request); - LOGGER.debug("Got: " + response.getStatusLine().getStatusCode() + " for HEAD " + resourceUri); - return response.getHeaders("Link"); - } - -} diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathRouter.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathRouter.java deleted file mode 100644 index 9debd5a6..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathRouter.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import static java.lang.String.format; -import static org.apache.camel.builder.PredicateBuilder.and; -import static org.apache.camel.builder.PredicateBuilder.not; -import static org.apache.camel.model.dataformat.JsonLibrary.Jackson; -import static org.apache.camel.Exchange.CONTENT_TYPE; -import static org.apache.camel.Exchange.HTTP_METHOD; -import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE; -import static org.apache.camel.Exchange.HTTP_URI; -import static org.slf4j.LoggerFactory.getLogger; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.support.builder.ExpressionBuilder; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * A content router for an LDPath service. - * - * @author Aaron Coburn - * @since Aug 5, 2016 - */ - -public class LDPathRouter extends RouteBuilder { - - private static final Logger LOGGER = getLogger(LDPathRouter.class); - - @Autowired - private LDPathWrapper ldpathWrapper; - - @Autowired - private FcrepoLdPathConfig config; - /** - * Configure the message route workflow. - */ - public void configure() throws Exception { - - /** - * Expose a RESTful endpoint for LDPath processing - */ - from(format("jetty:http://%s:%d%s?" + - "httpMethodRestrict=GET,POST,OPTIONS" + - "&sendServerVersion=false", config.getRestHost(), config.getRestPort(),config.getRestPrefix())) - .routeId("FcrepoLDPathRest") - .routeDescription("Expose the ldpath endpoint over HTTP") - .choice() - .when(header(HTTP_METHOD).isEqualTo("OPTIONS")) - .setHeader(CONTENT_TYPE).constant("text/turtle") - .setHeader("Allow").constant("GET,POST,OPTIONS") - .to("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl") - // make sure the required context parameter is present - .when(not(and(header("context").isNotNull(), header("context").regex("^https?://.+")))) - .setHeader(HTTP_RESPONSE_CODE).constant(400) - .setHeader(CONTENT_TYPE).constant("text/plain") - .transform(constant("Missing context parameter")) - .when(header(HTTP_METHOD).isEqualTo("GET")) - .to("direct:get") - .when(header(HTTP_METHOD).isEqualTo("POST")) - .to("direct:ldpathPrepare"); - - - from("direct:get") - .routeId("FcrepoLDPathGet") - .choice() - .when(and(header("ldpath").isNotNull(), header("ldpath").regex("^https?://.*"))) - .removeHeaders("CamelHttp*") - .setHeader(HTTP_URI).header("ldpath") - .to("http://localhost?useSystemProperties=true") - .to("direct:ldpathPrepare") - .otherwise() - .to("language:simple:resource:" + config.getLdpathTransformPath()) - .to("direct:ldpathPrepare"); - - from("direct:ldpathPrepare").routeId("FcrepoLDPathPrepare") - .to("direct:ldpath") - .to("direct:format"); - - from("direct:format").routeId("FcrepoLDPathFormat") - .marshal().json(Jackson) - .removeHeaders("*") - .setHeader(CONTENT_TYPE).constant("application/json"); - - from("direct:ldpath") - .setBody(ExpressionBuilder.beanExpression(ldpathWrapper, - "programQuery(${headers.context}, ${body})")); - } -} diff --git a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java b/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java deleted file mode 100644 index 21fb348d..00000000 --- a/fcrepo-ldpath/src/main/java/org/fcrepo/camel/ldpath/LDPathWrapper.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import static java.util.Collections.singletonList; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.github.jsonldjava.sesame.SesameJSONLDParserFactory; -import org.apache.marmotta.ldpath.LDPath; -import org.apache.marmotta.ldpath.api.functions.SelectorFunction; -import org.apache.marmotta.ldpath.backend.linkeddata.LDCacheBackend; -import org.apache.marmotta.ldpath.exception.LDPathParseException; -import org.openrdf.model.Value; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.query.resultio.BooleanQueryResultParserRegistry; -import org.openrdf.query.resultio.TupleQueryResultParserRegistry; -import org.openrdf.query.resultio.sparqlxml.SPARQLBooleanXMLParserFactory; -import org.openrdf.query.resultio.sparqlxml.SPARQLResultsXMLParserFactory; -import org.openrdf.rio.RDFParserRegistry; -import org.openrdf.rio.n3.N3ParserFactory; -import org.openrdf.rio.ntriples.NTriplesParserFactory; -import org.openrdf.rio.rdfjson.RDFJSONParserFactory; -import org.openrdf.rio.rdfxml.RDFXMLParserFactory; -import org.openrdf.rio.trig.TriGParserFactory; -import org.openrdf.rio.turtle.TurtleParserFactory; -import org.semarglproject.sesame.rdf.rdfa.SesameRDFaParserFactory; - -/** - * A convenience factory for creating an LDPath object with an LDCacheBackend. - * @author acoburn - * @since Aug 5, 2016 - */ -public class LDPathWrapper { - - private final LDPath ldpath; - - /** - * Create an LDPathWrapper and register a set of selector functions. - * - * @param backend the linkeddata backend - * @param functions selector functions - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - public LDPathWrapper(final LDCacheBackend backend, final Set functions) { - this(backend); - for (SelectorFunction function : functions) { - ldpath.registerFunction(function); - } - } - - /** - * Create an LDPathWrapper Object - * @param backend the linkeddata backend - */ - public LDPathWrapper(final LDCacheBackend backend) { - - // Register the Sesame RDF Parsers manually - RDFParserRegistry.getInstance().add(new RDFXMLParserFactory()); - RDFParserRegistry.getInstance().add(new NTriplesParserFactory()); - RDFParserRegistry.getInstance().add(new TurtleParserFactory()); - RDFParserRegistry.getInstance().add(new N3ParserFactory()); - RDFParserRegistry.getInstance().add(new SesameJSONLDParserFactory()); - RDFParserRegistry.getInstance().add(new RDFJSONParserFactory()); - RDFParserRegistry.getInstance().add(new SesameRDFaParserFactory()); - RDFParserRegistry.getInstance().add(new TriGParserFactory()); - BooleanQueryResultParserRegistry.getInstance().add(new SPARQLBooleanXMLParserFactory()); - TupleQueryResultParserRegistry.getInstance().add(new SPARQLResultsXMLParserFactory()); - - ldpath = new LDPath(backend); - } - - /** - * Execute an LDPath query - * @param uri the URI to query - * @param program the LDPath program - * @return a result object wrapped in a List - * @throws LDPathParseException if the LDPath program was malformed - */ - public List>> programQuery(final String uri, final InputStream program) - throws LDPathParseException { - return singletonList(ldpath.programQuery(new URIImpl(uri), new InputStreamReader(program))); - } -} diff --git a/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/default.ldpath b/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/default.ldpath deleted file mode 100644 index 2832eeca..00000000 --- a/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/default.ldpath +++ /dev/null @@ -1,130 +0,0 @@ -@prefix fedora : -@prefix pcdm : -@prefix ore : -@prefix iana : -@prefix acl : -@prefix dcterms : - -id = . :: xsd:string ; - -created_l = fedora:created :: xsd:dateTime ; -createdBy_s = fedora:createdBy :: xsd:string ; -hasParent_s = fedora:hasParent :: xsd:string ; -hasVersions_s = fedora:hasVersions :: xsd:anyURI ; -lastModified_l = fedora:lastModified :: xsd:dateTime ; -lastModifiedBy_s = fedora:lastModifiedBy :: xsd:string ; -numberOfChildren_l = fedora:numberOfChildren :: xsd:integer ; - -type_ss = rdf:type :: xsd:anyURI ; -label = rdfs:label :: xsd:string ; -comment = rdfs:comment :: xsd:string ; -sameAs = owl:sameAs :: xsd:anyURI ; - -altLabel = skos:altLabel :: xsd:string ; -broadMatch = skos:broadMatch :: xsd:anyURI ; -broader = skos:broader :: xsd:anyURI ; -broaderTransitive = skos:broaderTransitive :: xsd:anyURI ; -changeNote = skos:changeNote :: xsd:string ; -closeMatch = skos:closeMatch :: xsd:string ; -definition = skos:definition :: xsd:string ; -editorialNote = skos:editorialNote :: xsd:string ; -exactMatch = skos:exactMatch :: xsd:anyURI ; -example = skos:example :: xsd:string ; -hiddenLabel = skos:hiddenLabel :: xsd:string ; -historyNote = skos:historyNote :: xsd:string ; -inScheme = skos:inScheme :: xsd:anyURI ; -mappingRelation = skos:mappingRelation :: xsd:anyURI ; -member = skos:member :: xsd:anyURI ; -memberList = skos:memberList :: xsd:anyURI ; -narrowMatch = skos:narrowMatch :: xsd:anyURI ; -narrower = skos:narrower :: xsd:anyURI ; -narrowerTransitive = skos:narrowerTrasitive :: xsd:anyURI ; -notation = skos:notation :: xsd:string ; -note = skos:note :: xsd:string ; -prefLabel = skos:prefLabel :: xsd:string ; -related = skos:related :: xsd:anyURI ; -relatedMatch = skos:relatedMatch :: xsd:anyURI ; -scopeNote = skos:scopeNote :: xsd:string ; -semanticRelation = skos:semanticRelation :: xsd:anyURI ; -topConceptOf = skos:topConceptOf :: xsd:anyURI ; - -abstract = dcterms:abstract :: xsd:string ; -accessRights = dcterms:accessRights :: xsd:string ; -accrualMethod = dcterms:accrualMethod :: xsd:string ; -accrualPeriodicity = dcterms:accrualPeriodicity :: xsd:string ; -accrualPolicy = dcterms:accrualPolicy :: xsd:string ; -alternative = dcterms:alternative :: xsd:string ; -audience = dcterms:audience :: xsd:string ; -available = dcterms:available :: xsd:string ; -bibliographicCitation = dcterms:bibliographicCitation :: xsd:string ; -conformsTo = dcterms:conformsTo :: xsd:string ; -contributor = dc:contributor | dcterms:contributor :: xsd:string ; -coverage = dc:coverage | dcterms:coverage :: xsd:string ; -creator = dc:creator | dcterms:creator :: xsd:string ; -date = dc:date | dcterms:date :: xsd:dateTime ; -dateAccepted = dcterms:dateAccepted :: xsd:dateTime ; -dateCopyrighted = dcterms:dateCopyrighted :: xsd:dateTime ; -dateSubmitted = dcterms:dateSubmitted :: xsd:dateTime ; -description = dc:description | dcterms:description :: xsd:string ; -educationLevel = dcterms:educationLevel :: xsd:string ; -extent = dcterms:extent :: xsd:string ; -format = dc:format | dcterms:format :: xsd:string ; -hasFormat = dcterms:hasFormat :: xsd:string ; -hasPart = dcterms:hasPart :: xsd:string ; -hasVersion = dcterms:hasVersion :: xsd:string ; -identifier = dc:identifier | dcterms:identifier :: xsd:string ; -instructionalMethod = dcterms:instructionalMethod :: xsd:string ; -isFormatOf = dcterms:isFormatOf :: xsd:string ; -isPartOf = dcterms:isPartOf :: xsd:string ; -isReferencedBy = dcterms:isReferencedBy :: xsd:string ; -isReplacedBy = dcterms:isReplacedBy :: xsd:string ; -isRequiredBy = dcterms:isRequiredBy :: xsd:string ; -issued = dcterms:issued :: xsd:string ; -isVersionOf = dcterms:isVersionOf :: xsd:string ; -language = dc:language | dcterms:language :: xsd:string ; -license = dcterms:license :: xsd:string ; -mediator = dcterms:mediator :: xsd:string ; -medium = dcterms:medium :: xsd:string ; -modified = dcterms:modified :: xsd:string ; -provenance = dcterms:provenance :: xsd:string ; -publisher = dc:publisher | dcterms:publisher :: xsd:string ; -references = dcterms:references :: xsd:string ; -relation = dc:relation | dcterms:relation :: xsd:string ; -replaces = dcterms:replaces :: xsd:string ; -requires = dcterms:requires :: xsd:string ; -rights = dc:rights | dcterms:rights :: xsd:string ; -rightsHolder = dcterms:rightsHolder :: xsd:string ; -source = dc:source | dcterms:source :: xsd:string ; -spatial = dcterms:spatial :: xsd:string ; -subject = dc:subject | dcterms:subject :: xsd:string ; -tableOfContents = dcterms:tableOfContents :: xsd:string ; -temporal = dcterms:temporal :: xsd:string ; -title = dc:title | dcterms:title :: xsd:string ; -valid = dcterms:valid :: xsd:string ; - -fileOf = pcdm:fileOf :: xsd:anyURI ; -hasFile = pcdm:hasFile :: xsd:anyURI ; -hasMember = pcdm:hasMember :: xsd:anyURI ; -hasRelatedObject = pcdm:hasRelatedObject :: xsd:anyURI ; -memberOf = pcdm:memberOf :: xsd:anyURI ; -relatedObjectOf = pcdm:relatedObjectOf :: xsd:anyURI ; - -aggregates = ore:aggregates :: xsd:anyURI ; -isAggregatedBy = ore:isAggregatedBy :: xsd:anyURI ; -proxyFor = ore:proxyFor :: xsd:anyURI ; -proxyIn = ore:proxyIn :: xsd:anyURI ; - -first = iana:first :: xsd:anyURI ; -last = iana:last :: xsd:anyURI ; -next = iana:next :: xsd:anyURI ; -prev = iana:prev :: xsd:anyURI ; -describes = iana:describes :: xsd:anyURI ; -describedBy = iana:describedBy :: xsd:anyURI ; - -accessControl = acl:accessControl :: xsd:anyURI ; -accessTo = acl:accessTo :: xsd:anyURI ; -accessToClass = acl:accessToClass :: xsd:anyURI ; -agent = acl:agent :: xsd:string ; -agentClass = acl:agentClass :: xsd:anyURI ; -mode = acl:mode :: xsd:anyURI ; - diff --git a/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/options.ttl b/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/options.ttl deleted file mode 100644 index 2a2fb087..00000000 --- a/fcrepo-ldpath/src/main/resources/org/fcrepo/camel/ldpath/options.ttl +++ /dev/null @@ -1,11 +0,0 @@ -@prefix rdfs: . -@prefix registry: . -@prefix apix: . - -<#Extension> a apix:Extension ; - rdfs:label "LDPath Service" ; - rdfs:comment "A service that can apply LDPath programs to Fedora resources" ; - rdfs:seeAlso ; - apix:exposesService registry:LDPathService ; - apix:exposesServiceAtURI "svc:ldpath" ; - apix:bindsTo fedora:Resource . diff --git a/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteTest.java b/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteTest.java deleted file mode 100644 index 646fd1ba..00000000 --- a/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.AdviceWith; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.spring.javaconfig.CamelConfiguration; -import org.apache.commons.io.FileUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.camel.Exchange.CONTENT_TYPE; -import static org.apache.camel.Exchange.HTTP_METHOD; -import static org.apache.camel.Exchange.HTTP_URI; -import static org.apache.camel.util.ObjectHelper.loadResourceAsStream; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Test the route workflow. - * - * @author acoburn - * @since Aug 6, 2016 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RouteTest.ContextConfig.class}, loader = AnnotationConfigContextLoader.class) -public class RouteTest { - - private final ObjectMapper MAPPER = new ObjectMapper(); - - @EndpointInject("mock:language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl") - protected MockEndpoint optionsEndpoint; - - @EndpointInject("mock:http:localhost") - protected MockEndpoint httpEndpoint; - - @Produce("direct:start") - protected ProducerTemplate template; - - @Autowired - private CamelContext camelContext; - - @BeforeClass - public static void beforeClass() { - final String targetDir = System.getProperty("project.build.directory", "target"); - final var ldCacheDir = targetDir + File.separator + RouteTest.class.getCanonicalName() + - File.separator + "ldcache"; - new File(ldCacheDir).mkdirs(); - System.setProperty("ldpath.ldcache.directory", ldCacheDir); - final String restPort = System.getProperty("fcrepo.dynamic.ldpath.port", "9085"); - System.setProperty("ldpath.rest.port", restPort); - System.setProperty("ldpath.rest.host", "0.0.0.0"); - } - - @AfterClass - public static void afterClass() { - FileUtils.deleteQuietly(new File(System.getProperty("ldpath.ldcache.directory"))); - } - - @Test - public void testGetDefault() throws Exception { - - final String uri = "http://fedora.info/definitions/v4/event#ResourceCreation"; - final String endpoint = "mock:resultGet"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathGet", a -> { - a.weaveAddLast().to(endpoint); - }); - - template.sendBodyAndHeader("direct:get", null, "context", uri); - - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type_ss")); - assertTrue(data.get(0).get("id").contains(uri)); - assertTrue(data.get(0).get("label").contains("resource creation")); - assertTrue(data.get(0).get("type_ss").contains("http://www.w3.org/2000/01/rdf-schema#Class")); - } - - @Test - public void testOptions() throws Exception { - optionsEndpoint.expectedMessageCount(1); - final var context = camelContext.adapt(ModelCamelContext.class); - - AdviceWith.adviceWith(context, "FcrepoLDPathRest", a -> { - a.replaceFromWith("direct:start"); - a.mockEndpointsAndSkip("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl"); - }); - - template.sendBodyAndHeader(null, HTTP_METHOD, "OPTIONS"); - optionsEndpoint.assertIsSatisfied(); - - } - - @Test - public void testGetParam() throws Exception { - final String uri = "http://fedora.info/definitions/v4/repository#Binary"; - final String endpoint = "mock:resultGetParam"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - httpEndpoint.expectedMessageCount(1); - httpEndpoint.expectedHeaderReceived(HTTP_URI, "http://example.org/ldpath"); - final var context = camelContext.adapt(ModelCamelContext.class); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - - AdviceWith.adviceWith(context, "FcrepoLDPathGet", a -> { - a.mockEndpointsAndSkip("http:*"); - a.weaveAddLast().to(endpoint); - }); - - final Map headers = new HashMap<>(); - headers.put("ldpath", "http://example.org/ldpath"); - headers.put("context", uri); - template.sendBodyAndHeaders("direct:get", loadResourceAsStream("test.ldpath"), headers); - - httpEndpoint.assertIsSatisfied(); - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type")); - assertTrue(data.get(0).get("label").contains("binary")); - assertTrue(data.get(0).get("type").contains("Class")); - assertTrue(data.get(0).get("id").contains(uri)); - } - - @Test - public void testMimicPost() throws Exception { - final String uri = "http://fedora.info/definitions/v4/repository#Container"; - final String endpoint = "mock:resultPost"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - final var context = camelContext.adapt(ModelCamelContext.class); - - AdviceWith.adviceWith(context, "FcrepoLDPathPrepare", a -> { - a.weaveAddLast().to(endpoint); - }); - - - context.start(); - - template.sendBodyAndHeader("direct:ldpathPrepare", loadResourceAsStream("test.ldpath"), "context", uri); - - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type")); - assertTrue(data.get(0).get("label").contains("Fedora Container")); - assertTrue(data.get(0).get("type").contains("Class")); - assertTrue(data.get(0).get("id").contains(uri)); - - } - - - @Configuration - @ComponentScan(resourcePattern = "**/Fcrepo*.class") - static class ContextConfig extends CamelConfiguration { - } -} diff --git a/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteWithFunctionsTest.java b/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteWithFunctionsTest.java deleted file mode 100644 index 3e4df90a..00000000 --- a/fcrepo-ldpath/src/test/java/org/fcrepo/camel/ldpath/RouteWithFunctionsTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree. - */ -package org.fcrepo.camel.ldpath; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.EndpointInject; -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.AdviceWith; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.model.ModelCamelContext; -import org.apache.camel.spring.javaconfig.CamelConfiguration; -import org.apache.commons.io.FileUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.camel.Exchange.CONTENT_TYPE; -import static org.apache.camel.Exchange.HTTP_METHOD; -import static org.apache.camel.Exchange.HTTP_URI; -import static org.apache.camel.util.ObjectHelper.loadResourceAsStream; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Test the route workflow with functions enabled. - * - * @author Peter Eichman - * @since May 11, 2018 - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {RouteWithFunctionsTest.ContextConfig.class}, - loader = AnnotationConfigContextLoader.class) -public class RouteWithFunctionsTest { - - private final ObjectMapper MAPPER = new ObjectMapper(); - - @EndpointInject("mock:http:localhost") - protected MockEndpoint httpEndpoint; - - @EndpointInject("mock:language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl") - protected MockEndpoint optionsEndpoint; - - @Produce("direct:start") - protected ProducerTemplate template; - - @Autowired - protected CamelContext camelContext; - - @BeforeClass - public static void beforeClass() { - final String targetDir = System.getProperty("project.build.directory", "target"); - final var ldCacheDir = targetDir + File.separator + RouteWithFunctionsTest.class.getCanonicalName() + - File.separator + "ldcache"; - new File(ldCacheDir).mkdirs(); - - System.setProperty("ldpath.ldcache.directory", ldCacheDir); - final String restPort = System.getProperty("fcrepo.dynamic.ldpath.port", "9085"); - System.setProperty("ldpath.rest.port", restPort); - System.setProperty("ldpath.rest.host", "0.0.0.0"); - - } - - @AfterClass - public static void afterClass() { - FileUtils.deleteQuietly(new File(System.getProperty("ldpath.ldcache.directory"))); - } - - @Test - public void testGetDefault() throws Exception { - final String uri = "http://fedora.info/definitions/v4/event#ResourceCreation"; - final String endpoint = "mock:resultGet"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathGet", a -> { - a.weaveAddLast().to(endpoint); - }); - - template.sendBodyAndHeader("direct:get", null, "context", uri); - - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type_ss")); - - assertTrue(data.get(0).get("id").contains(uri)); - assertTrue(data.get(0).get("label").contains("resource creation")); - assertTrue(data.get(0).get("type_ss").contains("http://www.w3.org/2000/01/rdf-schema#Class")); - } - - @Test - public void testOptions() throws Exception { - optionsEndpoint.expectedMessageCount(1); - - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathRest", a -> { - a.replaceFromWith("direct:start"); - a.mockEndpointsAndSkip("language:simple:resource:classpath:org/fcrepo/camel/ldpath/options.ttl"); - }); - - template.sendBodyAndHeader(null, HTTP_METHOD, "OPTIONS"); - optionsEndpoint.assertIsSatisfied(); - } - - @Test - public void testGetParam() throws Exception { - final String uri = "http://fedora.info/definitions/v4/repository#Binary"; - final String endpoint = "mock:resultGetParam"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - httpEndpoint.expectedMessageCount(1); - httpEndpoint.expectedHeaderReceived(HTTP_URI, "http://example.org/ldpath"); - - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathGet", a -> { - a.mockEndpointsAndSkip("http:*"); - a.weaveAddLast().to(endpoint); - }); - - final Map headers = new HashMap<>(); - headers.put("ldpath", "http://example.org/ldpath"); - headers.put("context", uri); - template.sendBodyAndHeaders("direct:get", loadResourceAsStream("test.ldpath"), headers); - - mockEndpoint.assertIsSatisfied(); - httpEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type")); - assertTrue(data.get(0).get("id").contains(uri)); - assertTrue(data.get(0).get("label").contains("binary")); - assertTrue(data.get(0).get("type").contains("Class")); - } - - @Test - public void testMimicPost() throws Exception { - final String uri = "http://fedora.info/definitions/v4/repository#Container"; - final String endpoint = "mock:resultPost"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathPrepare", a -> { - a.weaveAddLast().to(endpoint); - }); - - template.sendBodyAndHeader("direct:ldpathPrepare", - loadResourceAsStream("test.ldpath"), "context", uri); - - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type")); - assertTrue(data.get(0).get("label").contains("Fedora Container")); - assertTrue(data.get(0).get("type").contains("Class")); - assertTrue(data.get(0).get("id").contains(uri)); - - } - - @Test - public void testMimicPostWithFunctions() throws Exception { - final String uri = "http://fedora.info/definitions/v4/repository#Container"; - final String endpoint = "mock:resultPostWithFunctions"; - final MockEndpoint mockEndpoint = (MockEndpoint) camelContext.getEndpoint(endpoint); - mockEndpoint.expectedMessageCount(1); - mockEndpoint.expectedHeaderReceived(CONTENT_TYPE, "application/json"); - - final var context = camelContext.adapt(ModelCamelContext.class); - AdviceWith.adviceWith(context, "FcrepoLDPathPrepare", a -> { - a.weaveAddLast().to(endpoint); - }); - - - template.sendBodyAndHeader("direct:ldpathPrepare", - loadResourceAsStream("test-with-functions.ldpath"), - "context", uri); - - mockEndpoint.assertIsSatisfied(); - final String result = mockEndpoint.getExchanges().get(0).getIn().getBody(String.class); - - @SuppressWarnings("unchecked") - final List>> data = MAPPER.readValue(result, List.class); - - assertFalse(data.isEmpty()); - assertTrue(data.get(0).containsKey("label")); - assertTrue(data.get(0).containsKey("type")); - assertTrue(data.get(0).containsKey("description")); - assertTrue(data.get(0).get("label").contains("Fedora Container")); - assertTrue(data.get(0).get("type").contains("Class")); - assertTrue(data.get(0).get("id").contains(uri)); - assertTrue(data.get(0).get("description").contains("Class : Fedora Container")); - - } - - - @Configuration - @ComponentScan(resourcePattern = "**/Fcrepo*.class") - static class ContextConfig extends CamelConfiguration { - } -} - diff --git a/fcrepo-ldpath/src/test/resources/container.ttl b/fcrepo-ldpath/src/test/resources/container.ttl deleted file mode 100644 index eb5c8f26..00000000 --- a/fcrepo-ldpath/src/test/resources/container.ttl +++ /dev/null @@ -1,8 +0,0 @@ -PREFIX ldp: -PREFIX indexing: -PREFIX pcdm: -PREFIX rdfs: - -<> a pcdm:Object; - rdfs:label "Some Object" ; - indexing:hasIndexingTransformation . diff --git a/fcrepo-ldpath/src/test/resources/logback-test.xml b/fcrepo-ldpath/src/test/resources/logback-test.xml deleted file mode 100644 index 14e71448..00000000 --- a/fcrepo-ldpath/src/test/resources/logback-test.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - %p %d{HH:mm:ss.SSS} \(%c{0}\) %m%n - - - - - - - - - - - - - - - - diff --git a/fcrepo-ldpath/src/test/resources/test-with-functions.ldpath b/fcrepo-ldpath/src/test/resources/test-with-functions.ldpath deleted file mode 100644 index 101e56d8..00000000 --- a/fcrepo-ldpath/src/test/resources/test-with-functions.ldpath +++ /dev/null @@ -1,6 +0,0 @@ -id = . :: xsd:string ; - -type = rdf:type / rdfs:label :: xsd:string ; -label = rdfs:label :: xsd:string ; -comment = rdfs:comment :: xsd:string ; -description = fn:concat(rdf:type / rdfs:label, " : ", rdfs:label) :: xsd:string ; diff --git a/fcrepo-ldpath/src/test/resources/test.ldpath b/fcrepo-ldpath/src/test/resources/test.ldpath deleted file mode 100644 index 4214cdf8..00000000 --- a/fcrepo-ldpath/src/test/resources/test.ldpath +++ /dev/null @@ -1,5 +0,0 @@ -id = . :: xsd:string ; - -type = rdf:type / rdfs:label :: xsd:string ; -label = rdfs:label :: xsd:string ; -comment = rdfs:comment :: xsd:string ; diff --git a/pom.xml b/pom.xml index ecf4a6a6..15003ddb 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,6 @@ fcrepo-http-forwarding fcrepo-service-activemq fcrepo-service-camel - fcrepo-ldpath fcrepo-camel-toolbox-app fcrepo-camel-common fcrepo-fixity @@ -156,6 +155,11 @@ ${camel.version} + + org.apache.camel + camel-xslt + ${camel.version} + org.apache.camel @@ -273,42 +277,6 @@ ${httpclient.version} - - org.apache.marmotta - ldpath-core - ${marmotta.version} - - - - org.apache.marmotta - ldpath-backend-linkeddata - ${marmotta.version} - - - - org.apache.marmotta - ldcache-backend-file - ${marmotta.version} - compile - - - - org.apache.marmotta - ldcache-api - ${marmotta.version} - - - - org.apache.marmotta - ldclient-provider-xml - ${marmotta.version} - - - - org.apache.marmotta - ldclient-provider-rdf - ${marmotta.version} - org.apache.jena From 1090239172131ee28243f3f6c3c9cc5f65f34597 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 1 Mar 2024 14:50:15 +0000 Subject: [PATCH 04/10] [maven-release-plugin] prepare release fcrepo-camel-toolbox-6.1.0 --- fcrepo-audit-triplestore/pom.xml | 2 +- fcrepo-camel-common/pom.xml | 2 +- fcrepo-camel-toolbox-app/pom.xml | 4 ++-- fcrepo-fixity/pom.xml | 2 +- fcrepo-http-forwarding/pom.xml | 2 +- fcrepo-indexing-solr/pom.xml | 2 +- fcrepo-indexing-triplestore/pom.xml | 2 +- fcrepo-reindexing/pom.xml | 2 +- fcrepo-service-activemq/pom.xml | 2 +- fcrepo-service-camel/pom.xml | 2 +- pom.xml | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fcrepo-audit-triplestore/pom.xml b/fcrepo-audit-triplestore/pom.xml index 0d77452b..567f9f6c 100644 --- a/fcrepo-audit-triplestore/pom.xml +++ b/fcrepo-audit-triplestore/pom.xml @@ -6,7 +6,7 @@ org.fcrepo.camel fcrepo-camel-toolbox - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-audit-triplestore diff --git a/fcrepo-camel-common/pom.xml b/fcrepo-camel-common/pom.xml index 677fac32..da51043d 100644 --- a/fcrepo-camel-common/pom.xml +++ b/fcrepo-camel-common/pom.xml @@ -3,7 +3,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 4.0.0 diff --git a/fcrepo-camel-toolbox-app/pom.xml b/fcrepo-camel-toolbox-app/pom.xml index 27f1d1ce..9665fb15 100644 --- a/fcrepo-camel-toolbox-app/pom.xml +++ b/fcrepo-camel-toolbox-app/pom.xml @@ -3,7 +3,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 4.0.0 @@ -111,7 +111,7 @@ true driver - + org.fcrepo.camel.toolbox.app.Driver diff --git a/fcrepo-fixity/pom.xml b/fcrepo-fixity/pom.xml index 1559abac..43088520 100644 --- a/fcrepo-fixity/pom.xml +++ b/fcrepo-fixity/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-fixity diff --git a/fcrepo-http-forwarding/pom.xml b/fcrepo-http-forwarding/pom.xml index fa08626d..a8856ded 100644 --- a/fcrepo-http-forwarding/pom.xml +++ b/fcrepo-http-forwarding/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-http-forwarding diff --git a/fcrepo-indexing-solr/pom.xml b/fcrepo-indexing-solr/pom.xml index e42f37c7..45af4bd4 100644 --- a/fcrepo-indexing-solr/pom.xml +++ b/fcrepo-indexing-solr/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-indexing-solr diff --git a/fcrepo-indexing-triplestore/pom.xml b/fcrepo-indexing-triplestore/pom.xml index 217f478d..d31f8b8c 100644 --- a/fcrepo-indexing-triplestore/pom.xml +++ b/fcrepo-indexing-triplestore/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-indexing-triplestore diff --git a/fcrepo-reindexing/pom.xml b/fcrepo-reindexing/pom.xml index 63fea702..6aee05a1 100644 --- a/fcrepo-reindexing/pom.xml +++ b/fcrepo-reindexing/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-reindexing diff --git a/fcrepo-service-activemq/pom.xml b/fcrepo-service-activemq/pom.xml index 1a25123b..0c57df72 100644 --- a/fcrepo-service-activemq/pom.xml +++ b/fcrepo-service-activemq/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-service-activemq diff --git a/fcrepo-service-camel/pom.xml b/fcrepo-service-camel/pom.xml index e6e658c7..4203dda8 100644 --- a/fcrepo-service-camel/pom.xml +++ b/fcrepo-service-camel/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0-SNAPSHOT + 6.1.0 fcrepo-service-camel diff --git a/pom.xml b/pom.xml index 15003ddb..c84ee950 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.fcrepo.camel fcrepo-camel-toolbox pom - 6.1.0-SNAPSHOT + 6.1.0 Fedora Camel Workflows A collection of camel-based event-driven workflows @@ -633,6 +633,6 @@ scm:git:git://github.com/fcrepo-exts/fcrepo-camel-toolbox.git scm:git:git@github.com:fcrepo-exts/fcrepo-camel-toolbox.git https://github.com/fcrepo-exts/fcrepo-camel-toolbox - HEAD + fcrepo-camel-toolbox-6.1.0 From c6f5467ba430b44f960e1c5ea59bf05d83d44df3 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 1 Mar 2024 14:50:15 +0000 Subject: [PATCH 05/10] [maven-release-plugin] prepare for next development iteration --- fcrepo-audit-triplestore/pom.xml | 2 +- fcrepo-camel-common/pom.xml | 2 +- fcrepo-camel-toolbox-app/pom.xml | 2 +- fcrepo-fixity/pom.xml | 2 +- fcrepo-http-forwarding/pom.xml | 2 +- fcrepo-indexing-solr/pom.xml | 2 +- fcrepo-indexing-triplestore/pom.xml | 2 +- fcrepo-reindexing/pom.xml | 2 +- fcrepo-service-activemq/pom.xml | 2 +- fcrepo-service-camel/pom.xml | 2 +- pom.xml | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fcrepo-audit-triplestore/pom.xml b/fcrepo-audit-triplestore/pom.xml index 567f9f6c..e63df856 100644 --- a/fcrepo-audit-triplestore/pom.xml +++ b/fcrepo-audit-triplestore/pom.xml @@ -6,7 +6,7 @@ org.fcrepo.camel fcrepo-camel-toolbox - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-audit-triplestore diff --git a/fcrepo-camel-common/pom.xml b/fcrepo-camel-common/pom.xml index da51043d..d6c3f454 100644 --- a/fcrepo-camel-common/pom.xml +++ b/fcrepo-camel-common/pom.xml @@ -3,7 +3,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT 4.0.0 diff --git a/fcrepo-camel-toolbox-app/pom.xml b/fcrepo-camel-toolbox-app/pom.xml index 9665fb15..f18503c0 100644 --- a/fcrepo-camel-toolbox-app/pom.xml +++ b/fcrepo-camel-toolbox-app/pom.xml @@ -3,7 +3,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT 4.0.0 diff --git a/fcrepo-fixity/pom.xml b/fcrepo-fixity/pom.xml index 43088520..e338fd34 100644 --- a/fcrepo-fixity/pom.xml +++ b/fcrepo-fixity/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-fixity diff --git a/fcrepo-http-forwarding/pom.xml b/fcrepo-http-forwarding/pom.xml index a8856ded..c9a9a3c7 100644 --- a/fcrepo-http-forwarding/pom.xml +++ b/fcrepo-http-forwarding/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-http-forwarding diff --git a/fcrepo-indexing-solr/pom.xml b/fcrepo-indexing-solr/pom.xml index 45af4bd4..ce3c6485 100644 --- a/fcrepo-indexing-solr/pom.xml +++ b/fcrepo-indexing-solr/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-indexing-solr diff --git a/fcrepo-indexing-triplestore/pom.xml b/fcrepo-indexing-triplestore/pom.xml index d31f8b8c..4c7805b6 100644 --- a/fcrepo-indexing-triplestore/pom.xml +++ b/fcrepo-indexing-triplestore/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-indexing-triplestore diff --git a/fcrepo-reindexing/pom.xml b/fcrepo-reindexing/pom.xml index 6aee05a1..082abee7 100644 --- a/fcrepo-reindexing/pom.xml +++ b/fcrepo-reindexing/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-reindexing diff --git a/fcrepo-service-activemq/pom.xml b/fcrepo-service-activemq/pom.xml index 0c57df72..2e45388c 100644 --- a/fcrepo-service-activemq/pom.xml +++ b/fcrepo-service-activemq/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-service-activemq diff --git a/fcrepo-service-camel/pom.xml b/fcrepo-service-camel/pom.xml index 4203dda8..c80761c5 100644 --- a/fcrepo-service-camel/pom.xml +++ b/fcrepo-service-camel/pom.xml @@ -6,7 +6,7 @@ fcrepo-camel-toolbox org.fcrepo.camel - 6.1.0 + 6.2.0-SNAPSHOT fcrepo-service-camel diff --git a/pom.xml b/pom.xml index c84ee950..4485d199 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.fcrepo.camel fcrepo-camel-toolbox pom - 6.1.0 + 6.2.0-SNAPSHOT Fedora Camel Workflows A collection of camel-based event-driven workflows @@ -633,6 +633,6 @@ scm:git:git://github.com/fcrepo-exts/fcrepo-camel-toolbox.git scm:git:git@github.com:fcrepo-exts/fcrepo-camel-toolbox.git https://github.com/fcrepo-exts/fcrepo-camel-toolbox - fcrepo-camel-toolbox-6.1.0 + HEAD From 40041f9476a30bcd9cb300577a3ddb2568125a9a Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Thu, 23 May 2024 13:44:44 -0500 Subject: [PATCH 06/10] Stop using onSpinWait (#203) Alters Thread.onSpinWait to use latch and await to avoid using CPU cycles to wait. Also adds additional debug/trace logging to Solr route Adds the default transform as the default on the property for Solr indexing Adds some additional documentation on Solr indexing. --- README.md | 32 +++++++++++++------ .../org/fcrepo/camel/toolbox/app/Driver.java | 17 +++++++--- .../solr/FcrepoSolrIndexingConfig.java | 2 +- .../camel/indexing/solr/SolrRouter.java | 26 ++++++++++----- .../fcrepo/camel/indexing/solr/RouteTest.java | 10 +++--- 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index c17330b4..ffadb085 100644 --- a/README.md +++ b/README.md @@ -124,17 +124,29 @@ This application listens to Fedora's event stream and indexes objects into an external Solr server. #### Properties -| Name | Description| Default Value | -| :--- | :---| :---- | +| Name | Description | Default Value | +| :--- |:---| :---- | | solr.indexing.enabled | Enables/disables the SOLR indexing service. Disabled by default | false | -| solr.fcrepo.checkHasIndexingTransformation | When true, check for an indexing transform in the resource matadata. | true | -| solr.fcrepo.defaultTransform | The solr default XSL transform when none is provide in resource metadata. | null | -| solr.input.stream | The JMS topic or queue serving as the message source | broker:topic:fedora | -| solr.reindex.stream | The JMS topic or queue serving as the reindex message source | broker:queue:solr.reindex | -| solr.commitWithin | Milliseconds within which commits should occur | 10000 | -| solr.indexing.predicate | When true, check that resource is of type http://fedora.info/definitions/v4/indexing#Indexable; otherwise do not index it. | false | -| solr.filter.containers | A comma-separate list of containers that should be ignored by the indexer | http://localhost:8080/fcrepo/rest/audit | - +| solr.fcrepo.checkHasIndexingTransformation | When true, check for an indexing transform in the resource metadata with the predicate http://fedora.info/definitions/v4/indexing#hasIndexingTransformation | true | +| solr.fcrepo.defaultTransform | The solr default XSL transform when none is provide in resource metadata. | null | +| solr.input.stream | The JMS topic or queue serving as the message source | broker:topic:fedora | +| solr.reindex.stream | The JMS topic or queue serving as the reindex message source | broker:queue:solr.reindex | +| solr.commitWithin | Milliseconds within which commits should occur | 10000 | +| solr.indexing.predicate | When true, check that resource is of type http://fedora.info/definitions/v4/indexing#Indexable; otherwise do not index it.| false | +| solr.filter.containers | A comma-separate list of containers that should be ignored by the indexer| http://localhost:8080/fcrepo/rest/audit | + +**Note**: You must start with the `file://` protocol when defining the path to a custom XSLT for either the `solr.fcrepo.defaultTransform` +or within the resource using the `http://fedora.info/definitions/v4/indexing#hasIndexingTransformation` predicate. + +For example, +```text +solr.fcrepo.defaultTransform=file:///path/to/your/transform.xsl +``` +or +```text +@prefix indexing: . +<> indexing:hasIndexingTransformation . +``` ### Repository Indexer (Triplestore) diff --git a/fcrepo-camel-toolbox-app/src/main/java/org/fcrepo/camel/toolbox/app/Driver.java b/fcrepo-camel-toolbox-app/src/main/java/org/fcrepo/camel/toolbox/app/Driver.java index 4f2c4eca..bdd0cc0f 100644 --- a/fcrepo-camel-toolbox-app/src/main/java/org/fcrepo/camel/toolbox/app/Driver.java +++ b/fcrepo-camel-toolbox-app/src/main/java/org/fcrepo/camel/toolbox/app/Driver.java @@ -12,6 +12,7 @@ import java.nio.file.Path; import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; import static org.fcrepo.camel.common.config.BasePropsConfig.FCREPO_CAMEL_CONFIG_FILE_PROPERTY; import static org.slf4j.LoggerFactory.getLogger; @@ -42,12 +43,20 @@ public Integer call() { System.setProperty(FCREPO_CAMEL_CONFIG_FILE_PROPERTY, configurationFilePath.toFile().getAbsolutePath()); } final var appContext = new AnnotationConfigApplicationContext("org.fcrepo.camel"); - appContext.registerShutdownHook(); + final var countdownLatch = new CountDownLatch(1); + + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + LOGGER.info("Shutting down fcrepo-camel-toolbox..."); + appContext.stop(); + countdownLatch.countDown(); + })); appContext.start(); LOGGER.info("fcrepo-camel-toolbox started."); - - while (appContext.isRunning()) { - Thread.onSpinWait(); + try { + countdownLatch.await(); + } catch (final InterruptedException e) { + // Ignore error because we are exiting anyways. + return 1; } return 0; } diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java index d2c520d4..d2c09903 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java @@ -37,7 +37,7 @@ static class SolrIndexingEnabled extends ConditionOnPropertyTrue { @Value("${solr.fcrepo.checkHasIndexingTransformation:true}") private boolean checkHasIndexingTransformation; - @Value("${solr.fcrepo.defaultTransform:}") + @Value("${solr.fcrepo.defaultTransform:org/fcrepo/camel/indexing/solr/default_transform.xsl}") private String defaultTransform; @Value("${solr.input.stream:broker:topic:fedora}") diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index dd2c0cf0..3543d1f4 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -53,6 +53,13 @@ public class SolrRouter extends RouteBuilder { */ public void configure() throws Exception { + logger.debug("Solr Router starting..."); + logger.trace("solr.indexing.predicate = '{}'", config.isIndexingPredicate()); + logger.trace("solr.checkHasIndexingTransformation = '{}'", config.isCheckHasIndexingTransformation()); + logger.trace("solr.defaultTransform = '{}'", config.getDefaultTransform()); + logger.trace("solr.input.stream = '{}'", config.getInputStream()); + logger.trace("solr.baseUrl = '{}'", config.getSolrBaseUrl()); + 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#"); ns.add("ldp", "http://www.w3.org/ns/ldp#"); @@ -100,9 +107,10 @@ public void configure() throws Exception { header(FCREPO_URI).isEqualTo(constant(uri)))) .collect(toList())))) .choice() - .when(and(simple(config.isIndexingPredicate() + " != 'true'"), - simple(config.isCheckHasIndexingTransformation() + " != 'true'"))) + .when(and(not(constant(config.isIndexingPredicate())), + not(constant(config.isCheckHasIndexingTransformation())))) .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()) + .log(LoggingLevel.TRACE, "Indexing Transformation set to: ${header.CamelIndexingTransformation}") .log(LoggingLevel.INFO, "sending to update_solr") .to("direct:update.solr") .otherwise() @@ -111,13 +119,17 @@ public void configure() throws Exception { + "?preferOmit=PreferContainment&accept=application/rdf+xml" ) .setHeader(INDEXING_TRANSFORMATION).xpath(hasIndexingTransformation, String.class, ns) + .log(LoggingLevel.TRACE, logger, "Indexing Transformation: ${header.CamelIndexingTransformation}") .choice() .when(or(header(INDEXING_TRANSFORMATION).isNull(), header(INDEXING_TRANSFORMATION).isEqualTo(""))) - .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()).end() + .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()) + .log(LoggingLevel.TRACE, logger, "No indexing transform found on the resource, using " + + "default transform: ${header.CamelIndexingTransformation}") + .end() .removeHeaders("CamelHttp*") .choice() - .when(or(simple(config.isIndexingPredicate() + " != 'true'"), + .when(or(not(constant(config.isIndexingPredicate())), header(FCREPO_RESOURCE_TYPE).contains(INDEXABLE))) .to("direct:update.solr") .otherwise() @@ -146,14 +158,12 @@ public void configure() throws Exception { // Don't index the transformation itself .filter().simple("${header.CamelIndexingTransformation} != ${header.CamelIndexingUri}") .choice() - .when(header(INDEXING_TRANSFORMATION).isNotNull()) + .when(and(header(INDEXING_TRANSFORMATION).isNotNull(), + header(INDEXING_TRANSFORMATION).isNotEqualTo(""))) .log(LoggingLevel.INFO, logger, "Sending RDF for Transform with with XSLT from ${header.CamelIndexingTransformation}") .toD("xslt:${header.CamelIndexingTransformation}") .to("direct:send.to.solr") - .when(or(header(INDEXING_TRANSFORMATION).isNull(), header(INDEXING_TRANSFORMATION).isEqualTo(""))) - .log(LoggingLevel.INFO, logger,"No Transform supplied") - .to("direct:send.to.solr") .otherwise() .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}"); diff --git a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java index 799160c9..4249c8db 100644 --- a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java +++ b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java @@ -263,8 +263,7 @@ public void testUpdateRouter() throws Exception { final var context = camelContext.adapt(ModelCamelContext.class); AdviceWith.adviceWith(context, "FcrepoSolrUpdater", a -> { - a.mockEndpointsAndSkip("fcrepo*"); - a.mockEndpointsAndSkip("http4*"); + a.mockEndpointsAndSkip("xslt:*"); }); AdviceWith.adviceWith(context, "FcrepoSolrSend", a -> { @@ -275,8 +274,11 @@ public void testUpdateRouter() throws Exception { solrUpdateEndPoint.expectedMessageCount(1); solrUpdateEndPoint.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST"); - template.sendBodyAndHeaders("direct:update.solr", "", - createEvent(baseURL + fileID, eventTypes)); + final var headers = createEvent(baseURL + fileID, eventTypes); + // Need to add the header as it is set in FcrepoSolrIndexer + headers.put("CamelIndexingTransformation", "org/fcrepo/camel/indexing/solr/default_transform.xsl"); + + template.sendBodyAndHeaders( "direct:update.solr", "", headers); MockEndpoint.assertIsSatisfied(solrUpdateEndPoint); } From 5250db99ec50571a6a009d24e94fade60248403f Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 23 Jul 2024 15:09:51 +0100 Subject: [PATCH 07/10] Alterations at Jared's request on PR --- .../org/fcrepo/camel/indexing/solr/SolrRouter.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 19d7eb59..352065a4 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -8,13 +8,10 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.support.builder.Namespaces; -import org.apache.camel.builder.PredicateBuilder; -import org.apache.camel.Predicate; import org.fcrepo.camel.processor.EventProcessor; import org.fcrepo.camel.common.processor.AddBasicAuthProcessor; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.apache.commons.lang3.StringUtils; import static java.util.stream.Collectors.toList; import static org.apache.camel.Exchange.CONTENT_TYPE; import static org.apache.camel.Exchange.HTTP_METHOD; @@ -63,8 +60,6 @@ public void configure() throws Exception { final String solrUsername = config.getSolrUsername(); final String solrPassword = config.getSolrPassword(); - final Predicate useSolrAuth = PredicateBuilder.constant( - "true".equals(!StringUtils.isEmpty(solrUsername) && !StringUtils.isEmpty(solrPassword))); /* * A generic error handler (specific to this RouteBuilder) */ @@ -187,12 +182,8 @@ public void configure() throws Exception { .removeHeaders("CamelHttp*") .setHeader(HTTP_METHOD).constant("POST") .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) - .choice() - .when(useSolrAuth) - .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) - .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) - .otherwise() - .log(LoggingLevel.DEBUG, logger, "No Solr Auth provided") + .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) + .log(LoggingLevel.DEBUG, logger, "Authenticating to solr with user: " + solrUsername ) .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); } From b356b31c3f6e08cf42ce61b00451d3d115cce024 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 13 Feb 2024 11:57:49 +0000 Subject: [PATCH 08/10] Initial commit of solr basic auth functionality --- README.md | 3 +++ .../solr/FcrepoSolrIndexingConfig.java | 13 +++++++++++ .../camel/indexing/solr/SolrRouter.java | 22 +++++++++++++++---- .../fcrepo/camel/indexing/solr/RouteTest.java | 2 ++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ffadb085..2da69504 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,9 @@ indexes objects into an external Solr server. | solr.commitWithin | Milliseconds within which commits should occur | 10000 | | solr.indexing.predicate | When true, check that resource is of type http://fedora.info/definitions/v4/indexing#Indexable; otherwise do not index it.| false | | solr.filter.containers | A comma-separate list of containers that should be ignored by the indexer| http://localhost:8080/fcrepo/rest/audit | +| solr.username | Optional username for a Solr server protected with Basic Auth. Must be used in combination with solr.password | | +| solr.password | Optional password for a Solr server protected with Basic Auth. Must be used in combination with solr.username | | + **Note**: You must start with the `file://` protocol when defining the path to a custom XSLT for either the `solr.fcrepo.defaultTransform` or within the resource using the `http://fedora.info/definitions/v4/indexing#hasIndexingTransformation` predicate. diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java index d2c09903..e5113478 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/FcrepoSolrIndexingConfig.java @@ -58,6 +58,12 @@ static class SolrIndexingEnabled extends ConditionOnPropertyTrue { @Value("${solr.baseUrl:http://localhost:8983/solr/collection1}") private String solrBaseUrl; + @Value("${solr.username:}") + private String solrUsername; + + @Value("${solr.password:}") + private String solrPassword; + public boolean isCheckHasIndexingTransformation() { return checkHasIndexingTransformation; } @@ -90,6 +96,13 @@ public String getSolrBaseUrl() { return solrBaseUrl; } + public String getSolrUsername() { + return solrUsername; + } + + public String getSolrPassword() { + return solrPassword; + } @Bean(name = "http") public HttpComponent http() { diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 3543d1f4..2cef9c88 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -8,10 +8,13 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.support.builder.Namespaces; +import org.apache.camel.builder.PredicateBuilder; +import org.apache.camel.Predicate; import org.fcrepo.camel.processor.EventProcessor; +import org.fcrepo.camel.common.processor.AddBasicAuthProcessor; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; - +import org.apache.commons.lang3.StringUtils; import static java.util.stream.Collectors.toList; import static org.apache.camel.Exchange.CONTENT_TYPE; import static org.apache.camel.Exchange.HTTP_METHOD; @@ -64,7 +67,10 @@ public void configure() throws Exception { ns.add("indexing", "http://fedora.info/definitions/v4/indexing#"); ns.add("ldp", "http://www.w3.org/ns/ldp#"); - + final String solrUsername = config.getSolrUsername(); + final String solrPassword = config.getSolrPassword(); + final Predicate useSolrAuth = PredicateBuilder.constant( + "true".equals(!StringUtils.isEmpty(solrUsername) && !StringUtils.isEmpty(solrPassword))); /* * A generic error handler (specific to this RouteBuilder) */ @@ -80,8 +86,8 @@ public void configure() throws Exception { .routeId("FcrepoSolrRouter") .process(new EventProcessor()) .choice() - .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION), - header(FCREPO_EVENT_TYPE).contains(DELETE))) + .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION), + header(FCREPO_EVENT_TYPE).contains(DELETE))) .log(LoggingLevel.TRACE, "Received message from Fedora routing to delete.solr") .to("direct:delete.solr") .otherwise() @@ -107,6 +113,7 @@ public void configure() throws Exception { header(FCREPO_URI).isEqualTo(constant(uri)))) .collect(toList())))) .choice() +<<<<<<< HEAD .when(and(not(constant(config.isIndexingPredicate())), not(constant(config.isCheckHasIndexingTransformation())))) .setHeader(INDEXING_TRANSFORMATION).simple(config.getDefaultTransform()) @@ -167,6 +174,7 @@ public void configure() throws Exception { .otherwise() .log(LoggingLevel.INFO, logger, "Skipping ${header.CamelFcrepoUri}"); + /* * Send the transformed resource to Solr */ @@ -176,6 +184,12 @@ public void configure() throws Exception { .setHeader(CONTENT_TYPE).constant("text/xml") .setHeader(HTTP_METHOD).constant("POST") .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) + .choice() + .when(useSolrAuth) + .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) + .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) + .otherwise() + .log(LoggingLevel.INFO, logger, "No Solr Auth provided") .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); } diff --git a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java index 4249c8db..44f62467 100644 --- a/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java +++ b/fcrepo-indexing-solr/src/test/java/org/fcrepo/camel/indexing/solr/RouteTest.java @@ -81,6 +81,8 @@ public static void beforeClass() { System.setProperty("solr.baseUrl", solrURL); System.setProperty("solr.reindex.stream", "seda:reindex"); System.setProperty("solr.fcrepo.checkHasIndexingTransformation", "true"); + System.setProperty("solr.username", "solr"); + System.setProperty("solr.password", "solrRocks"); } From 44709f8dba70688208f8cfe18847e13fc0e3d31a Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 15 Feb 2024 13:00:46 +0000 Subject: [PATCH 09/10] reducing log level of solr indexer when using auth --- .../main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 2cef9c88..07ed453f 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -189,7 +189,7 @@ public void configure() throws Exception { .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) .otherwise() - .log(LoggingLevel.INFO, logger, "No Solr Auth provided") + .log(LoggingLevel.DEBUG, logger, "No Solr Auth provided") .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); } From 6512ebfc6fd421ed84296741b3d796e7391e4891 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 23 Jul 2024 15:09:51 +0100 Subject: [PATCH 10/10] Alterations at Jared's request on PR --- .../org/fcrepo/camel/indexing/solr/SolrRouter.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java index 07ed453f..99821caa 100644 --- a/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java +++ b/fcrepo-indexing-solr/src/main/java/org/fcrepo/camel/indexing/solr/SolrRouter.java @@ -8,13 +8,10 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.support.builder.Namespaces; -import org.apache.camel.builder.PredicateBuilder; -import org.apache.camel.Predicate; import org.fcrepo.camel.processor.EventProcessor; import org.fcrepo.camel.common.processor.AddBasicAuthProcessor; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.apache.commons.lang3.StringUtils; import static java.util.stream.Collectors.toList; import static org.apache.camel.Exchange.CONTENT_TYPE; import static org.apache.camel.Exchange.HTTP_METHOD; @@ -69,8 +66,6 @@ public void configure() throws Exception { final String solrUsername = config.getSolrUsername(); final String solrPassword = config.getSolrPassword(); - final Predicate useSolrAuth = PredicateBuilder.constant( - "true".equals(!StringUtils.isEmpty(solrUsername) && !StringUtils.isEmpty(solrPassword))); /* * A generic error handler (specific to this RouteBuilder) */ @@ -184,12 +179,8 @@ public void configure() throws Exception { .setHeader(CONTENT_TYPE).constant("text/xml") .setHeader(HTTP_METHOD).constant("POST") .setHeader(HTTP_QUERY).simple("commitWithin=" + config.getCommitWithin()) - .choice() - .when(useSolrAuth) - .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) - .log(LoggingLevel.DEBUG, logger, "Authenticating solr with: " + solrUsername + ":" + solrPassword) - .otherwise() - .log(LoggingLevel.DEBUG, logger, "No Solr Auth provided") + .process(new AddBasicAuthProcessor(solrUsername, solrPassword)) + .log(LoggingLevel.DEBUG, logger, "Authenticating to solr with user: " + solrUsername ) .to(config.getSolrBaseUrl() + "/update?useSystemProperties=true"); }