Skip to content
Permalink
Browse files

added method to check for datastream uris

  • Loading branch information...
fasseg committed Jun 6, 2013
1 parent 92fd7c8 commit 30a49823a37bbd67d743725d75e07be09d1b1900
Showing with 35 additions and 9 deletions.
  1. +35 −9 fcrepo-fixity-core/src/main/java/org/fcrepo/fixity/client/FedoraFixityClient.java
@@ -62,7 +62,9 @@
* and iterate over all the elements which contain the predicate
* #hasParent in order to discover objects
*/
stmts = model.listStatements(model.createResource(parentUri), RdfLexicon.HAS_CHILD, (RDFNode) null);
stmts =
model.listStatements(model.createResource(parentUri),
RdfLexicon.HAS_CHILD, (RDFNode) null);
final List<String> uris = new ArrayList<>();
while (stmts.hasNext()) {
Statement st = stmts.next(); //NOSONAR
@@ -88,21 +90,23 @@
/* parse the fixity part of the RDF response */
final Model model = ModelFactory.createDefaultModel();
RDFDataMgr.read(model, uri + "/fcr:fixity");
StmtIterator sts=null;
try{
StmtIterator sts = null;
try {
sts = model.listStatements(model.createResource(uri),
RdfLexicon.HAS_FIXITY_RESULT, (RDFNode) null);
if (!sts.hasNext()) {
sts.close();
throw new IOException("No fixity information available for " +
uri);
throw new IOException(
"No fixity information available for " +
uri);
}
Statement st = sts.next(); //NOSONAR
Statement st = sts.next(); //NOSONAR
final Resource res = st.getObject().asResource();

/* parse the checksum from the model */
st =
model.listStatements(res, RdfLexicon.HAS_COMPUTED_CHECKSUM,
model.listStatements(res,
RdfLexicon.HAS_COMPUTED_CHECKSUM,
(RDFNode) null).next();
final String checksum = st.getObject().asResource().getURI();

@@ -134,13 +138,35 @@
break;
default:
throw new IOException(
"Unabel to handle results of unkwonn type");
"Unable to handle results of unknown type");
}
}finally{
} finally {
sts.close();
}
}
return results;
}

/**
* @param objectUri
* @return
*/
public List<String> retrieveDatatstreamUris(String objectUri) {
final Model model = ModelFactory.createDefaultModel();
RDFDataMgr.read(model, objectUri);
final StmtIterator sts =
model.listStatements(null, RdfLexicon.HAS_MIXIN_TYPE,
"fedora:datastream");
try {
List<String> result = new ArrayList<>();
while (sts.hasNext()) {
final Statement st = sts.next(); //NOSONAR
final String dsUri = st.getResource().getURI();
result.add(dsUri);
}
return result;
} finally {
sts.close();
}
}
}

0 comments on commit 30a4982

Please sign in to comment.
You can’t perform that action at this time.