From 315a72376f29af640d43028df6178d1eff283f4a Mon Sep 17 00:00:00 2001 From: dannylamb Date: Thu, 11 Apr 2019 12:46:18 +0000 Subject: [PATCH 1/3] Bumping versions for 5.0.0 support --- build.gradle | 6 +++--- islandora-indexing-triplestore/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index ca1bcbc4..10767373 100644 --- a/build.gradle +++ b/build.gradle @@ -45,10 +45,10 @@ subprojects { docURL = 'http://github.com/Islandora-CLAW/wiki' license = 'MIT' - camelVersion = '2.19.2' + camelVersion = '2.20.4' slf4jVersion = '1.7.12' - fcrepoCamelVersion = '4.5.0' - fcrepoCamelToolboxVersion = '4.7.2' + fcrepoCamelVersion = '5.0.0' + fcrepoCamelToolboxVersion = '5.0.0' activemqVersion = '5.15.0' commonsIoVersion = '2.4' diff --git a/islandora-indexing-triplestore/build.gradle b/islandora-indexing-triplestore/build.gradle index cab27f33..43f51c0b 100644 --- a/islandora-indexing-triplestore/build.gradle +++ b/islandora-indexing-triplestore/build.gradle @@ -23,7 +23,7 @@ jar { instruction 'Import-Package', 'org.apache.camel.component.http4,' + "org.apache.camel;version=\"${camelVersion}\"," + - "org.fcrepo.camel.processor," + + "org.fcrepo.camel.processor;version=\"${fcrepoCamelVersion}\"," + defaultOsgiImports instruction 'Export-Package', 'ca.islandora.alpaca.indexing.triplestore' } From 2acfcbd10f70b432cf6d354b901d35944448655d Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 23 Apr 2019 16:50:39 +0000 Subject: [PATCH 2/3] First pass at external content --- .../main/cfg/ca.islandora.alpaca.indexing.fcrepo.cfg | 2 +- .../alpaca/indexing/fcrepo/FcrepoIndexer.java | 12 +++++++----- .../main/resources/OSGI-INF/blueprint/blueprint.xml | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/islandora-indexing-fcrepo/src/main/cfg/ca.islandora.alpaca.indexing.fcrepo.cfg b/islandora-indexing-fcrepo/src/main/cfg/ca.islandora.alpaca.indexing.fcrepo.cfg index 77e6bd15..9b3d5443 100644 --- a/islandora-indexing-fcrepo/src/main/cfg/ca.islandora.alpaca.indexing.fcrepo.cfg +++ b/islandora-indexing-fcrepo/src/main/cfg/ca.islandora.alpaca.indexing.fcrepo.cfg @@ -6,7 +6,7 @@ node.stream=activemq:queue:islandora-indexing-fcrepo-content node.delete.stream=activemq:queue:islandora-indexing-fcrepo-delete media.stream=activemq:queue:islandora-indexing-fcrepo-media file.stream=activemq:queue:islandora-indexing-fcrepo-file -file.delete.stream=activemq:queue:islandora-indexing-fcrepo-file-delete +file.external.stream=activemq:queue:islandora-indexing-fcrepo-file-external # Base url for microservices milliner.baseUrl=http://localhost:8000/milliner/ diff --git a/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java b/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java index 18adc7a1..c87864c1 100644 --- a/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java +++ b/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java @@ -209,8 +209,8 @@ public void configure() { // Index the file in Gemini. .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}?connectionClose=true"); - from("{{file.delete.stream}}") - .routeId("FcrepoIndexerFileDelete") + from("{{file.external.stream}}") + .routeId("FcrepoIndexerExternalFile") // Parse the event into a POJO. .unmarshal().json(JsonLibrary.Jackson, AS2Event.class) @@ -218,14 +218,16 @@ public void configure() { // Extract relevant data from the event. .setProperty("event").simple("${body}") .setProperty("uuid").simple("${exchangeProperty.event.object.id.replaceAll(\"urn:uuid:\",\"\")}") + .setProperty("drupal").simple("${exchangeProperty.event.object.url[0].href}") // Prepare the message. .removeHeaders("*", "Authorization") - .setHeader(Exchange.HTTP_METHOD, constant("DELETE")) + .setHeader(Exchange.HTTP_METHOD, constant("POST")) + .setHeader("Content-Location", simple("${exchangeProperty.drupal}")) .setBody(simple("${null}")) - // Remove the file from Gemini. - .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}?connectionClose=true"); + // Pass it to milliner. + .toD(getMillinerBaseUrl() + "external/${exchangeProperty.uuid}?connectionClose=true"); } } diff --git a/islandora-indexing-fcrepo/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/islandora-indexing-fcrepo/src/main/resources/OSGI-INF/blueprint/blueprint.xml index 1f83fc16..eac34acc 100644 --- a/islandora-indexing-fcrepo/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/islandora-indexing-fcrepo/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -14,7 +14,7 @@ - + From 8f3f02f9b180f2eb02f64b4ffc14a737dc5a72da Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 23 Apr 2019 18:33:49 +0000 Subject: [PATCH 3/3] Updating tests --- .../indexing/fcrepo/FcrepoIndexerTest.java | 24 +++++++------ .../resources/ExternalFileAS2Event.jsonld | 36 +++++++++++++++++++ .../OSGI-INF/blueprint/blueprint-test.xml | 2 +- 3 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 islandora-indexing-fcrepo/src/test/resources/ExternalFileAS2Event.jsonld diff --git a/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java b/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java index bbcad6c3..690a6c01 100644 --- a/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java +++ b/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java @@ -161,32 +161,36 @@ public void configure() throws Exception { } @Test - public void testFileDelet() throws Exception { - final String route = "FcrepoIndexerFileDelete"; + public void testExternalFile() throws Exception { + final String route = "FcrepoIndexerExternalFile"; context.getRouteDefinition(route).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith("direct:start"); mockEndpointsAndSkip( - "http://localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f?connectionClose=true" + "http://localhost:8000/milliner/external/148dfe8f-9711-4263-97e7-3ef3fb15864f?connectionClose=true" ); } }); context.start(); - // Assert we PUT to gemini with creds. - final MockEndpoint gemini = getMockEndpoint( - "mock:http:localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f" + // Assert we POST to Milliner with creds. + final MockEndpoint milliner = getMockEndpoint( + "mock:http:localhost:8000/milliner/external/148dfe8f-9711-4263-97e7-3ef3fb15864f" ); - gemini.expectedMessageCount(1); - gemini.expectedHeaderReceived("Authorization", "Bearer islandora"); - gemini.expectedHeaderReceived(Exchange.HTTP_METHOD, "DELETE"); + milliner.expectedMessageCount(1); + milliner.expectedHeaderReceived("Authorization", "Bearer islandora"); + milliner.expectedHeaderReceived( + "Content-Location", + "http://localhost:8000/sites/default/files/2018-08/Voltaire-Records1.jpg" + ); + milliner.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST"); // Send an event. template.send(exchange -> { exchange.getIn().setHeader("Authorization", "Bearer islandora"); exchange.getIn().setBody( - IOUtils.toString(loadResourceAsStream("FileAS2Event.jsonld"), "UTF-8"), + IOUtils.toString(loadResourceAsStream("ExternalFileAS2Event.jsonld"), "UTF-8"), String.class ); }); diff --git a/islandora-indexing-fcrepo/src/test/resources/ExternalFileAS2Event.jsonld b/islandora-indexing-fcrepo/src/test/resources/ExternalFileAS2Event.jsonld new file mode 100644 index 00000000..a2f8380e --- /dev/null +++ b/islandora-indexing-fcrepo/src/test/resources/ExternalFileAS2Event.jsonld @@ -0,0 +1,36 @@ +{ + "@context":"https:\/\/www.w3.org\/ns\/activitystreams", + "actor":{ + "type":"Person", + "id":"urn:uuid:9029a0c0-d845-4ddd-864c-2198d45839da", + "url":[ + { + "name":"Canonical", + "type":"Link", + "href":"http:\/\/localhost:8000\/user\/1", + "mediaType":"text\/html", + "rel":"canonical" + } + ] + }, + "object":{ + "id":"urn:uuid:148dfe8f-9711-4263-97e7-3ef3fb15864f", + "url":[ + { + "name":"Canonical", + "type":"Link", + "href":"http:\/\/localhost:8000\/sites\/default\/files\/2018-08\/Voltaire-Records1.jpg", + "mediaType":"image\/jpeg", + "rel":"canonical" + } + ] + }, + "type":"Create", + "summary":"Create a File", + "attachment":{ + "type":"Object", + "content":{ + }, + "mediaType":"application\/json" + } +} diff --git a/islandora-indexing-fcrepo/src/test/resources/OSGI-INF/blueprint/blueprint-test.xml b/islandora-indexing-fcrepo/src/test/resources/OSGI-INF/blueprint/blueprint-test.xml index 41f1f5a1..ee0a2d47 100644 --- a/islandora-indexing-fcrepo/src/test/resources/OSGI-INF/blueprint/blueprint-test.xml +++ b/islandora-indexing-fcrepo/src/test/resources/OSGI-INF/blueprint/blueprint-test.xml @@ -14,7 +14,7 @@ - +