Skip to content

Commit

Permalink
Modify DC datastream on update
Browse files Browse the repository at this point in the history
  • Loading branch information
claussni committed Aug 28, 2015
1 parent a0c8989 commit e433cfe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public SWORDEntry updateDeposit(DepositCollection deposit, ServiceDocument servi
final String pid = deposit.getDepositID();
final FedoraObject fedoraObject = new FedoraObject(pid);

fedoraObject.setDc(new DublinCore());

fedoraObject.setDc(metsContainer.getDublinCore());
final SWORDEntry swordEntry = getSWORDEntry(deposit, serviceDocument, fedoraObject);

if (!deposit.isNoOp()) { // Don't ingest if no-op is set
update(repository, pid, fedoraObject.getDc());
updateIfPresent(repository, pid, metsContainer.getModsDatastream());
updateAttachmentDatastreams(repository, pid, metsContainer.getFileDatastreams());
updateOrAdd(repository, pid, metsContainer.getSlubInfoDatastream());
Expand Down Expand Up @@ -262,9 +262,13 @@ private void updateAttachmentDatastreams(FedoraRepository repository, String pid

private void updateIfPresent(FedoraRepository repository, String pid, Datastream datastream) throws SWORDException {
if (datastream != null) {
if (repository.hasDatastream(pid, datastream.getId())) {
repository.modifyDatastream(pid, datastream, null);
}
update(repository, pid, datastream);
}
}

private void update(FedoraRepository repository, String pid, Datastream datastream) throws SWORDException {
if (repository.hasDatastream(pid, datastream.getId())) {
repository.modifyDatastream(pid, datastream, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public void md5CheckNotPerformedIfNoMd5IsGiven() throws Exception {
fh.updateDeposit(depositCollection, buildServiceDocument());
}

@Test
public void dcGetsUpdated() throws Exception {
FileHandler fh = new QucosaMETSFileHandler();
when(mockFedoraRepository.hasDatastream(eq("test:1"), eq("DC"))).thenReturn(true);
ArgumentCaptor<Datastream> argument = ArgumentCaptor.forClass(Datastream.class);
DepositCollection depositCollection = buildDeposit(METS_FILE_UPDATE, "test:1");

fh.updateDeposit(depositCollection, buildServiceDocument());

verify(mockFedoraRepository).modifyDatastream(eq("test:1"), argument.capture(), anyString());
}

@Test
public void modsGetsUpdated() throws Exception {
FileHandler fh = new QucosaMETSFileHandler();
Expand Down Expand Up @@ -171,7 +183,7 @@ public void swordResultHasCorrectEditLink() throws Exception {
SWORDEntry swordEntry = fh.updateDeposit(depositCollection, buildServiceDocument());

Link link = swordEntry.getLinks().next();
assertEquals("http://localhost:8080/sword/" + COLLECTION +"/test:1", link.getHref());
assertEquals("http://localhost:8080/sword/" + COLLECTION + "/test:1", link.getHref());
assertEquals("edit", link.getRel());
}

Expand Down

0 comments on commit e433cfe

Please sign in to comment.