Skip to content

Commit

Permalink
address checkstyle violations in fcrepo-kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 26, 2013
1 parent b1faed4 commit 83b5098
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 145 deletions.
157 changes: 103 additions & 54 deletions fcrepo-kernel/src/main/java/org/fcrepo/RdfLexicon.java
@@ -1,84 +1,133 @@
package org.fcrepo;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.ResourceFactory;

import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty;

public final class RdfLexicon {

public static final String INTERNAL_NAMESPACE = "info:fedora/fedora-system:def/internal#";

// MEMBERSHIP
public static final Property HAS_MEMBER_OF_RESULT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasMember");
public static final Property HAS_PARENT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasParent");
public static final Property HAS_CHILD = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasChild");
public static final Property HAS_CHILD_COUNT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#numberOfChildren");
public static final Property HAS_MEMBER_OF_RESULT =
createProperty(INTERNAL_NAMESPACE + "hasMember");
public static final Property HAS_PARENT =
createProperty(INTERNAL_NAMESPACE + "hasParent");
public static final Property HAS_CHILD =
createProperty(INTERNAL_NAMESPACE + "hasChild");
public static final Property HAS_CHILD_COUNT =
createProperty(INTERNAL_NAMESPACE + "numberOfChildren");

// FIXITY
public static final Property IS_FIXITY_RESULT_OF = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#isFixityResultOf");
public static final Property HAS_FIXITY_RESULT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasFixityResult");
public static final Property HAS_FIXITY_STATE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#status");
public static final Property HAS_COMPUTED_CHECKSUM = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#computedChecksum");
public static final Property HAS_COMPUTED_SIZE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#computedSize");

public static final Property HAS_FIXITY_CHECK_COUNT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#numFixityChecks");
public static final Property HAS_FIXITY_ERROR_COUNT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#numFixityErrors");
public static final Property HAS_FIXITY_REPAIRED_COUNT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#numFixityRepaired");
public static final Property IS_FIXITY_RESULT_OF =
createProperty(INTERNAL_NAMESPACE + "isFixityResultOf");
public static final Property HAS_FIXITY_RESULT =
createProperty(INTERNAL_NAMESPACE + "hasFixityResult");
public static final Property HAS_FIXITY_STATE =
createProperty(INTERNAL_NAMESPACE + "status");
public static final Property HAS_COMPUTED_CHECKSUM =
createProperty(INTERNAL_NAMESPACE + "computedChecksum");
public static final Property HAS_COMPUTED_SIZE =
createProperty(INTERNAL_NAMESPACE + "computedSize");

public static final Property HAS_FIXITY_CHECK_COUNT =
createProperty(INTERNAL_NAMESPACE + "numFixityChecks");
public static final Property HAS_FIXITY_ERROR_COUNT =
createProperty(INTERNAL_NAMESPACE + "numFixityErrors");
public static final Property HAS_FIXITY_REPAIRED_COUNT =
createProperty(INTERNAL_NAMESPACE + "numFixityRepaired");


// SEARCH
public static final Property SEARCH_HAS_TOTAL_RESULTS = ResourceFactory.createProperty("http://a9.com/-/spec/opensearch/1.1/totalResults");
public static final Property SEARCH_ITEMS_PER_PAGE = ResourceFactory.createProperty("http://a9.com/-/spec/opensearch/1.1/itemsPerPage");
public static final Property SEARCH_OFFSET = ResourceFactory.createProperty("http://a9.com/-/spec/opensearch/1.1/startIndex");
public static final Property SEARCH_TERMS = ResourceFactory.createProperty("http://a9.com/-/spec/opensearch/1.1/Query#searchTerms");
public static final Property SEARCH_HAS_MORE = ResourceFactory.createProperty("info:fedora/search/hasMoreResults");
public static final Property SEARCH_NEXT_PAGE = ResourceFactory.createProperty("info:fedora/search/next");
public static final Property SEARCH_HAS_TOTAL_RESULTS =
createProperty("http://a9.com/-/spec/opensearch/1.1/totalResults");
public static final Property SEARCH_ITEMS_PER_PAGE =
createProperty("http://a9.com/-/spec/opensearch/1.1/itemsPerPage");
public static final Property SEARCH_OFFSET =
createProperty("http://a9.com/-/spec/opensearch/1.1/startIndex");
public static final Property SEARCH_TERMS =
createProperty("http://a9.com/-/spec/opensearch/1.1/Query#searchTerms");
public static final Property SEARCH_HAS_MORE =
createProperty("info:fedora/search/hasMoreResults");
public static final Property SEARCH_NEXT_PAGE =
createProperty("info:fedora/search/next");

// REPOSITORY INFORMATION
public static final Property HAS_OBJECT_COUNT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#objectCount");
public static final Property HAS_OBJECT_SIZE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#objectSize");
public static final Property HAS_TRANSACTION_SERVICE = ResourceFactory.createProperty("info:fedora/hasTransactionProvider");
public static final Property HAS_NAMESPACE_SERVICE = ResourceFactory.createProperty("info:fedora/hasNamespaces");
public static final Property HAS_SEARCH_SERVICE = ResourceFactory.createProperty("http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#link-type-search");
public static final Property HAS_SITEMAP = ResourceFactory.createProperty("http://microformats.org/wiki/rel-sitemap");
public static final Property HAS_OBJECT_COUNT =
createProperty(INTERNAL_NAMESPACE + "objectCount");
public static final Property HAS_OBJECT_SIZE =
createProperty(INTERNAL_NAMESPACE + "objectSize");
public static final Property HAS_TRANSACTION_SERVICE =
createProperty("info:fedora/hasTransactionProvider");
public static final Property HAS_NAMESPACE_SERVICE =
createProperty("info:fedora/hasNamespaces");
public static final Property HAS_SEARCH_SERVICE =
createProperty("http://www.whatwg.org/specs/web-apps/current-work/"
+ "#link-type-search");
public static final Property HAS_SITEMAP =
createProperty("http://microformats.org/wiki/rel-sitemap");

// NAMESPACES
public static final Property HAS_NAMESPACE_PREFIX = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasNamespace");
public static final Property HAS_NAMESPACE_PREFIX =
createProperty(INTERNAL_NAMESPACE + "hasNamespace");


// OTHER SERVICES
public static final Property HAS_SERIALIZATION = ResourceFactory.createProperty("info:fedora/exportsAs");
public static final Property HAS_VERSION_HISTORY = ResourceFactory.createProperty("info:fedora/hasVersions");
public static final Property HAS_FIXITY_SERVICE = ResourceFactory.createProperty("info:fedora/hasFixity");
public static final Property HAS_FEED = ResourceFactory.createProperty("http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#link-type-feed");
public static final Property HAS_SUBSCRIPTION_SERVICE = ResourceFactory.createProperty("http://microformats.org/wiki/rel-subscription");
public static final Property HAS_SERIALIZATION =
createProperty("info:fedora/exportsAs");
public static final Property HAS_VERSION_HISTORY =
createProperty("info:fedora/hasVersions");
public static final Property HAS_FIXITY_SERVICE =
createProperty("info:fedora/hasFixity");
public static final Property HAS_FEED =
createProperty("http://www.whatwg.org/specs/web-apps/current-work/#feed0");
public static final Property HAS_SUBSCRIPTION_SERVICE =
createProperty("http://microformats.org/wiki/rel-subscription");

// CONTENT
public static final Property HAS_CONTENT = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasContent");
public static final Property IS_CONTENT_OF = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#isContentOf");
public static final Property HAS_LOCATION = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasLocation");
public static final Property HAS_MIME_TYPE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#mimeType");
public static final Property HAS_SIZE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasSize");
public static final Property HAS_CONTENT =
createProperty(INTERNAL_NAMESPACE + "hasContent");
public static final Property IS_CONTENT_OF =
createProperty(INTERNAL_NAMESPACE + "isContentOf");
public static final Property HAS_LOCATION =
createProperty(INTERNAL_NAMESPACE + "hasLocation");
public static final Property HAS_MIME_TYPE =
createProperty(INTERNAL_NAMESPACE + "mimeType");
public static final Property HAS_SIZE =
createProperty(INTERNAL_NAMESPACE + "hasSize");

// VERSIONING
public static final Property HAS_VERSION = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasVersion");
public static final Property HAS_VERSION_LABEL = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasVersionLabel");
public static final Property HAS_VERSION =
createProperty(INTERNAL_NAMESPACE + "hasVersion");
public static final Property HAS_VERSION_LABEL =
createProperty(INTERNAL_NAMESPACE + "hasVersionLabel");

// IMPORTANT JCR PROPERTIES
public static final Property HAS_PRIMARY_IDENTIFIER = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#uuid");
public static final Property HAS_PRIMARY_TYPE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#primaryType");
public static final Property HAS_NODE_TYPE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#hasNodeType");
public static final Property HAS_MIXIN_TYPE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#mixinTypes");

public static final Property CREATED_DATE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#created");
public static final Property CREATED_BY = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#createdBy");


public static final Property LAST_MODIFIED_DATE = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#lastModified");
public static final Property LAST_MODIFIED_BY = ResourceFactory.createProperty("info:fedora/fedora-system:def/internal#lastModifiedBy");


public static final Property RDFS_LABEL = ResourceFactory.createProperty("http://www.w3.org/2000/01/rdf-schema#label");
public static final Property DC_TITLE = ResourceFactory.createProperty("http://purl.org/dc/terms/title");
public static final Property HAS_PRIMARY_IDENTIFIER =
createProperty(INTERNAL_NAMESPACE + "uuid");
public static final Property HAS_PRIMARY_TYPE =
createProperty(INTERNAL_NAMESPACE + "primaryType");
public static final Property HAS_NODE_TYPE =
createProperty(INTERNAL_NAMESPACE + "hasNodeType");
public static final Property HAS_MIXIN_TYPE =
createProperty(INTERNAL_NAMESPACE + "mixinTypes");

public static final Property CREATED_DATE =
createProperty(INTERNAL_NAMESPACE + "created");
public static final Property CREATED_BY =
createProperty(INTERNAL_NAMESPACE + "createdBy");


public static final Property LAST_MODIFIED_DATE =
createProperty(INTERNAL_NAMESPACE + "lastModified");
public static final Property LAST_MODIFIED_BY =
createProperty(INTERNAL_NAMESPACE + "lastModifiedBy");


public static final Property RDFS_LABEL =
createProperty("http://www.w3.org/2000/01/rdf-schema#label");
public static final Property DC_TITLE =
createProperty("http://purl.org/dc/terms/title");

private RdfLexicon() {

Expand Down
4 changes: 0 additions & 4 deletions fcrepo-kernel/src/main/java/org/fcrepo/Transaction.java
Expand Up @@ -59,10 +59,6 @@ public Session getSession() {
return TxAwareSession.newInstance(session, id);
}

public Session getJcrSession() {
return session;
}

/**
* @todo Add Documentation.
*/
Expand Down
22 changes: 21 additions & 1 deletion fcrepo-kernel/src/main/java/org/fcrepo/TxAwareSession.java
Expand Up @@ -4,17 +4,37 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import static java.lang.reflect.Proxy.newProxyInstance;

/**
* A dynamic proxy that wraps JCR sessions. It is aware of fcrepo transactions, and
* turns mutating methods (e.g. logout, session) into no-ops. Those
* no-op'ed methods should be called from the Transaction level instead.
*/
public class TxAwareSession implements InvocationHandler {
private final String txId;
private Session session;

/**
* @param session a JCR session
* @param txID the transaction identifier
*/
public TxAwareSession(final Session session, final String txID) {
this.session = session;
this.txId = txID;
}

/**
* Wrap a JCR session with this dynamic proxy
*
* @param session a JCR session
* @param txId the transaction identifier
* @return a wrapped JCR session
*/
public static Session newInstance(final Session session, final String txId) {
return (Session) java.lang.reflect.Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[] { TxSession.class }, new TxAwareSession(session, txId));
return (Session) newProxyInstance(session.getClass().getClassLoader(),
new Class[]{TxSession.class},
new TxAwareSession(session, txId));
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions fcrepo-kernel/src/main/java/org/fcrepo/TxSession.java
Expand Up @@ -2,6 +2,12 @@

import javax.jcr.Session;

/**
* Additional methods introduced by our transaction-aware session
*/
public interface TxSession extends Session {
/**
* @return the transaction identifier associated with this session
*/
String getTxId();
}
Expand Up @@ -2,10 +2,17 @@

import javax.jcr.RepositoryException;

/**
* A transaction was not found in the transaction registry
*/
public class TransactionMissingException extends RepositoryException {

private static final long serialVersionUID = 2139084821001303830L;

/**
*
* @param s the exception message
*/
public TransactionMissingException(final String s) {
super(s);
}
Expand Down
Expand Up @@ -17,11 +17,21 @@ public class UUIDPathMinter extends BasePidMinter {
private final int length;
private final int count;

/**
* Configure the path minter using some reasonable defaults for
* the length (2) and count (4) of the branch nodes
*/
public UUIDPathMinter() {
this(2,4);

}

/**
* Configure the path minter for the length of the keys and depth of
* the branch node prefix
*
* @param length how long the branch node identifiers should be
* @param count how many branch nodes should be inserted
*/
public UUIDPathMinter(final int length, final int count) {
this.length = length;
this.count = count;
Expand Down
7 changes: 7 additions & 0 deletions fcrepo-kernel/src/main/java/org/fcrepo/rdf/GraphSubjects.java
Expand Up @@ -41,5 +41,12 @@ Node getNodeFromGraphSubject(final Session session, final Resource subject)
*/
boolean isFedoraGraphSubject(final Resource subject);

/**
* Get the RDF resource for an absolute path
*
* @param absPath the absolute path to the JCR node
* @return an RDF URI resource
* @throws RepositoryException
*/
Resource getGraphSubject(String absPath) throws RepositoryException;
}

0 comments on commit 83b5098

Please sign in to comment.