Skip to content

Commit

Permalink
Added support for datastream properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-dgi authored and mikedurbin committed Apr 14, 2015
1 parent cbf42f8 commit 445a679
Show file tree
Hide file tree
Showing 3 changed files with 347 additions and 28 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/fcrepo/migration/DatastreamVersion.java
Expand Up @@ -72,4 +72,18 @@ public interface DatastreamVersion {
* redirect datastream.
*/
public String getExternalOrRedirectURL();

/**
* Determines if this is the first version of a datastream.
*
* @return True if this is the first version, false otherwise.
*/
public boolean isFirstVersionIn(ObjectReference obj);

/**
* Determines if this is the last version of a datastream.
*
* @return True if this is the last version, false otherwise.
*/
public boolean isLastVersionIn(ObjectReference obj);
}
Expand Up @@ -5,11 +5,11 @@
import org.fcrepo.migration.DatastreamVersion;
import org.fcrepo.migration.DefaultContentDigest;
import org.fcrepo.migration.DefaultObjectInfo;
import org.fcrepo.migration.ObjectReference;
import org.fcrepo.migration.StreamingFedoraObjectHandler;
import org.fcrepo.migration.FedoraObjectProcessor;
import org.fcrepo.migration.ObjectInfo;
import org.fcrepo.migration.ObjectProperties;

import org.apache.commons.codec.binary.Base64OutputStream;

import javax.xml.bind.JAXBContext;
Expand All @@ -24,6 +24,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -378,6 +379,17 @@ public String getExternalOrRedirectURL() {
}
}

@Override
public boolean isFirstVersionIn(ObjectReference obj) {
List<DatastreamVersion> datastreams = obj.getDatastreamVersions(getDatastreamInfo().getDatastreamId());
return datastreams.indexOf(this) == 0;
}

@Override
public boolean isLastVersionIn(ObjectReference obj) {
List<DatastreamVersion> datastreams = obj.getDatastreamVersions(getDatastreamInfo().getDatastreamId());
return datastreams.indexOf(this) == datastreams.size() - 1;
}
}

private static Map<String, String> getAttributes(XMLStreamReader r, String ... allowedNames) {
Expand Down

0 comments on commit 445a679

Please sign in to comment.