From 92df03f61fabe30ac264e769578ed3f386949b03 Mon Sep 17 00:00:00 2001 From: nruest Date: Mon, 3 May 2021 14:39:13 -0400 Subject: [PATCH] Remove calls to Gemini and file.stream. - Best GitHub issue would be: https://github.com/Islandora-Devops/isle-dc/pull/132 --- .gitignore | 2 + .../ca.islandora.alpaca.indexing.fcrepo.cfg | 2 - .../alpaca/indexing/fcrepo/FcrepoIndexer.java | 50 +------------------ .../OSGI-INF/blueprint/blueprint.xml | 2 - .../indexing/fcrepo/FcrepoIndexerTest.java | 40 --------------- .../OSGI-INF/blueprint/blueprint-test.xml | 2 - 6 files changed, 3 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index 3e70575a..168c02e0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ target build .DS_Store bin/ +.bloop/ +.metals/ 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 9b3d5443..f27351a5 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 @@ -5,9 +5,7 @@ error.maxRedeliveries=5 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.external.stream=activemq:queue:islandora-indexing-fcrepo-file-external # Base url for microservices milliner.baseUrl=http://localhost:8000/milliner/ -gemini.baseUrl=http://localhost:8000/gemini/ 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 7d261828..e1d05437 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 @@ -57,12 +57,6 @@ public class FcrepoIndexer extends RouteBuilder { @PropertyInject("milliner.baseUrl") private String millinerBaseUrl; - /** - * Base URI of the Gemini web service. - */ - @PropertyInject("gemini.baseUrl") - private String geminiBaseUrl; - /** * The Logger. */ @@ -96,20 +90,6 @@ public void setMillinerBaseUrl(final String millinerBaseUrl) { this.millinerBaseUrl = millinerBaseUrl; } - /** - * @return Gemini base url - */ - public String getGeminiBaseUrl() { - return enforceTrailingSlash(geminiBaseUrl); - } - - /** - * @param geminiBaseUrl Gemini base url - */ - public void setGeminiBaseUrl(final String geminiBaseUrl) { - this.geminiBaseUrl = geminiBaseUrl; - } - private String enforceTrailingSlash(final String baseUrl) { final String trimmed = baseUrl.trim(); return trimmed.endsWith("/") ? trimmed : trimmed + "/"; @@ -201,7 +181,7 @@ public void configure() { .setHeader(FEDORA_HEADER, exchangeProperty("fedoraBaseUrl")) .setBody(simple("${null}")) - // Remove the file from Gemini. + // Remove the file from Drupal. .toD(getMillinerBaseUrl() + "node/${exchangeProperty.uuid}?connectionClose=true"); from("{{media.stream}}") @@ -239,34 +219,6 @@ public void configure() { "media/${exchangeProperty.sourceField}/version?connectionClose=true" ).endChoice(); - from("{{file.stream}}") - .routeId("FcrepoIndexerFile") - - // Parse the event into a POJO. - .unmarshal().json(JsonLibrary.Jackson, AS2Event.class) - - // 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}") - .setProperty("fedora").simple("${exchangeProperty.event.attachment.content.fedoraUri}") - .setProperty("fedoraBaseUrl").simple("${exchangeProperty.event.target}") - .log(DEBUG, LOGGER, "Received File event for UUID (${exchangeProperty.uuid}), drupal URL (" + - "${exchangeProperty.drupal}), fedoraURL (${exchangeProperty.fedora}), fedora base URL " + - "(${exchangeProperty.fedoraBaseUrl})") - - // Prepare the message. - .removeHeaders("*", "Authorization") - .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) - .setHeader(Exchange.HTTP_METHOD, constant("PUT")) - .setHeader(FEDORA_HEADER, exchangeProperty("fedoraBaseUrl")) - .setBody(simple( - "{\"drupal\": \"${exchangeProperty.drupal}\", \"fedora\": \"${exchangeProperty.fedora}\"}") - ) - - // Index the file in Gemini. - .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}?connectionClose=true"); - from("{{file.external.stream}}") .routeId("FcrepoIndexerExternalFile") 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 eac34acc..e392f497 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 @@ -13,11 +13,9 @@ - - 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 d918d63f..775c0e9d 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 @@ -159,46 +159,6 @@ public void configure() throws Exception { assertMockEndpointsSatisfied(); } - @Test - public void testFile() throws Exception { - final String route = "FcrepoIndexerFile"; - 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" - ); - } - }); - context.start(); - - // Assert we PUT to gemini with creds. - final MockEndpoint gemini = getMockEndpoint( - "mock:http:localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f" - ); - gemini.expectedMessageCount(1); - gemini.expectedHeaderReceived("Authorization", "Bearer islandora"); - gemini.expectedHeaderReceived(Exchange.CONTENT_TYPE, "application/json"); - gemini.expectedHeaderReceived(Exchange.HTTP_METHOD, "PUT"); - gemini.expectedHeaderReceived(FcrepoIndexer.FEDORA_HEADER, "http://localhost:8080/fcrepo/rest/file"); - gemini.allMessages().body().startsWith( - "{\"drupal\": \"http://localhost:8000/_flysystem/fedora/2018-08/Voltaire-Records1.jpg\", \"fedora\": " + - "\"http://localhost:8080/fcrepo/rest/2018-08/Voltaire-Records1.jpg\"}" - ); - - // Send an event. - template.send(exchange -> { - exchange.getIn().setHeader("Authorization", "Bearer islandora"); - exchange.getIn().setBody( - IOUtils.toString(loadResourceAsStream("FileAS2Event.jsonld"), "UTF-8"), - String.class - ); - }); - - assertMockEndpointsSatisfied(); - } - @Test public void testExternalFile() throws Exception { final String route = "FcrepoIndexerExternalFile"; 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 ee0a2d47..07627978 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 @@ -13,11 +13,9 @@ - -