Skip to content

Commit

Permalink
Non-functional reformatting update
Browse files Browse the repository at this point in the history
    Resolves: https://www.pivotaltracker.com/story/show/59402954

    Code cleanup including
    - whitespace adjustment
    - static imports
    - removing unneeded type-safety annotations
  • Loading branch information
ajs6f authored and Andrew Woods committed Oct 23, 2013
1 parent 99564d9 commit d08914b
Show file tree
Hide file tree
Showing 93 changed files with 1,056 additions and 1,017 deletions.
Expand Up @@ -19,6 +19,8 @@
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 javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.slf4j.LoggerFactory.getLogger;

Expand Down Expand Up @@ -56,7 +58,6 @@
import org.fcrepo.http.commons.session.InjectedSession;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.modeshape.jcr.api.JcrConstants;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -199,7 +200,7 @@ public Response modifyContent(@PathParam("path")
new URI(
subjects.getGraphSubject(
datastreamNode
.getNode(JcrConstants.JCR_CONTENT))
.getNode(JCR_CONTENT))
.getURI())).build();
} else {
return noContent().build();
Expand Down Expand Up @@ -266,7 +267,7 @@ public Response getContent(@PathParam("path")
if (range.end() > contentSize ||
(range.end() == -1 && range.start() > contentSize)) {
builder =
Response.status(
status(
REQUESTED_RANGE_NOT_SATISFIABLE)
.header("Content-Range",
contentRangeValue);
Expand All @@ -276,14 +277,14 @@ public Response getContent(@PathParam("path")
.start(), range.size());

builder =
Response.status(PARTIAL_CONTENT).entity(
status(PARTIAL_CONTENT).entity(
rangeInputStream)
.header("Content-Range",
contentRangeValue);
}

} else {
builder = Response.ok(content);
builder = ok(content);
}
}

Expand Down
Expand Up @@ -16,16 +16,17 @@

package org.fcrepo.http.api;

import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA;
import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.noContent;
import static javax.ws.rs.core.Response.ok;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
Expand All @@ -50,6 +51,7 @@
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.api.rdf.HttpGraphSubjects;
Expand Down Expand Up @@ -84,7 +86,7 @@ public class FedoraDatastreams extends AbstractResource {
/**
* Update the content of multiple datastreams from a multipart POST. The
* datastream to update is given by the name of the content disposition.
*
*
* @param pathList
* @param dsidList
* @param multipart
Expand Down Expand Up @@ -145,7 +147,7 @@ public Response modifyDatastreams(@PathParam("path")

/**
* Delete multiple datastreams given by the dsid query parameter
*
*
* @param pathList
* @param dsidList
* @return
Expand Down Expand Up @@ -173,7 +175,7 @@ public Response deleteDatastreams(@PathParam("path")
/**
* Retrieve multiple datastream bitstreams in a single request as a
* multipart/mixed response.
*
*
* @param pathList
* @param requestedDsids
* @param request
Expand Down Expand Up @@ -227,7 +229,7 @@ public Response getDatastreamsContents(@PathParam("path")
}

digest.update(ds.getContentDigest().toString().getBytes(
StandardCharsets.UTF_8));
UTF_8));

if (ds.getLastModifiedDate().after(date)) {
date = ds.getLastModifiedDate();
Expand All @@ -243,7 +245,7 @@ public Response getDatastreamsContents(@PathParam("path")
final Date roundedDate = new Date();
roundedDate.setTime(date.getTime() - date.getTime() % 1000);

Response.ResponseBuilder builder =
ResponseBuilder builder =
request.evaluatePreconditions(roundedDate, etag);

final CacheControl cc = new CacheControl();
Expand All @@ -265,7 +267,7 @@ public Response getDatastreamsContents(@PathParam("path")
multipart.bodyPart(bodyPart);
}

builder = Response.ok(multipart, MULTIPART_FORM_DATA);
builder = ok(multipart, MULTIPART_FORM_DATA);
}

return builder.cacheControl(cc).lastModified(date).tag(etag)
Expand Down
36 changes: 17 additions & 19 deletions fcrepo-http-api/src/main/java/org/fcrepo/http/api/FedoraExport.java
Expand Up @@ -16,6 +16,7 @@

package org.fcrepo.http.api;

import static javax.ws.rs.core.Response.ok;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
Expand Down Expand Up @@ -60,45 +61,42 @@ public class FedoraExport extends AbstractResource {
private final Logger logger = getLogger(this.getClass());

/**
* Export an object with the given format, e.g.:
*
* GET /path/to/object/fcr:export?format=jcr/xml
* -> the node as JCR/XML
* Export an object with the given format, e.g.: GET
* /path/to/object/fcr:export?format=jcr/xml -> the node as JCR/XML
*
* @param pathList
* @param format
* @return
*/
@GET
public Response exportObject(@PathParam("path")
final List<PathSegment> pathList,
@QueryParam("format")
@DefaultValue("jcr/xml")
final String format) {
public Response exportObject(
@PathParam("path") final List<PathSegment> pathList,
@QueryParam("format") @DefaultValue("jcr/xml") final String format) {

final String path = toPath(pathList);

logger.debug("Requested object serialization for: " + path +
" using serialization format " + format);
logger.debug("Requested object serialization for: " + path
+ " using serialization format " + format);

final FedoraObjectSerializer serializer =
serializers.getSerializer(format);
serializers.getSerializer(format);

return Response.ok().type(serializer.getMediaType()).entity(
return ok().type(serializer.getMediaType()).entity(
new StreamingOutput() {

@Override
public void write(final OutputStream out)
throws IOException {

try {
logger.debug("Selecting from serializer map: " +
serializers);
logger.debug("Retrieved serializer for format: " +
format);
logger.debug("Selecting from serializer map: "
+ serializers);
logger.debug("Retrieved serializer for format: "
+ format);
serializer.serialize(objectService.getObject(
session, path), out);
logger.debug("Successfully serialized object: " +
path);
logger.debug("Successfully serialized object: "
+ path);
} catch (final RepositoryException e) {
throw new WebApplicationException(e);
} finally {
Expand Down
Expand Up @@ -18,6 +18,8 @@

import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static com.hp.hpl.jena.vocabulary.RDF.nil;
import static com.hp.hpl.jena.vocabulary.RDF.type;
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;
Expand Down Expand Up @@ -65,7 +67,6 @@
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDF;

/**
* Basic administrative search across the repository
Expand Down Expand Up @@ -113,7 +114,7 @@ public Dataset searchSubmitHtml(@QueryParam("q")
final int limit,
@Context
final Request request,
@Context HttpServletResponse servletResponse,
@Context final HttpServletResponse servletResponse,
@Context
final UriInfo uriInfo) throws RepositoryException {
return getSearchDataset(terms, offset, limit, servletResponse, uriInfo);
Expand All @@ -139,11 +140,11 @@ public Dataset searchSubmitRdf(@QueryParam("q") final String terms,
@QueryParam("offset") @DefaultValue("0") final long offset,
@QueryParam("limit") @DefaultValue("25") final int limit,
@Context final Request request,
@Context HttpServletResponse servletResponse,
@Context final HttpServletResponse servletResponse,
@Context final UriInfo uriInfo) throws RepositoryException {

if (terms == null) {
LOGGER.trace("Received search request, but terms was empty. Aborting.");
LOGGER.trace("Received search request, but terms were empty. Aborting.");
throw new WebApplicationException(status(BAD_REQUEST).entity(
"q parameter is mandatory").build());
}
Expand Down Expand Up @@ -185,8 +186,8 @@ private Dataset getSearchDataset(final String terms,
final Model searchModel = createDefaultModel();
if (terms != null) {
final Resource pageResource = createResource(uriInfo.getRequestUri().toASCIIString());
searchModel.add(pageResource, RDF.type, SEARCH_PAGE);
searchModel.add(pageResource, RDF.type, PAGE);
searchModel.add(pageResource, type, SEARCH_PAGE);
searchModel.add(pageResource, type, PAGE);
searchModel.add(pageResource, PAGE_OF, searchResult);


Expand Down Expand Up @@ -214,7 +215,7 @@ private Dataset getSearchDataset(final String terms,
.toString());
searchModel.add(pageResource, NEXT_PAGE, nextPageResource);
} else {
searchModel.add(pageResource, NEXT_PAGE, RDF.nil);
searchModel.add(pageResource, NEXT_PAGE, nil);
}

final String firstPage = uriInfo
Expand Down
Expand Up @@ -101,8 +101,8 @@ public Dataset getNextPid(@PathParam("path")
createResource(uriInfo.getAbsolutePath().toASCIIString());

final Collection<String> identifiers =
transform(create(closed(1, numPids), integers()), pidMinter
.makePid());
transform(create(closed(1, numPids), integers()), pidMinter
.makePid());

final HttpGraphSubjects subjects =
new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);
Expand Down
Expand Up @@ -65,10 +65,8 @@ public class FedoraImport extends AbstractResource {
private final Logger logger = getLogger(this.getClass());

/**
* Deserialize a serialized object at the current path
*
* POST /fcr:import?format=jcr/xml
* (with a JCR/XML payload)
* Deserialize a serialized object at the current path POST
* /fcr:import?format=jcr/xml (with a JCR/XML payload)
*
* @param pathList
* @param format
Expand All @@ -80,19 +78,17 @@ public class FedoraImport extends AbstractResource {
* @throws URISyntaxException
*/
@POST
public Response importObject(@PathParam("path")
final List<PathSegment> pathList,
@QueryParam("format")
@DefaultValue("jcr/xml")
final String format,
final InputStream stream) throws IOException, RepositoryException,
InvalidChecksumException, URISyntaxException {
public Response importObject(@PathParam("path") final List<PathSegment> pathList,
@QueryParam("format") @DefaultValue("jcr/xml") final String format,
final InputStream stream)
throws IOException, RepositoryException, InvalidChecksumException,
URISyntaxException {

final String path = toPath(pathList);
logger.debug("Deserializing at {}", path);

final HttpGraphSubjects subjects =
new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);
new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);

try {
serializers.getSerializer(format)
Expand Down

0 comments on commit d08914b

Please sign in to comment.