Skip to content

Commit

Permalink
fixed repository going to negative
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Nguyen committed Mar 12, 2013
1 parent f1c1edd commit 1801499
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
38 changes: 19 additions & 19 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraDatastreams.java
Expand Up @@ -75,7 +75,7 @@ public class FedoraDatastreams extends AbstractResource {

/**
* Returns a list of datastreams for the object
*
*
* @param pid
* persistent identifier of the digital object
* @return the list of datastreams
Expand Down Expand Up @@ -182,7 +182,7 @@ public MultipartBody getDatastreamsContents(@PathParam("pid")

/**
* Create a new datastream with user provided checksum for validation
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand Down Expand Up @@ -224,10 +224,10 @@ public Response addDatastream(@PathParam("pid")
}

}

/**
* Create a new datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -247,14 +247,14 @@ public Response addDatastream(@PathParam("pid")
final String dsid, @HeaderParam("Content-Type")
MediaType contentType, InputStream requestBodyStream)
throws RepositoryException, IOException {

return addDatastream(pid, null, null, dsid, contentType, requestBodyStream);

}

/**
* Modify an existing datastream's content
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand Down Expand Up @@ -294,9 +294,9 @@ private URI addDatastreamNode(final String pid, final String dsPath,
getObjectSize(session.getNode(getObjectJcrNodePath(pid)));
logger.debug("Attempting to add datastream node at path: " + dsPath);
try {
boolean created = session.nodeExists(dsPath);
createDatastreamNode(session, dsPath, contentType.toString(),
requestBodyStream, checksumType, checksum);
boolean created = session.nodeExists(dsPath);
session.save();
if (created) {
/*
Expand All @@ -311,7 +311,7 @@ private URI addDatastreamNode(final String pid, final String dsPath,
session.save();
}
logger.debug("Finished adding datastream node at path: " + dsPath);
} catch (InvalidChecksumException e) {
} catch (InvalidChecksumException e) {
logger.error("Checksum Mismatch Exception");
logger.debug("No datastream has been added");
session.logout();
Expand All @@ -323,7 +323,7 @@ private URI addDatastreamNode(final String pid, final String dsPath,

/**
* Get the datastream profile of a datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -348,7 +348,7 @@ public DatastreamProfile getDatastream(@PathParam("pid")

/**
* Get the binary content of a datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand Down Expand Up @@ -383,7 +383,7 @@ public Response getDatastreamContent(@PathParam("pid")

/**
* Get previous version information for this datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsId
Expand Down Expand Up @@ -413,9 +413,9 @@ DatastreamHistory getDatastreamHistory(@PathParam("pid")
/**
* Get previous version information for this datastream. See
* /{dsid}/versions. Kept for compatibility with fcrepo <3.5 API.
*
*
* @deprecated
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -434,7 +434,7 @@ public DatastreamHistory getDatastreamHistoryOld(@PathParam("pid")
final String dsid) throws RepositoryException, IOException {
return getDatastreamHistory(pid, dsid);
}

@GET
@Path("/{dsid}/fixity")
@Produces({TEXT_XML, APPLICATION_JSON})
Expand All @@ -446,7 +446,7 @@ public DatastreamFixity getDatastreamFixity(@PathParam("pid")
DatastreamFixity dsf = validatedDatastreamFixity(ds);
return dsf;
}

/**
* Computes the size and sha1 of a datastream and compares
* it to that stored in the node properties
Expand All @@ -466,17 +466,17 @@ private DatastreamFixity validatedDatastreamFixity(Datastream ds) throws Reposit
URI dsChecksum = ds.getContentDigest();
long dsSize = ds.getContentSize();
String dsChecksumStr = ContentDigest.asChecksumString(dsChecksum);

DatastreamFixity dsf = new DatastreamFixity();
dsf.validChecksum = false;
dsf.validSize = false;
dsf.dsChecksumType = ds.getContentDigestType();
dsf.dsChecksum = dsChecksum;
dsf.dsSize = dsSize;

logger.debug("Validated checksum: " + compChecksum);
logger.debug("Validated size is " + compSize);

if (compChecksum.equals(dsChecksumStr)) {
dsf.validChecksum = true;
}
Expand All @@ -489,7 +489,7 @@ private DatastreamFixity validatedDatastreamFixity(Datastream ds) throws Reposit

/**
* Purge the datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand Down
Expand Up @@ -70,7 +70,7 @@ public class FedoraDatastreams extends AbstractResource {

/**
* Returns a list of datastreams for the object
*
*
* @param pid
* persistent identifier of the digital object
* @return the list of datastreams
Expand Down Expand Up @@ -177,7 +177,7 @@ public MultipartBody getDatastreamsContents(@PathParam("pid")

/**
* Create a new datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -189,7 +189,7 @@ public MultipartBody getDatastreamsContents(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
* @throws InvalidChecksumException
*/
@POST
@Path("/{dsid}")
Expand Down Expand Up @@ -233,7 +233,7 @@ public Response addDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
* @throws InvalidChecksumException
*/
@POST
@Consumes("multipart/form-data")
Expand All @@ -249,7 +249,7 @@ public Response addDatastream(@PathParam("pid")

/**
* Modify an existing datastream's content
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -261,7 +261,7 @@ public Response addDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
* @throws InvalidChecksumException
*/
@PUT
@Path("/{dsid}")
Expand Down Expand Up @@ -296,7 +296,7 @@ public Response modifyDatastream(@PathParam("pid")
* @return 201 Created
* @throws RepositoryException
* @throws IOException
* @throws InvalidChecksumException
* @throws InvalidChecksumException
*/
@PUT
@Consumes("multipart/form-data")
Expand All @@ -320,9 +320,9 @@ private URI addDatastreamNode(final String pid, final String dsPath,
getObjectSize(session.getNode(getObjectJcrNodePath(pid)));
logger.debug("Attempting to add datastream node at path: " + dsPath);
try {
boolean created = session.nodeExists(dsPath);
createDatastreamNode(session, dsPath, contentType.toString(),
requestBodyStream);
boolean created = session.nodeExists(dsPath);

This comment has been minimized.

Copy link
@cbeer

cbeer Mar 12, 2013

Contributor

After calling createDatastreamNode, that node better exist. I think this was supposed to be a check if the method was creating or updating a datastream, but maybe we've lost that now?

This comment has been minimized.

Copy link
@vincentwin

vincentwin Mar 12, 2013

Contributor

I'm not sure what the original intention was behind that. Do we need to handle datastream updates here? If not, can we remove the check?

This comment has been minimized.

Copy link
@cbeer

cbeer Mar 12, 2013

Contributor

@ajs6f can you chime in?

This comment has been minimized.

Copy link
@ajs6f

ajs6f Mar 12, 2013

Contributor

No, it wasn't a check. It was different logic to calculate the size change depending on whether this is a new datastream or a changed one. That's why it was before the mutation. I don't know whether it is still relevant.

session.save();
if (created) {
/*
Expand All @@ -345,7 +345,7 @@ private URI addDatastreamNode(final String pid, final String dsPath,

/**
* Get the datastream profile of a datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -370,7 +370,7 @@ public DatastreamProfile getDatastream(@PathParam("pid")

/**
* Get the binary content of a datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -390,7 +390,7 @@ public Response getDatastreamContent(@PathParam("pid")

/**
* Get previous version information for this datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsId
Expand Down Expand Up @@ -420,9 +420,9 @@ DatastreamHistory getDatastreamHistory(@PathParam("pid")
/**
* Get previous version information for this datastream. See
* /{dsid}/versions. Kept for compatibility with fcrepo <3.5 API.
*
*
* @deprecated
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand All @@ -444,7 +444,7 @@ public DatastreamHistory getDatastreamHistoryOld(@PathParam("pid")

/**
* Purge the datastream
*
*
* @param pid
* persistent identifier of the digital object
* @param dsid
Expand Down

0 comments on commit 1801499

Please sign in to comment.