Skip to content

Commit

Permalink
More JavaDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 21, 2013
1 parent 914b035 commit 9f7c318
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
61 changes: 54 additions & 7 deletions fcrepo-kernel/src/main/java/org/fcrepo/services/ObjectService.java
Expand Up @@ -11,7 +11,6 @@
import javax.inject.Inject;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand All @@ -30,25 +29,73 @@ public class ObjectService {
@Inject
private Repository repo;

/**
* For use with non-mutating methods.
*/
private static Session readOnlySession;

/**
* @param session A JCR Session
* @param path JCR path under which to create this object
* @return
* @throws RepositoryException
*/
@Deprecated
public static Node createObjectNodeByPath(final Session session,
final String path) throws RepositoryException {
return new FedoraObject(session, path).getNode();
}

/**
* @param session A JCR Session
* @param name The name (pid) to use to create the object
* @return the JCR node behind the created object
* @throws RepositoryException
*/
public static Node
createObjectNode(final Session session, final String path)
createObjectNode(final Session session, final String name)
throws RepositoryException {
return new FedoraObject(session, path).getNode();
return new FedoraObject(session, getObjectJcrNodePath(name)).getNode();
}

public static Node createObjectNodeByName(final Session session,
/**
* @param session A JCR Session
* @param name The name (pid) to use to create the object
* @return The created object
* @throws RepositoryException
*/
public static FedoraObject createObject(final Session session,
final String name) throws RepositoryException {
return new FedoraObject(session, getObjectJcrNodePath(name)).getNode();
return new FedoraObject(session, getObjectJcrNodePath(name));
}

/**
* @param pid
* @return The JCR node behind the FedoraObject with the proferred PID
* @throws RepositoryException
*/
public static Node getObjectNode(final String pid)
throws PathNotFoundException, RepositoryException {
throws RepositoryException {
logger.trace("Executing getObjectNode() with pid: " + pid);
return readOnlySession.getNode(getObjectJcrNodePath(pid));
return getObject(pid).getNode();
}

/**
* @param pid
* @return A FedoraObject with the proferred PID
* @throws RepositoryException
*/
public static FedoraObject getObject(final String pid)
throws RepositoryException {
logger.trace("Executing getObject() with pid: " + pid);
return new FedoraObject(readOnlySession
.getNode(getObjectJcrNodePath(pid)));
}

/**
* @return A Set of object names (identifiers)
* @throws RepositoryException
*/
public static Set<String> getObjectNames() throws RepositoryException {

Node objects = readOnlySession.getNode(getObjectJcrNodePath(""));
Expand Down
4 changes: 2 additions & 2 deletions fcrepo-kernel/src/test/java/org/fcrepo/DatastreamTest.java
Expand Up @@ -3,7 +3,7 @@

import static org.fcrepo.services.DatastreamService.createDatastreamNode;
import static org.fcrepo.services.DatastreamService.getDatastream;
import static org.fcrepo.services.ObjectService.createObjectNodeByName;
import static org.fcrepo.services.ObjectService.createObjectNode;
import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
Expand All @@ -27,7 +27,7 @@ public class DatastreamTest extends AbstractTest {
@Test
public void testLabel() throws RepositoryException, IOException {
Session session = repo.login();
createObjectNodeByName(session, "testObject");
createObjectNode(session, "testObject");
Node dsNode =
createDatastreamNode(session,
"/objects/testObject/testDatastreamNode",
Expand Down
Expand Up @@ -3,7 +3,7 @@

import static org.fcrepo.services.DatastreamService.createDatastreamNode;
import static org.fcrepo.services.DatastreamService.getDatastream;
import static org.fcrepo.services.ObjectService.createObjectNodeByName;
import static org.fcrepo.services.ObjectService.createObjectNode;
import static org.jgroups.util.Util.assertEquals;
import static org.jgroups.util.Util.assertTrue;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
Expand Down Expand Up @@ -48,7 +48,7 @@ public void testCreateDatastreamNode() throws Exception {
public void testGetDatastreamContentInputStream() throws Exception {
Session session = repository.login();
InputStream is = new ByteArrayInputStream("asdf".getBytes());
createObjectNodeByName(session, "testObject");
createObjectNode(session, "testObject");
createDatastreamNode(session, "/objects/testObject/testDatastreamNode",
"application/octet-stream", is);

Expand Down
Expand Up @@ -113,8 +113,7 @@ public Response ingest(@PathParam("pid")

final Session session = repo.login();
try {
final Node obj =
createObjectNode(session, getObjectJcrNodePath(pid));
final Node obj = createObjectNode(session, pid);
session.save();
/*
* we save before updating the repo size because the act of
Expand Down

0 comments on commit 9f7c318

Please sign in to comment.