Skip to content

Commit

Permalink
Minor code cleanup, reducing compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Oct 8, 2013
1 parent 5f1f093 commit 08f495b
Show file tree
Hide file tree
Showing 90 changed files with 230 additions and 279 deletions.
Expand Up @@ -19,6 +19,7 @@
import static javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM_TYPE;
import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.noContent;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
Expand Down Expand Up @@ -83,7 +84,7 @@ public class FedoraContent extends AbstractResource {
/**
* Create an anonymous DS with a newly minted name and content from request
* body
*
*
* @param pathList
* @throws RepositoryException
*/
Expand All @@ -108,7 +109,7 @@ public Response create(@PathParam("path")
}

logger.debug("create Datastream {}", path);
final Throwable exception = null;

try {
final URI checksumURI;

Expand All @@ -130,9 +131,8 @@ public Response create(@PathParam("path")
session.save();
return created(
new URI(subjects.getGraphSubject(
datastreamNode
.getNode(JcrConstants.JCR_CONTENT))
.getURI())).build();
datastreamNode.getNode(JCR_CONTENT)).getURI()))
.build();

} finally {
session.logout();
Expand All @@ -141,7 +141,7 @@ public Response create(@PathParam("path")

/**
* Modify an existing datastream's content
*
*
* @param pathList
* @param requestContentType Content-Type header
* @param requestBodyStream Binary blob
Expand Down Expand Up @@ -212,7 +212,7 @@ public Response modifyContent(@PathParam("path")

/**
* Get the binary content of a datastream
*
*
* @param pathList
* @return Binary blob
* @throws RepositoryException
Expand Down
Expand Up @@ -52,10 +52,10 @@
import javax.ws.rs.core.Response;

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.kernel.utils.ContentDigest;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
Expand Down
Expand Up @@ -35,9 +35,9 @@
import javax.ws.rs.core.StreamingOutput;

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.serialization.FedoraObjectSerializer;
import org.fcrepo.serialization.SerializerUtil;
import org.fcrepo.http.commons.session.InjectedSession;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
Expand Down
Expand Up @@ -21,6 +21,13 @@
import static javax.ws.rs.core.MediaType.TEXT_HTML;
import static javax.ws.rs.core.Response.status;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT1;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.kernel.RdfLexicon.FIRST_PAGE;
import static org.fcrepo.kernel.RdfLexicon.NEXT_PAGE;
import static org.fcrepo.kernel.RdfLexicon.PAGE;
Expand All @@ -30,13 +37,6 @@
import static org.fcrepo.kernel.RdfLexicon.SEARCH_OFFSET;
import static org.fcrepo.kernel.RdfLexicon.SEARCH_PAGE;
import static org.fcrepo.kernel.RdfLexicon.SEARCH_TERMS;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT1;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.slf4j.LoggerFactory.getLogger;

import javax.jcr.RepositoryException;
Expand Down
Expand Up @@ -39,9 +39,9 @@
import javax.ws.rs.core.UriInfo;

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.Datastream;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

Expand Down
Expand Up @@ -24,14 +24,14 @@
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static com.hp.hpl.jena.update.GraphStoreFactory.create;
import static javax.ws.rs.core.MediaType.TEXT_HTML;
import static org.fcrepo.kernel.RdfLexicon.HAS_MEMBER_OF_RESULT;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT1;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.kernel.RdfLexicon.HAS_MEMBER_OF_RESULT;

import java.util.Collection;
import java.util.List;
Expand Down
Expand Up @@ -37,9 +37,9 @@

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.serialization.SerializerUtil;
import org.fcrepo.http.commons.session.InjectedSession;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
Expand Down
41 changes: 19 additions & 22 deletions fcrepo-http-api/src/main/java/org/fcrepo/http/api/FedoraNodes.java
Expand Up @@ -29,16 +29,16 @@
import static org.apache.http.HttpStatus.SC_NO_CONTENT;
import static org.apache.jena.riot.WebContent.contentTypeSPARQLUpdate;
import static org.apache.jena.riot.WebContent.contentTypeToLang;
import static org.fcrepo.kernel.RdfLexicon.FIRST_PAGE;
import static org.fcrepo.kernel.RdfLexicon.HAS_CHILD_COUNT;
import static org.fcrepo.kernel.RdfLexicon.NEXT_PAGE;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT1;
import static org.fcrepo.http.commons.domain.RDFMediaType.N3_ALT2;
import static org.fcrepo.http.commons.domain.RDFMediaType.NTRIPLES;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.fcrepo.kernel.RdfLexicon.FIRST_PAGE;
import static org.fcrepo.kernel.RdfLexicon.HAS_CHILD_COUNT;
import static org.fcrepo.kernel.RdfLexicon.NEXT_PAGE;
import static org.fcrepo.kernel.rdf.GraphProperties.INLINED_RESOURCES_MODEL;
import static org.fcrepo.kernel.rdf.GraphProperties.PROBLEMS_MODEL_NAME;
import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -50,7 +50,6 @@
import java.util.Date;
import java.util.List;

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -76,19 +75,17 @@
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.UriInfo;

import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import org.apache.commons.io.IOUtils;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.WebContent;
import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.http.commons.domain.PATCH;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.jcr.FedoraJcrTypes;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.modeshape.jcr.api.JcrConstants;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
Expand All @@ -97,6 +94,8 @@
import com.codahale.metrics.annotation.Timed;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;

/**
* CRUD operations on Fedora Nodes
Expand All @@ -113,7 +112,7 @@ public class FedoraNodes extends AbstractResource {

/**
* Retrieve the node profile
*
*
* @param pathList
* @param offset with limit, control the pagination window of details for
* child nodes
Expand All @@ -133,7 +132,7 @@ public Dataset describe(@PathParam("path") final List<PathSegment> pathList,
@QueryParam("limit") @DefaultValue("-1") final int limit,
@QueryParam("non-member-properties") final String nonMemberProperties,
@Context final Request request,
@Context HttpServletResponse servletResponse,
@Context final HttpServletResponse servletResponse,
@Context final UriInfo uriInfo) throws RepositoryException, IOException {
final String path = toPath(pathList);
logger.trace("Getting profile for {}", path);
Expand Down Expand Up @@ -179,7 +178,7 @@ public Dataset describe(@PathParam("path") final List<PathSegment> pathList,
.contains(subjects.getGraphSubject(resource.getNode()),
HAS_CHILD_COUNT)) {

Model requestModel = ModelFactory.createDefaultModel();
final Model requestModel = ModelFactory.createDefaultModel();

final long childCount = treeModel
.listObjectsOfProperty(subjects.getGraphSubject(resource.getNode()), HAS_CHILD_COUNT)
Expand Down Expand Up @@ -231,7 +230,7 @@ public Dataset describe(@PathParam("path") final List<PathSegment> pathList,

/**
* Update an object using SPARQL-UPDATE
*
*
* @param pathList
* @return 201
* @throws RepositoryException
Expand Down Expand Up @@ -275,10 +274,10 @@ public Response updateSparql(@PathParam("path")
throw new WebApplicationException(builder.build());
}

Dataset properties = resource.updatePropertiesDataset(new HttpGraphSubjects(
final Dataset properties = resource.updatePropertiesDataset(new HttpGraphSubjects(
session, FedoraNodes.class, uriInfo), IOUtils
.toString(requestBodyStream));
Model problems = properties.getNamedModel(PROBLEMS_MODEL_NAME);
final Model problems = properties.getNamedModel(PROBLEMS_MODEL_NAME);
if (problems.size() > 0) {
logger.info(
"Found these problems updating the properties for {}: {}",
Expand Down Expand Up @@ -369,7 +368,7 @@ public Response createOrReplaceObjectRdf(

/**
* Creates a new object.
*
*
* @param pathList
* @return 201
* @throws RepositoryException
Expand Down Expand Up @@ -487,11 +486,9 @@ public Response createObject(@PathParam("path")
result.replacePropertiesDataset(subjects, inputModel);
} else if (result instanceof Datastream) {

final Node node =
datastreamService.createDatastreamNode(session, newObjectPath,
contentTypeString, requestBodyStream,
checksumURI);

datastreamService.createDatastreamNode(session,
newObjectPath, contentTypeString,
requestBodyStream, checksumURI);

}
}
Expand All @@ -518,7 +515,7 @@ public Response createObject(@PathParam("path")

/**
* Deletes an object.
*
*
* @param path
* @return
* @throws RepositoryException
Expand Down
Expand Up @@ -47,10 +47,10 @@
import javax.ws.rs.core.Variant;

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.http.commons.responses.GraphStoreStreamingOutput;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.FedoraResource;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
Expand Down
Expand Up @@ -33,12 +33,12 @@

import org.apache.commons.io.IOUtils;
import org.apache.jena.riot.WebContent;
import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.http.api.FedoraNodes;
import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
import org.fcrepo.kernel.rdf.GraphProperties;
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.kernel.rdf.GraphProperties;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
Expand Down
Expand Up @@ -15,7 +15,19 @@
*/
package org.fcrepo.http.api.repository;

import com.google.common.io.Files;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

import org.apache.commons.io.IOUtils;
import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.session.InjectedSession;
Expand All @@ -25,17 +37,7 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.io.Files;

@Component
@Scope("prototype")
Expand Down

0 comments on commit 08f495b

Please sign in to comment.