Skip to content

Commit

Permalink
use the new, on-demand repository calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 22, 2013
1 parent 559e8ff commit dc6fe90
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Expand Up @@ -70,6 +70,7 @@ public void testDescribeSize() throws Exception {
}

assertEquals(201, getStatus(postObjMethod("fdhgsldfhg")));
assertEquals(201, getStatus(postDSMethod("fdhgsldfhg", "asdf", "1234")));

HttpGet newDescribeMethod = new HttpGet(serverAddress + "describe");
newDescribeMethod.addHeader("Accept", TEXT_XML);
Expand Down
Expand Up @@ -20,6 +20,7 @@
import javax.ws.rs.core.UriInfo;

import org.fcrepo.identifiers.PidMinter;
import org.fcrepo.services.ObjectService;
import org.modeshape.jcr.api.JcrTools;
import org.modeshape.jcr.api.Repository;
import org.slf4j.Logger;
Expand Down Expand Up @@ -49,6 +50,14 @@ public abstract class AbstractResource {
@Inject
protected Repository repo;


/**
* The fcrepo object service
*/
@Inject
protected ObjectService objectService;


/**
* A resource that can mint new Fedora PIDs.
*/
Expand Down Expand Up @@ -144,7 +153,7 @@ protected void updateRepositorySize(Long change, Session session)

protected Long getRepositorySize(Session session) {
try {
return session.getNode("/objects").getProperty("fedora:size").getLong();
return objectService.getAllObjectsDatastreamSize();
} catch(RepositoryException e) {
logger.warn(e.toString());
return -1L;
Expand Down
Expand Up @@ -123,9 +123,9 @@ public Set<String> getObjectNames() throws RepositoryException {
* @return a double of the size of the fedora:datastream binary content
* @throws RepositoryException
*/
public double getAllObjectsDatastreamSize() throws RepositoryException {
public long getAllObjectsDatastreamSize() throws RepositoryException {

double sum = 0;
long sum = 0;
javax.jcr.query.QueryManager queryManager = readOnlySession.getWorkspace().getQueryManager();

String querystring = "\n" +
Expand All @@ -142,7 +142,7 @@ public double getAllObjectsDatastreamSize() throws RepositoryException {
final Row row = rows.nextRow();
final Value value = row.getValue("fedora:size");

sum = sum + value.getDouble();
sum = sum + value.getLong();
}

return sum;
Expand Down
Expand Up @@ -92,6 +92,8 @@ public void testDescribeSize() throws Exception {
}

assertEquals(201, getStatus(postObjMethod("fdhgsldfhg")));
assertEquals(201, getStatus(postDSMethod("fdhgsldfhg", "asdf", "1234")));


HttpGet newDescribeMethod = new HttpGet(serverAddress + "describe");
newDescribeMethod.addHeader("Accept", TEXT_XML);
Expand Down

0 comments on commit dc6fe90

Please sign in to comment.