Skip to content

Commit

Permalink
Minor formatting clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Mar 13, 2015
1 parent 042c232 commit be87542
Showing 1 changed file with 48 additions and 50 deletions.
Expand Up @@ -21,6 +21,7 @@
import static com.google.common.collect.Iterators.filter;
import static com.google.common.collect.Iterators.singletonIterator;
import static com.google.common.collect.Iterators.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static com.hp.hpl.jena.update.UpdateAction.execute;
import static com.hp.hpl.jena.update.UpdateFactory.create;
Expand All @@ -39,6 +40,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.jcr.AccessDeniedException;
import javax.jcr.ItemNotFoundException;
Expand Down Expand Up @@ -87,8 +89,8 @@

/**
* Common behaviors across {@link org.fcrepo.kernel.models.Container} and
* {@link org.fcrepo.kernel.models.NonRdfSourceDescription} types; also used when the exact type of an object is
* irrelevant
* {@link org.fcrepo.kernel.models.NonRdfSourceDescription} types; also used
* when the exact type of an object is irrelevant
*
* @author ajs6f
*/
Expand All @@ -100,24 +102,21 @@ public class FedoraResourceImpl extends JcrTools implements FedoraJcrTypes, Fedo

/**
* Construct a {@link org.fcrepo.kernel.models.FedoraResource} from an existing JCR Node
*
* @param node an existing JCR node to treat as an fcrepo object
*/
public FedoraResourceImpl(final Node node) {
this.node = node;
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getNode()
*/
@Override
public Node getNode() {
return node;
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getPath()
*/
@Override
Expand All @@ -129,8 +128,7 @@ public String getPath() {
}
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getChildren()
*/
@Override
Expand All @@ -144,7 +142,6 @@ public Iterator<FedoraResource> getChildren() {

/**
* Get the "good" children for a node by skipping all pairtree nodes in the way.
*
* @param input
* @return
* @throws RepositoryException
Expand All @@ -167,7 +164,6 @@ public Iterator<FedoraResource> apply(final Node input) {
}
});
}

/**
* Children for whom we will not generate triples.
*/
Expand All @@ -188,28 +184,29 @@ public boolean apply(final Node n) {
}
};

private static final Converter<FedoraResource, FedoraResource> datastreamToBinary =
new Converter<FedoraResource, FedoraResource>() {

@Override
protected FedoraResource doForward(final FedoraResource fedoraResource) {
if (fedoraResource instanceof NonRdfSourceDescription) {
return ((NonRdfSourceDescription) fedoraResource).getDescribedResource();
}
return fedoraResource;
}
private static final Converter<FedoraResource, FedoraResource> datastreamToBinary
= new Converter<FedoraResource, FedoraResource>() {

@Override
protected FedoraResource doBackward(final FedoraResource fedoraResource) {
if (fedoraResource instanceof FedoraBinary) {
return ((FedoraBinary) fedoraResource).getDescription();
}
return fedoraResource;
}
};
@Override
protected FedoraResource doForward(final FedoraResource fedoraResource) {
if (fedoraResource instanceof NonRdfSourceDescription) {
return ((NonRdfSourceDescription) fedoraResource).getDescribedResource();
}
return fedoraResource;
}

private static final Converter<Node, FedoraResource> nodeToObjectBinaryConverter = nodeConverter
.andThen(datastreamToBinary);
@Override
protected FedoraResource doBackward(final FedoraResource fedoraResource) {
if (fedoraResource instanceof FedoraBinary) {
return ((FedoraBinary) fedoraResource).getDescription();
}
return fedoraResource;
}
};

private static final Converter<Node, FedoraResource> nodeToObjectBinaryConverter
= nodeConverter.andThen(datastreamToBinary);

@Override
public FedoraResource getContainer() {
Expand Down Expand Up @@ -297,8 +294,7 @@ private void createTombstone(final Node parent, final String path) throws Reposi
findOrCreateChild(parent, path, FEDORA_TOMBSTONE);
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getCreatedDate()
*/
@Override
Expand All @@ -316,8 +312,7 @@ public Date getCreatedDate() {
return null;
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getLastModifiedDate()
*/
@Override
Expand All @@ -343,13 +338,15 @@ public Date getLastModifiedDate() {
return null;
}


@Override
public boolean hasType(final String type) {
try {
if (isFrozen.apply(node) && hasProperty(FROZEN_MIXIN_TYPES)) {
final Iterator<String> types =
transform(property2values.apply(getProperty(FROZEN_MIXIN_TYPES)), value2string);
return Iterators.contains(types, type);
final List<String> types = newArrayList(
transform(property2values.apply(getProperty(FROZEN_MIXIN_TYPES)), value2string)
);
return types.contains(type);
}
return node.isNodeType(type);
} catch (final PathNotFoundException e) {
Expand Down Expand Up @@ -391,19 +388,19 @@ public void updateProperties(final IdentifierConverter<Resource, FedoraResource>

@Override
public RdfStream getTriples(final IdentifierConverter<Resource, FedoraResource> idTranslator,
final Class<? extends RdfStream> context) {
final Class<? extends RdfStream> context) {
return getTriples(idTranslator, Collections.singleton(context));
}

@Override
public RdfStream getTriples(final IdentifierConverter<Resource, FedoraResource> idTranslator,
final Iterable<? extends Class<? extends RdfStream>> contexts) {
final Iterable<? extends Class<? extends RdfStream>> contexts) {
final RdfStream stream = new RdfStream();

for (final Class<? extends RdfStream> context : contexts) {
try {
final Constructor<? extends RdfStream> declaredConstructor =
context.getDeclaredConstructor(FedoraResource.class, IdentifierConverter.class);
final Constructor<? extends RdfStream> declaredConstructor
= context.getDeclaredConstructor(FedoraResource.class, IdentifierConverter.class);

final RdfStream rdfStream = declaredConstructor.newInstance(this, idTranslator);
rdfStream.session(getSession());
Expand Down Expand Up @@ -452,8 +449,7 @@ public VersionHistory getVersionHistory() {
}
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#isNew()
*/
@Override
Expand Down Expand Up @@ -532,8 +528,7 @@ public Statement map1(final Statement stmnt) {
}
}

/*
* (non-Javadoc)
/* (non-Javadoc)
* @see org.fcrepo.kernel.models.FedoraResource#getEtagValue()
*/
@Override
Expand Down Expand Up @@ -662,8 +657,9 @@ private Node getFrozenNode(final String label) throws RepositoryException {
final String baseUUID = getNode().getIdentifier();

/*
* We found a node whose identifier is the "label" for the version. Now we must do due dilligence to make
* sure it's a frozen node representing a version of the subject node.
* We found a node whose identifier is the "label" for the version. Now
* we must do due dilligence to make sure it's a frozen node representing
* a version of the subject node.
*/
final Property p = frozenNode.getProperty("jcr:frozenUuid");
if (p != null) {
Expand All @@ -672,12 +668,14 @@ private Node getFrozenNode(final String label) throws RepositoryException {
}
}
/*
* Though a node with an id of the label was found, it wasn't the node we were looking for, so fall
* through and look for a labeled node.
* Though a node with an id of the label was found, it wasn't the
* node we were looking for, so fall through and look for a labeled
* node.
*/
} catch (final ItemNotFoundException ex) {
/*
* the label wasn't a uuid of a frozen node but instead possibly a version label.
* the label wasn't a uuid of a frozen node but
* instead possibly a version label.
*/
}
return null;
Expand Down

0 comments on commit be87542

Please sign in to comment.