Skip to content

Commit

Permalink
Remove calls to Gemini and file.stream.
Browse files Browse the repository at this point in the history
- Best GitHub issue would be: Islandora-Devops/isle-dc#132
  • Loading branch information
ruebot committed May 3, 2021
1 parent 762a433 commit 92df03f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 95 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ target
build
.DS_Store
bin/
.bloop/
.metals/
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 + "/";
Expand Down Expand Up @@ -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}}")
Expand Down Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
<cm:property name="error.maxRedeliveries" value="5"/>
<cm:property name="node.stream" value="activemq:queue:islandora-indexing-fcrepo-content"/>
<cm:property name="node.delete.stream" value="activemq:queue:islandora-indexing-fcrepo-delete"/>
<cm:property name="file.stream" value="activemq:queue:islandora-indexing-fcrepo-file"/>
<cm:property name="file.external.stream" value="activemq:queue:islandora-indexing-fcrepo-file-external"/>
<cm:property name="media.stream" value="activemq:queue:islandora-indexing-fcrepo-media"/>
<cm:property name="milliner.baseUrl" value="http://localhost:8000/milliner/"/>
<cm:property name="gemini.baseUrl" value="http://localhost:8000/gemini/"/>
</cm:default-properties>
</cm:property-placeholder>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
<cm:property name="error.maxRedeliveries" value="1"/>
<cm:property name="node.stream" value="seda:islandora-indexing-fcrepo-content"/>
<cm:property name="node.delete.stream" value="seda:islandora-indexing-fcrepo-delete"/>
<cm:property name="file.stream" value="seda:islandora-indexing-fcrepo-file"/>
<cm:property name="file.external.stream" value="seda:islandora-indexing-fcrepo-file-external"/>
<cm:property name="media.stream" value="seda:islandora-indexing-fcrepo-media"/>
<cm:property name="milliner.baseUrl" value="http://localhost:8000/milliner/"/>
<cm:property name="gemini.baseUrl" value="http://localhost:8000/gemini/"/>
</cm:default-properties>
</cm:property-placeholder>

Expand Down

0 comments on commit 92df03f

Please sign in to comment.