Skip to content

Commit

Permalink
added null check for objects without datastreams, second try
Browse files Browse the repository at this point in the history
  • Loading branch information
fasseg committed Mar 19, 2013
1 parent e04a339 commit dacfae4
Showing 1 changed file with 12 additions and 11 deletions.
Expand Up @@ -50,17 +50,18 @@ public ObjectFixity check(String objectId) throws IOException, NoSuchAlgorithmEx
final ObjectDatastreams datastreams = client.getObjectDatastreams(objectId);
if (datastreams == null || datastreams.datastreams == null){
logger.warn("There are no datastreams available for pid: " + objectId);
}
for (ObjectDatastreams.DatastreamElement dsElement : datastreams.datastreams) {
logger.debug("verifying checksum of object {} datastream {}", objectId, dsElement.dsid);
final String dsId = dsElement.dsid;
final org.fcrepo.jaxb.responses.management.DatastreamFixity ds = client.getDatastreamFixity(objectId, dsId);

DatastreamFixity dsFixity = new DatastreamFixity(ds);
if (dsFixity.getType() != ResultType.SUCCESS){
errors.add(dsFixity);
} else {
successes.add(dsFixity);
}else{
for (ObjectDatastreams.DatastreamElement dsElement : datastreams.datastreams) {
logger.debug("verifying checksum of object {} datastream {}", objectId, dsElement.dsid);
final String dsId = dsElement.dsid;
final org.fcrepo.jaxb.responses.management.DatastreamFixity ds = client.getDatastreamFixity(objectId, dsId);

DatastreamFixity dsFixity = new DatastreamFixity(ds);
if (dsFixity.getType() != ResultType.SUCCESS){
errors.add(dsFixity);
} else {
successes.add(dsFixity);
}
}
}
return new ObjectFixity(objectId,new Date(), successes, errors);
Expand Down

0 comments on commit dacfae4

Please sign in to comment.