Skip to content

Commit

Permalink
Slight factoring to use already-present utility methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 19, 2013
1 parent 87ccd5a commit a734325
Showing 1 changed file with 4 additions and 13 deletions.
Expand Up @@ -20,7 +20,6 @@

import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
import javax.jcr.observation.Event;
import javax.jms.JMSException;
import javax.jms.Message;
Expand All @@ -29,6 +28,7 @@
import org.apache.abdera.model.Category;
import org.apache.abdera.model.Entry;
import org.apache.abdera.parser.Parser;
import org.fcrepo.utils.FedoraTypesUtils;

public class LegacyMethod {

Expand Down Expand Up @@ -73,9 +73,9 @@ public class LegacyMethod {

public LegacyMethod(Event jcrEvent, Node resource) throws RepositoryException {
this(newEntry());
NodeType [] nodeTypes = resource.getMixinNodeTypes();
boolean isDatastreamNode = testNodeTypes(nodeTypes, "fedora:datastream");
boolean isObjectNode = testNodeTypes(nodeTypes, "fedora:object") && !isDatastreamNode;

boolean isDatastreamNode = FedoraTypesUtils.isFedoraDatastream.apply(resource);
boolean isObjectNode = FedoraTypesUtils.isFedoraObject.apply(resource) && !isDatastreamNode;

if (isDatastreamNode || isObjectNode) {
setMethodName(mapMethodName(jcrEvent, isObjectNode));
Expand Down Expand Up @@ -192,15 +192,6 @@ private static String getEntryContent(String methodName, String returnVal) {
return objectToString(returnVal, datatype);
}

private static boolean testNodeTypes(NodeType [] nodeTypes, String type) {
boolean result = false;
for (NodeType nt: nodeTypes) {
result |= type.equals(nt.getName());
if (result) break;
}
return result;
}

private static String objectToString(String obj, String xsdType) {
if (obj == null) {
return "null";
Expand Down

0 comments on commit a734325

Please sign in to comment.