Skip to content

Commit

Permalink
Annotating kernel method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Aug 2, 2013
1 parent d9f5b5e commit e22504e
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 80 deletions.
6 changes: 6 additions & 0 deletions fcrepo-kernel/pom.xml
Expand Up @@ -21,6 +21,12 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions fcrepo-kernel/src/main/java/org/fcrepo/FedoraResource.java
Expand Up @@ -32,8 +32,6 @@
import javax.jcr.Session;
import javax.jcr.version.VersionHistory;

import com.hp.hpl.jena.update.UpdateFactory;
import com.hp.hpl.jena.update.UpdateRequest;
import org.apache.commons.codec.digest.DigestUtils;
import org.fcrepo.rdf.GraphProperties;
import org.fcrepo.rdf.GraphSubjects;
Expand All @@ -49,6 +47,8 @@
import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.update.UpdateAction;
import com.hp.hpl.jena.update.UpdateFactory;
import com.hp.hpl.jena.update.UpdateRequest;

/**
* Common behaviors across FedoraObject and Datastream types; also used
Expand Down
58 changes: 30 additions & 28 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/FedoraTypesUtils.java
Expand Up @@ -60,10 +60,12 @@
import com.google.common.base.Function;
import com.google.common.base.Predicate;

import javax.annotation.Nonnull;

/**
* Convenience class with static methods for manipulating Fedora types in the
* JCR.
*
*
* @author ajs6f
* @date Feb 14, 2013
*/
Expand Down Expand Up @@ -130,7 +132,7 @@ public boolean apply(final Node node) {
new Function<NodeType, String>() {

@Override
public String apply(final NodeType t) {
public String apply(@Nonnull final NodeType t) {
checkArgument(t != null, "null has no name!");
return t.getName();
}
Expand All @@ -143,10 +145,10 @@ public String apply(final NodeType t) {
new Function<Value, String>() {

@Override
public String apply(final Value v) {
public String apply(@Nonnull final Value v) {
checkArgument(v != null, "null has no appropriate "
+ "String representation!");
try {
checkArgument(v != null, "null has no appropriate "
+ "String representation!");
return v.getString();
} catch (final RepositoryException e) {
throw propagate(e);
Expand All @@ -161,7 +163,7 @@ public String apply(final Value v) {
new Predicate<Property>() {

@Override
public boolean apply(final Property p) {
public boolean apply(@Nonnull final Property p) {
checkArgument(p != null,
"null is neither multiple or not multiple!");
try {
Expand All @@ -179,7 +181,7 @@ public boolean apply(final Property p) {
public static Predicate<Node> isInternalNode = new Predicate<Node>() {

@Override
public boolean apply(final Node n) {
public boolean apply(@Nonnull final Node n) {
checkArgument(n != null,
"null is neither multiple or not multiple!");
try {
Expand All @@ -199,10 +201,10 @@ public boolean apply(final Node n) {
new Function<Node, ValueFactory>() {

@Override
public ValueFactory apply(final Node n) {
public ValueFactory apply(@Nonnull final Node n) {
checkArgument(n != null,
"null has no ValueFactory associated with it!");
try {
checkArgument(n != null,
"null has no ValueFactory associated with it!");
return n.getSession().getValueFactory();
} catch (final RepositoryException e) {
throw propagate(e);
Expand Down Expand Up @@ -247,17 +249,17 @@ public com.hp.hpl.jena.rdf.model.Property apply(

/**
* Creates a JCR {@link Binary}
*
*
* @param n a {@link Node}
* @param i an {@link InputStream}
* @return a JCR {@link Binary}
*/
public static Binary getBinary(final Node n, final InputStream i) {
public static Binary getBinary(@Nonnull final Node n, final InputStream i) {
checkArgument(n != null,
"null cannot have a Binary created for it!");
checkArgument(i != null,
"null cannot have a Binary created from it!");
try {
checkArgument(n != null,
"null cannot have a Binary created for it!");
checkArgument(i != null,
"null cannot have a Binary created from it!");
return n.getSession().getValueFactory().createBinary(i);
} catch (final RepositoryException e) {
throw propagate(e);
Expand All @@ -266,18 +268,18 @@ public static Binary getBinary(final Node n, final InputStream i) {

/**
* Creates a JCR {@link Binary}
*
*
* @param n a {@link Node}
* @param i an {@link InputStream}
* @return a JCR {@link Binary}
*/
public static Binary getBinary(final Node n, final InputStream i,
public static Binary getBinary(@Nonnull final Node n, final InputStream i,
final String hint) {
checkArgument(n != null,
"null cannot have a Binary created for it!");
checkArgument(i != null,
"null cannot have a Binary created from it!");
try {
checkArgument(n != null,
"null cannot have a Binary created for it!");
checkArgument(i != null,
"null cannot have a Binary created from it!");
final JcrValueFactory jcrValueFactory =
((JcrValueFactory) n.getSession().getValueFactory());
return jcrValueFactory.createBinary(i, hint);
Expand All @@ -288,7 +290,7 @@ public static Binary getBinary(final Node n, final InputStream i,

/**
* Get the JCR Node Type manager
*
*
* @param node
* @return
* @throws RepositoryException
Expand All @@ -301,7 +303,7 @@ public static NodeTypeManager getNodeTypeManager(final Node node)
/**
* Get the property definition information (containing type and multi-value
* information)
*
*
* @param node the node to use for inferring the property definition
* @param propertyName the property name to retrieve a definition for
* @return a JCR PropertyDefinition, if available, or null
Expand All @@ -325,7 +327,7 @@ public static PropertyDefinition getDefinitionForPropertyName(
/**
* Convenience method for transforming arrays into {@link Collection}s
* through a mapping {@link Function}.
*
*
* @param input A Collection<F>.
* @param f A Function<F,T>.
* @return An ImmutableSet copy of input after transformation by f
Expand All @@ -347,7 +349,7 @@ public static String convertDateToXSDString(final long date) {

/**
* Get the JCR Base version for a node
*
*
* @param node
* @return
* @throws RepositoryException
Expand All @@ -360,7 +362,7 @@ public static Version getBaseVersion(final Node node)

/**
* Get the JCR VersionHistory for an existing node
*
*
* @param node
* @return
* @throws RepositoryException
Expand All @@ -373,7 +375,7 @@ public static VersionHistory getVersionHistory(final Node node)

/**
* Get the JCR VersionHistory for a node at a given JCR path
*
*
* @param session
* @param path
* @return
Expand Down
Expand Up @@ -28,7 +28,6 @@
import javax.jcr.Session;
import javax.jcr.Value;

import com.hp.hpl.jena.vocabulary.RDF;
import org.fcrepo.RdfLexicon;
import org.fcrepo.rdf.GraphSubjects;
import org.slf4j.Logger;
Expand All @@ -37,6 +36,7 @@
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.vocabulary.RDF;

/**
* Listen to Jena statement events, and when the statement is changed in the
Expand All @@ -63,14 +63,14 @@ public class JcrPropertyStatementListener extends StatementListener {
* @throws RepositoryException
*/
public static JcrPropertyStatementListener getListener(
final GraphSubjects subjects, final Session session, Model problemModel)
final GraphSubjects subjects, final Session session, final Model problemModel)
throws RepositoryException {
return new JcrPropertyStatementListener(subjects, session, problemModel);
}

/**
* Construct a statement listener within the given session
*
*
* @param subjects
* @param session
* @throws RepositoryException
Expand All @@ -85,7 +85,7 @@ private JcrPropertyStatementListener(final GraphSubjects subjects,

/**
* When a statement is added to the graph, serialize it to a JCR property
*
*
* @param s
*/
@Override
Expand Down Expand Up @@ -154,7 +154,7 @@ public void addedStatement(final Statement s) {

/**
* When a statement is removed, remove it from the JCR properties
*
*
* @param s
*/
@Override
Expand Down Expand Up @@ -233,14 +233,11 @@ private boolean validateModificationsForPropertyName(
/**
* Get a list of any problems from trying to apply the statement changes to
* the node's properties
*
*
* @return
*/
public Model getProblems() {
return problems;
}

private Session getSession() {
return this.session;
}
}
6 changes: 3 additions & 3 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/JcrRdfTools.java
Expand Up @@ -69,9 +69,6 @@
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import org.fcrepo.RdfLexicon;
import org.fcrepo.rdf.GraphSubjects;
import org.fcrepo.services.LowLevelStorageService;
Expand All @@ -81,8 +78,11 @@
import org.slf4j.Logger;

import com.codahale.metrics.Counter;
import com.google.common.base.Predicate;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.PeekingIterator;
import com.hp.hpl.jena.datatypes.RDFDatatype;
Expand Down
11 changes: 6 additions & 5 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/NamespaceTools.java
Expand Up @@ -17,6 +17,7 @@

import static com.google.common.base.Preconditions.checkArgument;

import javax.annotation.Nonnull;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
Expand Down Expand Up @@ -64,12 +65,12 @@ public static NamespaceRegistry getNamespaceRegistry(final Item item)
*/
public static Function<Node, NamespaceRegistry> getNamespaceRegistry = new Function<Node, NamespaceRegistry>() {
@Override
public NamespaceRegistry apply(final Node n) {
public NamespaceRegistry apply(@Nonnull final Node n) {
checkArgument(n != null,
"null has no Namespace Registry associated " +
"with it!");
try {
checkArgument(n != null,
"null has no Namespace Registry associated " +
"with it!");
return (org.modeshape.jcr.api.NamespaceRegistry)n.getSession().getWorkspace().getNamespaceRegistry();
return (NamespaceRegistry)n.getSession().getWorkspace().getNamespaceRegistry();
} catch (final RepositoryException e) {
throw new IllegalStateException(e);
}
Expand Down
Expand Up @@ -48,7 +48,6 @@
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;

import com.hp.hpl.jena.rdf.model.ModelFactory;
import org.apache.commons.codec.digest.DigestUtils;
import org.fcrepo.rdf.GraphSubjects;
import org.fcrepo.rdf.impl.DefaultGraphSubjects;
Expand All @@ -65,6 +64,7 @@

import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.sparql.util.Symbol;

Expand Down

0 comments on commit e22504e

Please sign in to comment.