Skip to content

Commit

Permalink
Changed org.fcrepo.exceptionhandlers to org.fcrepo.exception and alte…
Browse files Browse the repository at this point in the history
…red inheritance of InvalidChecksumException

There are no ExceptionHandlers in that package, and because fcrepo-kernel does not use JAX-RS, there never will be.
Additionally, an invalid checksum is _not_ a JCR exception. It's an exception for the Fedora semantics.
  • Loading branch information
ajs6f committed Mar 10, 2013
1 parent c22f99f commit e0ab6ce
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
Expand Up @@ -51,7 +51,7 @@
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
import org.fcrepo.AbstractResource;
import org.fcrepo.Datastream;
import org.fcrepo.exceptionhandlers.InvalidChecksumException;
import org.fcrepo.exception.InvalidChecksumException;
import org.fcrepo.jaxb.responses.access.ObjectDatastreams;
import org.fcrepo.jaxb.responses.access.ObjectDatastreams.DatastreamElement;
import org.fcrepo.jaxb.responses.management.DatastreamHistory;
Expand Down Expand Up @@ -104,7 +104,7 @@ public ObjectDatastreams getDatastreams(@PathParam("pid")
@Path("/")
public Response addDatastreams(@PathParam("pid")
final String pid, final List<Attachment> attachmentList)
throws RepositoryException, IOException {
throws RepositoryException, IOException, InvalidChecksumException {

final Session session = repo.login();
try {
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-kernel/src/main/java/org/fcrepo/Datastream.java
Expand Up @@ -21,7 +21,7 @@
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.version.VersionException;

import org.fcrepo.exceptionhandlers.InvalidChecksumException;
import org.fcrepo.exception.InvalidChecksumException;
import org.fcrepo.utils.ContentDigest;
import org.modeshape.jcr.api.Binary;
import org.modeshape.jcr.api.JcrTools;
Expand Down
@@ -0,0 +1,11 @@

package org.fcrepo.exception;

public class InvalidChecksumException extends Exception {

private static final long serialVersionUID = 1L;

public InvalidChecksumException(String message) {
super(message);
}
}

This file was deleted.

Expand Up @@ -22,7 +22,7 @@
import javax.jcr.Session;

import org.fcrepo.Datastream;
import org.fcrepo.exceptionhandlers.InvalidChecksumException;
import org.fcrepo.exception.InvalidChecksumException;
import org.modeshape.jcr.api.JcrTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
13 changes: 7 additions & 6 deletions fcrepo-kernel/src/test/java/org/fcrepo/DatastreamTest.java
Expand Up @@ -17,6 +17,7 @@
import javax.jcr.Session;

import org.apache.commons.io.IOUtils;
import org.fcrepo.exception.InvalidChecksumException;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;

Expand All @@ -27,7 +28,7 @@ public class DatastreamTest extends AbstractTest {
Repository repo;

@Test
public void testLabel() throws RepositoryException, IOException {
public void testLabel() throws RepositoryException, IOException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
Node dsNode =
Expand All @@ -45,7 +46,7 @@ public void testLabel() throws RepositoryException, IOException {
}

@Test
public void testCreatedDate() throws RepositoryException, IOException {
public void testCreatedDate() throws RepositoryException, IOException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
createDatastreamNode(session,
Expand All @@ -60,7 +61,7 @@ public void testCreatedDate() throws RepositoryException, IOException {
}

@Test
public void testDatastreamContent() throws IOException, RepositoryException {
public void testDatastreamContent() throws IOException, RepositoryException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
createDatastreamNode(session,
Expand All @@ -78,7 +79,7 @@ public void testDatastreamContent() throws IOException, RepositoryException {
}

@Test
public void testDatastreamContentDigestAndLength() throws IOException, RepositoryException {
public void testDatastreamContentDigestAndLength() throws IOException, RepositoryException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
createDatastreamNode(session,
Expand All @@ -101,7 +102,7 @@ public void testDatastreamContentDigestAndLength() throws IOException, Repositor
}

@Test
public void testModifyDatastreamContentDigestAndLength() throws IOException, RepositoryException {
public void testModifyDatastreamContentDigestAndLength() throws IOException, RepositoryException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
createDatastreamNode(session,
Expand All @@ -126,7 +127,7 @@ public void testModifyDatastreamContentDigestAndLength() throws IOException, Rep
}

@Test
public void testDatastreamContentWithChecksum() throws IOException, RepositoryException {
public void testDatastreamContentWithChecksum() throws IOException, RepositoryException, InvalidChecksumException {
Session session = repo.login();
createObjectNode(session, "testObject");
createDatastreamNode(session,
Expand Down
Expand Up @@ -50,6 +50,7 @@
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
import org.fcrepo.AbstractResource;
import org.fcrepo.Datastream;
import org.fcrepo.exception.InvalidChecksumException;
import org.fcrepo.jaxb.responses.access.ObjectDatastreams;
import org.fcrepo.jaxb.responses.access.ObjectDatastreams.DatastreamElement;
import org.fcrepo.jaxb.responses.management.DatastreamHistory;
Expand Down Expand Up @@ -102,7 +103,7 @@ public ObjectDatastreams getDatastreams(@PathParam("pid")
@Path("/")
public Response addDatastreams(@PathParam("pid")
final String pid, final List<Attachment> attachmentList)
throws RepositoryException, IOException {
throws RepositoryException, IOException, InvalidChecksumException {

final Session session = repo.login();
try {
Expand Down Expand Up @@ -188,14 +189,15 @@ public MultipartBody getDatastreamsContents(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
*/
@POST
@Path("/{dsid}")
public Response addDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, InputStream requestBodyStream)
throws RepositoryException, IOException {
throws RepositoryException, IOException, InvalidChecksumException {
final Session session = repo.login();

contentType =
Expand Down Expand Up @@ -231,6 +233,7 @@ public Response addDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
*/
@POST
@Consumes("multipart/form-data")
Expand All @@ -239,7 +242,7 @@ public Response addDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, @Multipart("file")
Attachment file) throws RepositoryException, IOException {
Attachment file) throws RepositoryException, IOException, InvalidChecksumException {
return addDatastream(pid, dsid, file.getContentType(), file
.getDataHandler().getInputStream());
}
Expand All @@ -258,14 +261,15 @@ public Response addDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
*/
@PUT
@Path("/{dsid}")
public Response modifyDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, InputStream requestBodyStream)
throws RepositoryException, IOException {
throws RepositoryException, IOException, InvalidChecksumException {
final Session session = repo.login();
contentType =
contentType != null ? contentType
Expand All @@ -292,6 +296,7 @@ public Response modifyDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
*/
@PUT
@Consumes("multipart/form-data")
Expand All @@ -300,7 +305,7 @@ public Response modifyDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, @Multipart("file")
Attachment file) throws RepositoryException, IOException {
Attachment file) throws RepositoryException, IOException, InvalidChecksumException {

return modifyDatastream(pid, dsid, file.getContentType(), file
.getDataHandler().getInputStream());
Expand All @@ -309,7 +314,7 @@ public Response modifyDatastream(@PathParam("pid")

private URI addDatastreamNode(final String pid, final String dsPath,
final MediaType contentType, final InputStream requestBodyStream,
final Session session) throws RepositoryException, IOException {
final Session session) throws RepositoryException, IOException, InvalidChecksumException {

Long oldObjectSize =
getObjectSize(session.getNode(getObjectJcrNodePath(pid)));
Expand Down

0 comments on commit e0ab6ce

Please sign in to comment.