Skip to content

Commit

Permalink
External content (#59)
Browse files Browse the repository at this point in the history
* Bumping versions for 5.0.0 support
* First pass at external content
* Updating tests
  • Loading branch information
dannylamb authored and seth-shaw-unlv committed Apr 30, 2019
1 parent 1561f04 commit ddebb2e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 22 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,25 @@ 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)

// 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");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<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.delete.stream" value="activemq:queue:islandora-indexing-fcrepo-file-delete"/>
<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/"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<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.delete.stream" value="seda:islandora-indexing-fcrepo-file-delete"/>
<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/"/>
Expand Down
2 changes: 1 addition & 1 deletion islandora-indexing-triplestore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down

0 comments on commit ddebb2e

Please sign in to comment.