Skip to content

Commit

Permalink
Allow datastream update without content
Browse files Browse the repository at this point in the history
  • Loading branch information
claussni committed Nov 30, 2015
1 parent 71a1ebe commit 9138e10
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void ingest(FedoraObject fedoraFedoraObject) throws SWORDException {
public void modifyDatastream(String pid, Datastream update, String logMessage) throws SWORDException {
uploadDatastreamIfLocal(update);
org.fcrepo.server.types.gen.Datastream original = _APIM.getDatastream(pid, update.getId(), null);

if (update instanceof InlineDatastream) {
byte[] content = serializeContent((InlineDatastream) update);
_APIM.modifyDatastreamByValue(
Expand All @@ -195,21 +196,26 @@ public void modifyDatastream(String pid, Datastream update, String logMessage) t
original.getChecksum(),
logMessage,
false);
} else if (update instanceof URLContentLocationDatastream) {
} else {
final String contentLocationUrl =
(update instanceof URLContentLocationDatastream) ?
((URLContentLocationDatastream) update).getURL() : null;
final String checksum =
(contentLocationUrl != null) ?
original.getChecksum() : null;

_APIM.modifyDatastreamByReference(
pid,
update.getId(),
original.getAltIDs(),
update.getLabel(),
update.getMimeType(),
original.getFormatURI(),
((URLContentLocationDatastream) update).getURL(),
contentLocationUrl,
original.getChecksumType(),
original.getChecksum(),
checksum,
logMessage,
false);
} else {
throw new SWORDException("Unknown datastream type");
}
}

Expand Down

0 comments on commit 9138e10

Please sign in to comment.