Skip to content

Commit

Permalink
Formatting to pass checkstyle rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Shin committed Jun 26, 2013
1 parent 5c22a24 commit e48ea7f
Show file tree
Hide file tree
Showing 18 changed files with 493 additions and 165 deletions.
Expand Up @@ -30,9 +30,8 @@

/**
* This class is responsible for interaction with the Fedora Repository
*
*
* @author frank asseg
*
*/
@Service("fixityClient")
public class FedoraFixityClient {
Expand All @@ -42,21 +41,33 @@ public class FedoraFixityClient {

/**
* Fetch all the identifiers of objects which have a given parent
* @param parentUri The URI of the parent (e.g. http://localhost:8080/rest/objects)
*
* @param parentUri
* The URI of the parent (e.g. http://localhost:8080/rest/objects)
* @return A {@link List} containing the URIs of the child objects
*/
public List<String> retrieveUris(String parentUri) throws IOException {
return retrieveUris(parentUri,parentUri);
return retrieveUris(parentUri, parentUri);
}

public List<String> retrieveUris(String sourceUri, String parentUri) throws IOException {
/* fetch a RDF Description of the parent form the repository */
/**
* TODO
*
* @param sourceUri TODO
* @param parentUri TODO
* @return TODO
* @throws IOException
*/
public List<String> retrieveUris(String sourceUri, String parentUri)
throws IOException {
/* fetch a RDF Description of the parent from the repository */
StmtIterator stmts = null;
try {
/* parse the RDF N3 response using Apache Jena */
final Model model = ModelFactory.createDefaultModel();
try {
LOG.info("reading model for {} from parent URI {}",parentUri,sourceUri);
LOG.info("reading model for {} from parent URI {}", parentUri,
sourceUri);
RDFDataMgr.read(model, sourceUri);
} catch (HttpException e) {
throw new IOException("Unable to fetch uris from " + parentUri,
Expand All @@ -72,7 +83,7 @@ public List<String> retrieveUris(String sourceUri, String parentUri) throws IOEx
RdfLexicon.HAS_CHILD, (RDFNode) null);
final List<String> uris = new ArrayList<>();
while (stmts.hasNext()) {
Statement st = stmts.next(); //NOSONAR
Statement st = stmts.next(); // NOSONAR
String uri = st.getObject().asResource().getURI();
uris.add(uri);
LOG.debug("adding '" + uri + "' to retrieveUris results");
Expand All @@ -87,7 +98,8 @@ public List<String> retrieveUris(String sourceUri, String parentUri) throws IOEx

/**
* Request a datastream fixity check execution from Fedora an
* @param uri the URI of the Fedora datastream
*
* @param datastreamUris a List of the Fedora datastream URIs
*/
public List<DatastreamFixityResult> requestFixityChecks(
final List<String> datastreamUris) throws IOException {
Expand All @@ -96,18 +108,18 @@ public List<DatastreamFixityResult> requestFixityChecks(
for (final String uri : datastreamUris) {
/* parse the fixity part of the RDF response */
final Model model = ModelFactory.createDefaultModel();
RDFDataMgr.read(model, uri + "/fcr:fixity",Lang.N3);
RDFDataMgr.read(model, uri + "/fcr:fixity", Lang.N3);
StmtIterator sts = null;
try {
sts = model.listStatements(model.createResource(uri),
RdfLexicon.HAS_FIXITY_RESULT, (RDFNode) null);
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);
"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 */
Expand Down Expand Up @@ -135,10 +147,12 @@ public List<DatastreamFixityResult> requestFixityChecks(
FixityState state = FixityState.valueOf(stateName);
switch (state) {
case BAD_CHECKSUM:
results.add(new DatastreamFixityError(uri,"Datastream has the wrong Checksum"));
results.add(new DatastreamFixityError(uri,
"Datastream has the wrong Checksum"));
break;
case BAD_SIZE:
results.add(new DatastreamFixityError(uri,"Datastream has a bad size"));
results.add(new DatastreamFixityError(uri,
"Datastream has a bad size"));
break;
case SUCCESS:
results.add(new DatastreamFixitySuccess(uri));
Expand Down Expand Up @@ -167,11 +181,12 @@ 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");
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 Statement st = sts.next(); // NOSONAR
final String dsUri = st.getSubject().asResource().getURI();
result.add(dsUri);
}
Expand Down
Expand Up @@ -12,31 +12,37 @@

/**
* @author frank asseg
*
*/
public interface FixityDatabaseService {

/**
* Add a fixity result to the database
*
* @param res the result
*/
void addResult(ObjectFixityResult res);

/**
* Retrieve a {@link List} of {@link ObjectFixityResult} for a given fedora object
* Retrieve a {@link List} of {@link ObjectFixityResult} for a given fedora
* object
*
* @param uri the uri of the Object
* @return
*/
List<ObjectFixityResult> getResults(String uri);

/**
* Add a {@link Collection} of {@link ObjectFixityResult} to the database
* @param results the {@link ObjectFixityResult} {@link Collection} to add to the database
*
* @param results the {@link ObjectFixityResult} {@link Collection} to add
* to the database
*/
void addResults(Collection<ObjectFixityResult> results);

/**
* Retrieve a {@link List} of {@link ObjectFixityResult} from a given offset with up to <b>length</b> elements
* Retrieve a {@link List} of {@link ObjectFixityResult} from a given offset
* with up to <b>length</b> elements
*
* @param offset the offset
* @param length the length
* @return a {@link List} of {@link ObjectFixityResult}
Expand All @@ -45,55 +51,65 @@ public interface FixityDatabaseService {

/**
* Retrieve the number of {@link ObjectFixityResult}s in the database
*
* @return the number of results
*/
long getResultCount();

/**
* Retrieve the number of errors in the database
*
* @return the number of errors
*/
long getErrorCount();

/**
* Retrieve the number of successes in the database
*
* @return the number of successes
*/
long getSuccessCount();

/**
* Retrieve the number of repairs in the database
*
* @return the number of repairs
*/
long getRepairCount();

/**
* Retrieve the number of distinct fedora objects for which results are available in the database
* Retrieve the number of distinct fedora objects for which results are
* available in the database
*
* @return the number of distinct objects
*/
long getObjectCount();

/**
* Add a {@link DailyStatistics} record to the database
*
* @param stat the {@link DailyStatistics} to add to the db
*/
void addStat(DailyStatistics stat);

/**
* Retrieve a {@link List} of {@link DailyStatistics} form the database
*
* @return The {@link DailyStatistics}s
*/
List<DailyStatistics> getDailyStatistics();

/**
* Retrieve a distinct result from the database
*
* @param resultId the id of the result to fetch from the database
* @return the {@link ObjectFixityResult} associated with the resultId
*/
ObjectFixityResult getResult(long resultId);

/**
* Remove a distinct result from the database
*
* @param resultId the result id
*/
void deleteResult(long resultId);
Expand All @@ -105,28 +121,31 @@ public interface FixityDatabaseService {

/**
* Retrieve the {@link DailyStatistics} for a certain day
*
* @param date the date
* @return a {@link DailyStatistics} objects
*/
DailyStatistics getFixityStatisticForDate(Date date);

/**
* Retrieve the general {@link Statistics}
*
* @return a {@link Statistics} objects
*/
Statistics getStatistics();

/**
* Update the {@link DailyStatistics} for today
*
* @param sucesses the success count to add
* @param errors the errors count to add
* @param repairs the repair count to add
*/
void addFixityStatistics(int sucesses, int errors, int repairs);

/**
* @param id
* @return
* @param id TODO
* @return TODO
*/
DatastreamFixityResult getDatastreamFixityResult(long id);

Expand Down

0 comments on commit e48ea7f

Please sign in to comment.