Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Changed FedoraObject.getObjectDSSize() to filter to counting …
…only datastreams, not other nodes"

This reverts commit ba66ff1.
  • Loading branch information
ajs6f committed Mar 29, 2013
1 parent ba66ff1 commit f86e3eb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 61 deletions.
5 changes: 0 additions & 5 deletions fcrepo-kernel/pom.xml
Expand Up @@ -72,11 +72,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>

<build>
Expand Down
17 changes: 3 additions & 14 deletions fcrepo-kernel/src/main/java/org/fcrepo/Datastream.java
Expand Up @@ -32,7 +32,6 @@
import org.fcrepo.services.LowLevelStorageService;
import org.fcrepo.utils.ContentDigest;
import org.fcrepo.utils.FedoraJcrTypes;
import org.fcrepo.utils.Funktion;
import org.modeshape.jcr.api.Binary;
import org.modeshape.jcr.api.JcrTools;
import org.slf4j.Logger;
Expand All @@ -53,11 +52,11 @@ public class Datastream extends JcrTools implements FedoraJcrTypes {
Datastream.class, "content-size"));

Node node;

LowLevelStorageService llStore;

public Datastream(Node n) {
super(false); // turn off debug logging
super(false); // turn off debug logging
this.node = n;
}

Expand All @@ -68,7 +67,7 @@ public Datastream(final Session session, String pid, String dsId)

public Datastream(final Session session, final String dsPath)
throws RepositoryException {
super(false);
super(false);
this.node = findOrCreateNode(session, dsPath, NT_FILE);
if (this.node.isNew()) {
this.node.addMixin(FEDORA_DATASTREAM);
Expand All @@ -86,16 +85,6 @@ public Datastream(final Session session, final String dsPath)
}
}

public static Funktion<Node, Datastream> node2Datastream =
new Funktion<Node, Datastream>() {

@Override
public Datastream apply(Node n) {
return new Datastream(n);
}

};

/**
* @return The backing JCR node.
*/
Expand Down
42 changes: 19 additions & 23 deletions fcrepo-kernel/src/main/java/org/fcrepo/FedoraObject.java
@@ -1,17 +1,10 @@

package org.fcrepo;

import static ch.lambdaj.Lambda.aggregate;
import static ch.lambdaj.Lambda.extract;
import static ch.lambdaj.Lambda.on;
import static com.google.common.base.Joiner.on;
import static com.google.common.collect.Iterators.filter;
import static com.google.common.collect.Iterators.transform;
import static com.yammer.metrics.MetricRegistry.name;
import static org.fcrepo.Datastream.node2Datastream;
import static org.fcrepo.services.RepositoryService.metrics;
import static org.fcrepo.services.ServiceHelpers.getNodePropertySize;
import static org.fcrepo.utils.FedoraTypesUtils.isFedoraDatastream;
import static org.fcrepo.utils.FedoraTypesUtils.isOwned;
import static org.fcrepo.utils.FedoraTypesUtils.map;
import static org.fcrepo.utils.FedoraTypesUtils.nodetype2name;
Expand All @@ -22,16 +15,14 @@
import java.util.Collection;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.fcrepo.utils.FedoraJcrTypes;
import org.fcrepo.utils.FedoraNodeIterator;
import org.modeshape.jcr.api.JcrTools;

import ch.lambdaj.function.aggregate.Sum;

import com.yammer.metrics.Timer;

/**
Expand Down Expand Up @@ -100,10 +91,10 @@ public void setOwnerId(String ownerId) throws RepositoryException {
node.setProperty(FEDORA_OWNERID, ownerId);
}
}

public String getLabel() throws RepositoryException {
if (node.hasProperty(DC_TITLE)) {
final Property dcTitle = node.getProperty(DC_TITLE);
Property dcTitle = node.getProperty(DC_TITLE);
if (!dcTitle.isMultiple())
return node.getProperty(DC_TITLE).getString();
else {
Expand All @@ -112,25 +103,26 @@ public String getLabel() throws RepositoryException {
}
return null;
}


public void setLabel(String label) throws RepositoryException {
node.setProperty(DC_TITLE, label);
}

public String getCreated() throws RepositoryException {
return node.getProperty("jcr:created").getString();
return node.getProperty("jcr:created").getString();
}

public String getLastModified() throws RepositoryException {
return node.getProperty("jcr:lastModified").getString();
return node.getProperty("jcr:lastModified").getString();
}

public long getSize() throws RepositoryException {
return getObjectSize(node);
return getObjectSize(node);
}

public Collection<String> getModels() throws RepositoryException {
return map(node.getMixinNodeTypes(), nodetype2name);
return map(node.getMixinNodeTypes(), nodetype2name);
}

/**
Expand All @@ -148,9 +140,13 @@ static Long getObjectSize(Node obj) throws RepositoryException {
* @throws RepositoryException
*/
private static Long getObjectDSSize(Node obj) throws RepositoryException {
return (Long) aggregate(extract(transform(filter(new FedoraNodeIterator(obj
.getNodes()), isFedoraDatastream), node2Datastream), on(
Datastream.class).getSize()), new Sum());
Long size = 0L;
NodeIterator i = obj.getNodes();
while (i.hasNext()) {
Datastream ds = new Datastream(i.nextNode());
size += ds.getSize();
}
return size;
}

}
Expand Up @@ -79,8 +79,8 @@ public boolean apply(Node node) {
/**
* Translates a node type to its name.
*/
static public Funktion<NodeType, String> nodetype2name =
new Funktion<NodeType, String>() {
static public Function<NodeType, String> nodetype2name =
new Function<NodeType, String>() {

@Override
public String apply(NodeType t) {
Expand All @@ -91,8 +91,8 @@ public String apply(NodeType t) {
/**
* Translates a JCR value to its string expression.
*/
public static Funktion<Value, String> value2string =
new Funktion<Value, String>() {
public static Function<Value, String> value2string =
new Function<Value, String>() {

@Override
public String apply(Value v) {
Expand Down
15 changes: 0 additions & 15 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/Funktion.java

This file was deleted.

0 comments on commit f86e3eb

Please sign in to comment.