}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("addDatastream")) {
try {
addDatastream = false;
m_ds = new Datastream();
// Get required attributes
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsControlGrp = attrs.getValue("dsControlGroupType");
m_ds.dsLabel = attrs.getValue("dsLabel");
m_ds.dsState = attrs.getValue("dsState");
m_ds.dsMIME = attrs.getValue("dsMIME");
m_ds.logMessage = attrs.getValue("logMessage");
// Check for optional attributes
if (attrs.getValue("dsID") != null
&& !attrs.getValue("dsID").equals("")) {
m_ds.dsID = attrs.getValue("dsID");
} else {
m_ds.dsID = null;
}
if (attrs.getValue("dsLocation") != null
&& !attrs.getValue("dsLocation").equals("")) {
m_ds.dsLocation = attrs.getValue("dsLocation");
}
if (attrs.getValue("formatURI") != null
&& !attrs.getValue("formatURI").equals("")) {
m_ds.formatURI = attrs.getValue("formatURI");
}
if (attrs.getValue("versionable") != null
&& !attrs.getValue("versionable").equals("")) {
m_ds.versionable =
new Boolean(attrs.getValue("versionable"))
.booleanValue();
}
if (attrs.getValue("altIDs") != null
&& !attrs.getValue("altIDs").equals("")) {
m_ds.altIDs = attrs.getValue("altIDs").split(" ");
}
if (attrs.getValue("checksumType") != null
&& !attrs.getValue("checksumType").equals("")) {
m_ds.checksumType = attrs.getValue("checksumType");
}
if (attrs.getValue("checksum") != null
&& !attrs.getValue("checksum").equals("")) {
m_ds.checksum = attrs.getValue("checksum");
}
addDatastream = true;
} catch (Exception e) {
e.printStackTrace();
failedCount++;
logFailedDirective(m_ds.objectPID, localName, e, "");
return;
}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("purgeDatastream")) {
try {
purgeDatastream = false;
m_ds = new Datastream();
// Get required attributes
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsID = attrs.getValue("dsID");
m_ds.logMessage = attrs.getValue("logMessage");
// Get optional attributes. If asOfDate attribute is missing
// or empty its value is null and indicates that all versions
// of the datastream are to be purged.
if (attrs.getValue("asOfDate") != null
&& !attrs.getValue("asOfDate").equals("")) {
m_ds.asOfDate = attrs.getValue("asOfDate");
}
if (attrs.getValue("endDate") != null
&& !attrs.getValue("endDate").equals("")) {
m_ds.endDate = attrs.getValue("endDate");
}
if (attrs.getValue("force") != null
&& !attrs.getValue("force").equals("")) {
m_ds.force =
new Boolean(attrs.getValue("force")).booleanValue();
}
purgeDatastream = true;
} catch (Exception e) {
failedCount++;
logFailedDirective(m_ds.objectPID, localName, e, "");
}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("modifyDatastream")) {
try {
org.fcrepo.server.types.gen.Datastream dsOrig = null;
modifyDatastream = false;
// Get required attributes
m_ds = new Datastream();
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsID = attrs.getValue("dsID");
m_ds.dsControlGrp = attrs.getValue("dsControlGroupType");
m_ds.logMessage = attrs.getValue("logMessage");
try {
dsOrig =
APIM.getDatastream(m_ds.objectPID, m_ds.dsID, null);
} catch (Exception e) {
failedCount++;
logFailedDirective(m_ds.objectPID,
localName,
null,
"Datastream ID: " + m_ds.dsID
+ " does not exist"
+ " in the object: "
+ m_ds.objectPID
+ " .\n Unable to modify"
+ "datastream.");
return;
}
// Check that datastream control group type matches that of the
// original datastream being modified. This would get caught
// later by the server, but may as well detect this now and
// flag as an error in directives file.
if (dsOrig.getControlGroup().value()
.equalsIgnoreCase(m_ds.dsControlGrp)) {
// Check for optional atributes. Missing attributes (null) indicate
// that no change is to occur to that attribute and that the original
// value of that datastream attribute is to be retained. Attributes that
// contain the empty string indicate that the datastream attribute value
// is to be set to the empty string.
if (attrs.getValue("dsLabel") != null) {
m_ds.dsLabel = attrs.getValue("dsLabel");
} else {
m_ds.dsLabel = dsOrig.getLabel();
}
if (attrs.getValue("dsLocation") != null) {
m_ds.dsLocation = attrs.getValue("dsLocation");
} else {
m_ds.dsLocation = dsOrig.getLocation();
}
if (attrs.getValue("dsMIME") != null) {
m_ds.dsMIME = attrs.getValue("dsMIME");
} else {
m_ds.dsMIME = dsOrig.getMIMEType();
}
if (attrs.getValue("force") != null) {
m_ds.force =
new Boolean(attrs.getValue("force"))
.booleanValue();
} else {
m_ds.force = false;
}
if (attrs.getValue("altIDs") != null) {
m_ds.altIDs = attrs.getValue("altIDs").split(" ");
} else {
m_ds.altIDs =
dsOrig.getAltIDs().getItem()
.toArray(new String[] {});
}
if (attrs.getValue("formatURI") != null) {
m_ds.formatURI = attrs.getValue("formatURI");
} else {
m_ds.formatURI = dsOrig.getFormatURI();
}
if (attrs.getValue("checksumType") != null) {
m_ds.checksumType = attrs.getValue("checksumType");
}
if (attrs.getValue("checksum") != null) {
m_ds.checksum = attrs.getValue("checksum");
}
modifyDatastream = true;
} else {
failedCount++;
logFailedDirective(m_ds.objectPID,
localName,
null,
" Datastream Control Group Type of: "
+ m_ds.dsControlGrp
+ " in directives file does not match control group"
+ " type in original datastream: "
+ dsOrig.getControlGroup()
.value());
}
} catch (Exception e) {
failedCount++;
logFailedDirective(m_ds.objectPID, localName, e, "");
}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("setDatastreamState")) {
try {
m_ds = new Datastream();
setDatastreamState = false;
// Get require attributes
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsID = attrs.getValue("dsID");
m_ds.dsState = attrs.getValue("dsState");
m_ds.logMessage = attrs.getValue("logMessage");
setDatastreamState = true;
} catch (Exception e) {
failedCount++;
logFailedDirective(m_ds.objectPID, localName, e, "");
}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("setDatastreamVersionable")) {
try {
m_ds = new Datastream();
setDatastreamVersionable = false;
// Get require attributes
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsID = attrs.getValue("dsID");
m_ds.versionable =
new Boolean(attrs.getValue("versionable"))
.booleanValue();
m_ds.logMessage = attrs.getValue("logMessage");
setDatastreamVersionable = true;
} catch (Exception e) {
failedCount++;
logFailedDirective(m_ds.objectPID, localName, e, "");
}
} else if (namespaceURI.equalsIgnoreCase(BATCH_MODIFY.uri)
&& localName.equalsIgnoreCase("compareDatastreamChecksum")) {
try {
m_ds = new Datastream();
compareDatastreamChecksum = false;
// Get require attributes
m_ds.objectPID = attrs.getValue("pid");
m_ds.dsID = attrs.getValue("dsID");