Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removing CXF cruft from XML
  • Loading branch information
ajs6f committed Apr 22, 2013
1 parent 9973d85 commit 372c540
Show file tree
Hide file tree
Showing 25 changed files with 129 additions and 220 deletions.
4 changes: 0 additions & 4 deletions fcrepo-generator-dc/pom.xml
Expand Up @@ -114,10 +114,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-cxf-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions fcrepo-generator-dc/src/main/enunciate/enunciate.xml

This file was deleted.

4 changes: 0 additions & 4 deletions fcrepo-http-api/pom.xml
Expand Up @@ -148,10 +148,6 @@
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-cxf-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions fcrepo-http-api/src/main/enunciate/enunciate.xml

This file was deleted.

3 changes: 0 additions & 3 deletions fcrepo-http-api/src/main/resources/logback.xml
Expand Up @@ -9,9 +9,6 @@
<logger name="org.fcrepo" additivity="false" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.apache.cxf" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.modeshape" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
Expand Down
3 changes: 0 additions & 3 deletions fcrepo-http-api/src/test/resources/logback-test.xml
Expand Up @@ -13,9 +13,6 @@
<logger name="org.modeshape" additivity="false" level="WARN">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.apache.cxf" additivity="false" level="WARN">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.apache.http.client" additivity="false" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>
Expand Down
3 changes: 0 additions & 3 deletions fcrepo-kernel/src/test/resources/logback-test.xml
Expand Up @@ -13,9 +13,6 @@
<logger name="org.modeshape" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.apache.cxf" additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</logger>
<root additivity="false" level="INFO">
<appender-ref ref="STDOUT"/>
</root>
Expand Down
10 changes: 0 additions & 10 deletions fcrepo-legacy-api/src/main/enunciate/enunciate.xml

This file was deleted.

Expand Up @@ -8,12 +8,10 @@
import static javax.ws.rs.core.MediaType.TEXT_XML;
import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.ok;
import static org.fcrepo.api.legacy.FedoraObjects.getObjectSize;
import static org.fcrepo.jaxb.responses.management.DatastreamProfile.convertDateToXSDString;
import static org.fcrepo.jaxb.responses.management.DatastreamProfile.DatastreamControlGroup.M;
import static org.fcrepo.jaxb.responses.management.DatastreamProfile.DatastreamStates.A;
import static org.fcrepo.services.PathService.getDatastreamJcrNodePath;
import static org.fcrepo.services.PathService.getObjectJcrNodePath;
import static org.fcrepo.services.ServiceHelpers.getNodePropertySize;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.modeshape.jcr.api.JcrConstants.JCR_DATA;
Expand Down Expand Up @@ -59,7 +57,6 @@
import org.springframework.stereotype.Component;

import com.google.common.collect.ImmutableSet.Builder;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.BodyPart;
import com.sun.jersey.multipart.FormDataParam;
import com.sun.jersey.multipart.MultiPart;
Expand Down Expand Up @@ -97,7 +94,7 @@ public ObjectDatastreams getDatastreams(@PathParam("pid")
final ObjectDatastreams objectDatastreams = new ObjectDatastreams();
final Builder<DatastreamElement> datastreams = builder();

NodeIterator i = objectService.getObjectNode(pid).getNodes();
final NodeIterator i = objectService.getObjectNode(pid).getNodes();
while (i.hasNext()) {
final Node ds = i.nextNode();
datastreams.add(new DatastreamElement(ds.getName(), ds.getName(),
Expand All @@ -111,20 +108,23 @@ public ObjectDatastreams getDatastreams(@PathParam("pid")
@POST
@Path("/")
public Response addDatastreams(@PathParam("pid")
final String pid, final MultiPart multipart)
throws RepositoryException, IOException, InvalidChecksumException {
final String pid, final MultiPart multipart) throws RepositoryException,
IOException, InvalidChecksumException {

final Session session = getAuthenticatedSession();
InputStream src = null;
try {

for (BodyPart part : multipart.getBodyParts()) {
final String dsid = part.getContentDisposition().getParameters().get("name");
for (final BodyPart part : multipart.getBodyParts()) {
final String dsid =
part.getContentDisposition().getParameters()
.get("name");
final String dsPath = getDatastreamJcrNodePath(pid, dsid);
src = part.getEntityAs(InputStream.class);
datastreamService.createDatastreamNode(session, dsPath, part.getMediaType().toString(), src);
datastreamService.createDatastreamNode(session, dsPath, part
.getMediaType().toString(), src);
}

session.save();

} finally {
Expand All @@ -139,32 +139,34 @@ public Response addDatastreams(@PathParam("pid")
@Produces("multipart/mixed")
public Response getDatastreamsContents(@PathParam("pid")
final String pid, @QueryParam("dsid")
List<String> dsids) throws RepositoryException, IOException {
final List<String> dsids) throws RepositoryException, IOException {

final Session session = getAuthenticatedSession();

if (dsids.isEmpty()) {
NodeIterator ni = objectService.getObjectNode(pid).getNodes();
final NodeIterator ni = objectService.getObjectNode(pid).getNodes();
while (ni.hasNext()) {
dsids.add(ni.nextNode().getName());
}
}

try {
MultiPart multipart = new MultiPart();
Iterator<String> i = dsids.iterator();
final MultiPart multipart = new MultiPart();
final Iterator<String> i = dsids.iterator();
while (i.hasNext()) {
final String dsid = i.next();

try {
final Datastream ds =
datastreamService.getDatastream(pid, dsid);
multipart.bodyPart(ds.getContent(), MediaType.valueOf(ds.getMimeType()));
} catch (PathNotFoundException e) {
multipart.bodyPart(ds.getContent(), MediaType.valueOf(ds
.getMimeType()));
} catch (final PathNotFoundException e) {

}
}
return Response.ok(multipart,MediaType.MULTIPART_FORM_DATA).build();
return Response.ok(multipart, MediaType.MULTIPART_FORM_DATA)
.build();
} finally {
session.logout();
}
Expand All @@ -191,14 +193,14 @@ public Response getDatastreamsContents(@PathParam("pid")
public Response addDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, InputStream requestBodyStream)
MediaType contentType, final InputStream requestBodyStream)
throws RepositoryException, IOException, InvalidChecksumException {
final Session session = getAuthenticatedSession();

contentType =
contentType != null ? contentType
: APPLICATION_OCTET_STREAM_TYPE;
String dspath = getDatastreamJcrNodePath(pid, dsid);
final String dspath = getDatastreamJcrNodePath(pid, dsid);

if (!session.nodeExists(dspath)) {
return created(
Expand Down Expand Up @@ -235,11 +237,13 @@ public Response addDatastream(@PathParam("pid")
@Path("/{dsid}")
public Response addDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, final MultiPart multipart) throws RepositoryException, IOException,
InvalidChecksumException {
BodyPart part = multipart.getBodyParts().get(0);
MediaType type = MediaType.valueOf(part.getHeaders().get("Content-Type").get(0));
return addDatastream(pid, dsid, type, part.getEntityAs(InputStream.class));
final String dsid, final MultiPart multipart) throws RepositoryException,
IOException, InvalidChecksumException {
final BodyPart part = multipart.getBodyParts().get(0);
final MediaType type =
MediaType.valueOf(part.getHeaders().get("Content-Type").get(0));
return addDatastream(pid, dsid, type, part
.getEntityAs(InputStream.class));
}

/**
Expand All @@ -263,13 +267,13 @@ public Response addDatastream(@PathParam("pid")
public Response modifyDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, InputStream requestBodyStream)
MediaType contentType, final InputStream requestBodyStream)
throws RepositoryException, IOException, InvalidChecksumException {
final Session session = getAuthenticatedSession();
contentType =
contentType != null ? contentType
: APPLICATION_OCTET_STREAM_TYPE;
String dspath = getDatastreamJcrNodePath(pid, dsid);
final String dspath = getDatastreamJcrNodePath(pid, dsid);

return created(
addDatastreamNode(pid, dspath, contentType, requestBodyStream,
Expand Down Expand Up @@ -299,7 +303,8 @@ public Response modifyDatastream(@PathParam("pid")
public Response modifyDatastreamMultipart(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, @FormDataParam("file") InputStream src) throws RepositoryException, IOException,
final MediaType contentType, @FormDataParam("file")
final InputStream src) throws RepositoryException, IOException,
InvalidChecksumException {

return modifyDatastream(pid, dsid, contentType, src);
Expand Down Expand Up @@ -342,7 +347,7 @@ public DatastreamProfile getDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsId) throws RepositoryException, IOException {
logger.trace("Executing getDatastream() with dsId: " + dsId);
Datastream ds = datastreamService.getDatastream(pid, dsId);
final Datastream ds = datastreamService.getDatastream(pid, dsId);
logger.debug("Retrieved dsNode: " + ds.getNode().getName());
return getDSProfile(ds);

Expand Down Expand Up @@ -435,15 +440,15 @@ public DatastreamHistory getDatastreamHistoryOld(@PathParam("pid")
@DELETE
@Path("/{dsid}")
public Response deleteDatastream(@PathParam("pid")
String pid, @PathParam("dsid")
String dsid) throws RepositoryException {
final String pid, @PathParam("dsid")
final String dsid) throws RepositoryException {
final String dsPath = getDatastreamJcrNodePath(pid, dsid);
final Session session = getAuthenticatedSession();
final Node ds = session.getNode(dsPath);
return deleteResource(ds);
}

private DatastreamProfile getDSProfile(Datastream ds)
private DatastreamProfile getDSProfile(final Datastream ds)
throws RepositoryException, IOException {
logger.trace("Executing getDSProfile() with node: " + ds.getDsId());
final DatastreamProfile dsProfile = new DatastreamProfile();
Expand Down Expand Up @@ -475,21 +480,23 @@ private DatastreamProfile getDSProfile(Datastream ds)
return dsProfile;
}

private String getDSMimeType(Node ds) throws ValueFormatException,
private String getDSMimeType(final Node ds) throws ValueFormatException,
PathNotFoundException, RepositoryException, IOException {
final Binary b =
(Binary) ds.getNode(JCR_CONTENT).getProperty(JCR_DATA)
.getBinary();
return b.getMimeType();
}

public static Long getDatastreamSize(Node ds) throws ValueFormatException,
PathNotFoundException, RepositoryException {
public static Long getDatastreamSize(final Node ds)
throws ValueFormatException, PathNotFoundException,
RepositoryException {
return getNodePropertySize(ds) + getContentSize(ds);
}

public static Long getContentSize(Node ds) throws ValueFormatException,
PathNotFoundException, RepositoryException {
public static Long getContentSize(final Node ds)
throws ValueFormatException, PathNotFoundException,
RepositoryException {
return ds.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary()
.getSize();
}
Expand Down
Expand Up @@ -8,6 +8,9 @@
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.TEXT_XML;

import java.io.IOException;

import javax.jcr.RepositoryException;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -41,18 +44,18 @@ public class FedoraIdentifiers extends AbstractResource {
@Produces({TEXT_XML, APPLICATION_JSON})
public NextPid getNextPid(@QueryParam("numPids")
@DefaultValue("1")
Integer numPids) {
final Integer numPids) {

return new NextPid(copyOf(transform(closed(1, numPids)
.asSet(integers()), makePid)));

}

private Function<Integer, String> makePid =
private final Function<Integer, String> makePid =
new Function<Integer, String>() {

@Override
public String apply(Integer slot) {
public String apply(final Integer slot) {
return pidMinter.mintPid();
}
};
Expand Down
Expand Up @@ -82,7 +82,7 @@ public Response registerObjectNamespaces(final NamespaceListing nses)
try {
final NamespaceRegistry r =
session.getWorkspace().getNamespaceRegistry();
for (Namespace ns : nses.namespaces) {
for (final Namespace ns : nses.namespaces) {
r.registerNamespace(ns.prefix, ns.uri.toString());
}
} finally {
Expand Down
Expand Up @@ -17,7 +17,6 @@

import java.io.IOException;

import javax.inject.Inject;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
Expand Down Expand Up @@ -48,7 +47,7 @@ public class FedoraObjects extends AbstractResource {

private static final Logger logger = LoggerFactory
.getLogger(FedoraObjects.class);

@Autowired
ObjectService objectService;

Expand Down Expand Up @@ -149,7 +148,7 @@ public ObjectProfile getObject(@PathParam("pid")

objectProfile.pid = pid;
if (obj.hasProperty(DC_TITLE)) {
Property dcTitle = obj.getProperty(DC_TITLE);
final Property dcTitle = obj.getProperty(DC_TITLE);
if (!dcTitle.isMultiple()) {
objectProfile.objLabel = obj.getProperty(DC_TITLE).getString();
} else {
Expand Down Expand Up @@ -194,7 +193,7 @@ public Response deleteObject(@PathParam("pid")
* @return object size in bytes
* @throws RepositoryException
*/
static Long getObjectSize(Node obj) throws RepositoryException {
static Long getObjectSize(final Node obj) throws RepositoryException {
return getNodePropertySize(obj) + getObjectDSSize(obj);
}

Expand All @@ -203,11 +202,12 @@ static Long getObjectSize(Node obj) throws RepositoryException {
* @return object's datastreams' total size in bytes
* @throws RepositoryException
*/
private static Long getObjectDSSize(Node obj) throws RepositoryException {
private static Long getObjectDSSize(final Node obj)
throws RepositoryException {
Long size = 0L;
NodeIterator i = obj.getNodes();
final NodeIterator i = obj.getNodes();
while (i.hasNext()) {
Node ds = i.nextNode();
final Node ds = i.nextNode();
size = size + getNodePropertySize(ds);
size = size + getContentSize(ds);
}
Expand Down

0 comments on commit 372c540

Please sign in to comment.