-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allowing 404s when deleting from Fedora * Houdini connector * Gutting it to work wtih the rest of the content modeling overhaul * Houdini connector tests * Working tests * Checkstyle
- Loading branch information
Showing
17 changed files
with
930 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apply plugin: 'osgi' | ||
|
||
description = 'Islandora CLAW Houdini Connector' | ||
|
||
dependencies { | ||
compile group: 'commons-io', name: 'commons-io', version: commonsIoVersion | ||
compile group: 'org.apache.camel', name: 'camel-blueprint', version: camelVersion | ||
compile group: 'org.apache.camel', name: 'camel-core', version: camelVersion | ||
compile group: 'org.apache.camel', name: 'camel-jackson', version: camelVersion | ||
compile group: 'org.apache.camel', name: 'camel-http4', version: camelVersion | ||
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion | ||
testCompile group: 'org.apache.camel', name: 'camel-test-blueprint', version: camelVersion | ||
testCompile group: 'org.apache.servicemix.bundles', name: 'org.apache.servicemix.bundles.xerces', version: '2.11.0_1' | ||
testCompile group: 'org.ow2.asm', name: 'asm-commons', version: '5.0.3' | ||
} | ||
|
||
jar { | ||
manifest { | ||
description project.description | ||
docURL project.docURL | ||
vendor project.vendor | ||
license project.license | ||
|
||
instruction 'Import-Package', 'org.apache.camel.component.http4,' + | ||
"org.apache.camel;version=\"${camelVersion}\"," + | ||
defaultOsgiImports | ||
instruction 'Export-Package', 'ca.islandora.connector.houdini' | ||
} | ||
} | ||
|
||
artifacts { | ||
archives (file('build/cfg/main/ca.islandora.alpaca.connector.houdini.cfg')) { | ||
classifier 'configuration' | ||
type 'cfg' | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
islandora-connector-houdini/src/main/cfg/ca.islandora.alpaca.connector.houdini.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# In the event of failure, the maximum number of times a redelivery will be attempted. | ||
error.maxRedeliveries=10 | ||
|
||
# The camel URI for the incoming message stream. | ||
in.stream=activemq:queue:islandora-connector-houdini | ||
|
||
houdini.convert.url = http://localhost:8000/houdini/convert |
75 changes: 75 additions & 0 deletions
75
...nnector-houdini/src/main/java/ca/islandora/alpaca/connector/houdini/HoudiniConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to Islandora Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Islandora Foundation licenses this file to you under the MIT License. | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ca.islandora.alpaca.connector.houdini; | ||
|
||
import static org.apache.camel.LoggingLevel.ERROR; | ||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import ca.islandora.alpaca.connector.houdini.event.AS2Event; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.model.dataformat.JsonLibrary; | ||
import org.slf4j.Logger; | ||
|
||
/** | ||
* @author dhlamb | ||
*/ | ||
public class HoudiniConnector extends RouteBuilder { | ||
|
||
private static final Logger LOGGER = getLogger(HoudiniConnector.class); | ||
|
||
@Override | ||
public void configure() { | ||
// Global exception handler for the indexer. | ||
// Just logs after retrying X number of times. | ||
onException(Exception.class) | ||
.maximumRedeliveries("{{error.maxRedeliveries}}") | ||
.log( | ||
ERROR, | ||
LOGGER, | ||
"Error connecting generating derivative with Houdini: ${exception.message}\n\n${exception.stacktrace}" | ||
); | ||
|
||
from("{{in.stream}}") | ||
.routeId("IslandoraConnectorHoudini") | ||
|
||
// Parse the event into a POJO. | ||
.unmarshal().json(JsonLibrary.Jackson, AS2Event.class) | ||
|
||
// Stash the event on the exchange. | ||
.setProperty("event").simple("${body}") | ||
|
||
// Make the Crayfish request. | ||
.removeHeaders("*", "Authorization") | ||
.setHeader(Exchange.HTTP_METHOD, constant("GET")) | ||
.setHeader("Accept", simple("${exchangeProperty.event.attachment.content.mimetype}")) | ||
.setHeader("X-Islandora-Args", simple("${exchangeProperty.event.attachment.content.args}")) | ||
.setHeader("Apix-Ldp-Resource", simple("${exchangeProperty.event.attachment.content.sourceUri}")) | ||
.transform(simple("${null}")) | ||
.to("{{houdini.convert.url}}") | ||
|
||
// PUT the media. | ||
.removeHeaders("*", "Authorization", "Content-Type") | ||
.setHeader("Content-Disposition", | ||
simple("attachment; filename=\"${exchangeProperty.event.attachment.content.filename}\"")) | ||
.setHeader(Exchange.HTTP_METHOD, constant("PUT")) | ||
.toD("${exchangeProperty.event.attachment.content.destinationUri}"); | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
...connector-houdini/src/main/java/ca/islandora/alpaca/connector/houdini/event/AS2Actor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to Islandora Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Islandora Foundation licenses this file to you under the MIT License. | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ca.islandora.alpaca.connector.houdini.event; | ||
|
||
/** | ||
* POJO for a user performing an action. Part of a AS2Event. | ||
* | ||
* @author Danny Lamb | ||
*/ | ||
public class AS2Actor { | ||
|
||
/** | ||
* @return Type of user | ||
*/ | ||
public String getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* @param type Type of user | ||
*/ | ||
public void setType(final String type) { | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* @return URN of user | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* @param id URN of user | ||
*/ | ||
public void setId(final String id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* @return URL for user | ||
*/ | ||
public AS2Url[] getUrl() { | ||
return url; | ||
} | ||
|
||
/** | ||
* @param url URL for user | ||
*/ | ||
public void setUrl(final AS2Url[] url) { | ||
this.url = url; | ||
} | ||
|
||
private String type; | ||
private String id; | ||
private AS2Url[] url; | ||
|
||
} | ||
|
77 changes: 77 additions & 0 deletions
77
...ctor-houdini/src/main/java/ca/islandora/alpaca/connector/houdini/event/AS2Attachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to Islandora Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Islandora Foundation licenses this file to you under the MIT License. | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ca.islandora.alpaca.connector.houdini.event; | ||
|
||
/** | ||
* POJO for an attachment. Part of a AS2Event. | ||
* | ||
* @author Danny Lamb | ||
*/ | ||
public class AS2Attachment { | ||
|
||
/** | ||
* @return Type | ||
*/ | ||
public String getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* @param type Type | ||
*/ | ||
public void setType(final String type) { | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* @return Mimetype | ||
*/ | ||
public String getMediaType() { | ||
return mediaType; | ||
} | ||
|
||
/** | ||
* @param mediaType Mimetype | ||
*/ | ||
public void setMediaType(final String mediaType) { | ||
this.mediaType = mediaType; | ||
} | ||
|
||
/** | ||
* @return Content | ||
*/ | ||
public AS2AttachmentContent getContent() { | ||
return content; | ||
} | ||
|
||
/** | ||
* @param content Content | ||
*/ | ||
public void setContent(final AS2AttachmentContent content) { | ||
this.content = content; | ||
} | ||
|
||
private String type; | ||
private String mediaType; | ||
private AS2AttachmentContent content; | ||
|
||
} | ||
|
||
|
||
|
108 changes: 108 additions & 0 deletions
108
...udini/src/main/java/ca/islandora/alpaca/connector/houdini/event/AS2AttachmentContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Licensed to Islandora Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Islandora Foundation licenses this file to you under the MIT License. | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ca.islandora.alpaca.connector.houdini.event; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* POJO for attachment content. Part of a AS2Event. | ||
* | ||
* @author Danny Lamb | ||
*/ | ||
public class AS2AttachmentContent { | ||
|
||
/** | ||
* @return Source uri | ||
*/ | ||
@JsonProperty(value = "source_uri") | ||
public String getSourceUri() { | ||
return sourceUri; | ||
} | ||
|
||
/** | ||
* @param sourceUri Source uri | ||
*/ | ||
public void setSourceUri(final String sourceUri) { | ||
this.sourceUri = sourceUri; | ||
} | ||
|
||
/** | ||
* @return Destination uri | ||
*/ | ||
@JsonProperty(value = "destination_uri") | ||
public String getDestinationUri() { | ||
return destinationUri; | ||
} | ||
|
||
/** | ||
* @param destinationUri Destination uri | ||
*/ | ||
public void setDestinationUri(final String destinationUri) { | ||
this.destinationUri = destinationUri; | ||
} | ||
|
||
/** | ||
* @return Mimetype | ||
*/ | ||
public String getMimetype() { | ||
return mimetype; | ||
} | ||
|
||
/** | ||
* @param mimetype Mimetype | ||
*/ | ||
public void setMimetype(final String mimetype) { | ||
this.mimetype = mimetype; | ||
} | ||
|
||
/** | ||
* @return Args | ||
*/ | ||
public String getArgs() { | ||
return args; | ||
} | ||
|
||
/** | ||
* @param args Args | ||
*/ | ||
public void setArgs(final String args) { | ||
this.args = args; | ||
} | ||
|
||
/** | ||
* @return Filename | ||
*/ | ||
public String getFilename() { | ||
return filename; | ||
} | ||
|
||
/** | ||
* @param filename Filename | ||
*/ | ||
public void setFilename(final String filename) { | ||
this.filename = filename; | ||
} | ||
|
||
private String sourceUri; | ||
private String destinationUri; | ||
private String mimetype; | ||
private String args; | ||
private String filename; | ||
|
||
} |
Oops, something went wrong.