Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added even more Javadocs
  • Loading branch information
ajs6f committed Feb 26, 2013
1 parent 64d262f commit ed29128
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 2 deletions.
29 changes: 28 additions & 1 deletion fcrepo-kernel/src/main/java/org/fcrepo/Datastream.java
Expand Up @@ -19,7 +19,7 @@
import javax.jcr.version.VersionException;

/**
* Abstraction for Fedora datastreams.
* Abstraction for a Fedora datastream backed by a JCR node.
*
* @author ajs6f
*
Expand All @@ -32,33 +32,60 @@ public Datastream(Node n) {
this.node = n;
}

/**
* @return The backing JCR node.
*/
public Node getNode() {
return node;
}

/**
* @return The InputStream of content associated with this datastream.
* @throws RepositoryException
*/
public InputStream getContent() throws RepositoryException {
return node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary()
.getStream();
}

/**
* @return The size in bytes of content associated with this datastream.
* @throws RepositoryException
*/
public long getContentSize() throws RepositoryException {
return node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary()
.getSize();
}

/**
* @return The ID of this datastream, unique within an object. Normally just the name of the backing JCR node.
* @throws RepositoryException
*/
public String getDsId() throws RepositoryException {
return node.getName();
}

/**
* @return the FedoraObject to which this datastream belongs.
* @throws RepositoryException
*/
public FedoraObject getObject() throws RepositoryException {
return new FedoraObject(node.getParent());
}

/**
* @return The MimeType of content associated with this datastream.
* @throws RepositoryException
*/
public String getMimeType() throws RepositoryException {
return node.hasProperty("fedora:contentType") ? node.getProperty(
"fedora:contentType").getString() : "application/octet-stream";
}

/**
* @return A label associated with this datastream. Normally stored in a String-valued dc:title property.
* @throws RepositoryException
*/
public String getLabel() throws RepositoryException {
if (node.hasProperty(DC_TITLE)) {

Expand Down
@@ -1,5 +1,12 @@
package org.fcrepo.identifiers;

/**
* Defines the behavior of a component that can accept responsibility
* for the creation of Fedora PIDs.
*
* @author ajs6f
*
*/
public interface PidMinter {

public String mintPid();
Expand Down
@@ -1,10 +1,18 @@
package org.fcrepo.identifiers;

import static java.util.UUID.randomUUID;

/**
* Simple PidMinter that replies on Java's inbuilt UUID minting.
*
* @author ajs6f
*
*/
public class UUIDPidMinter implements PidMinter {

@Override
public String mintPid() {
return java.util.UUID.randomUUID().toString();
return randomUUID().toString();
}

}
Expand Up @@ -29,6 +29,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Service for creating and retrieving Datastreams without using the JCR API.
*
* @author cbeer
*
*/
public class DatastreamService {

private static final Logger logger = LoggerFactory
Expand Down
Expand Up @@ -21,6 +21,12 @@

import com.google.common.collect.ImmutableSet.Builder;

/**
* Service for creating and retrieving FedoraObjects without using the JCR API.
*
* @author cbeer
*
*/
public class ObjectService {

private static final Logger logger = LoggerFactory
Expand Down
15 changes: 15 additions & 0 deletions fcrepo-kernel/src/main/java/org/fcrepo/services/PathService.java
Expand Up @@ -4,16 +4,31 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Conveience class for constructing Fedora-related paths in the JCR repository.
*
* @author cbeer
*
*/
public class PathService {

private static final Logger logger = LoggerFactory
.getLogger(DatastreamService.class);

/**
* @param pid
* @return The JCR path to this object's backing node.
*/
public static String getObjectJcrNodePath(String pid) {
logger.trace("Executing getObjectJcrNodePath() with pid: " + pid);
return "/objects/" + pid;
}

/**
* @param pid
* @param dsId
* @return The JCR path to this datastream's backing node.
*/
public static String getDatastreamJcrNodePath(String pid, String dsId) {
logger.trace("Executing getDatastreamJcrNodePath() with pid: " + pid +
" and dsId: " + dsId);
Expand Down
10 changes: 10 additions & 0 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/EventType.java
@@ -1,5 +1,11 @@
package org.fcrepo.utils;

/**
* A convenient abstraction over JCR's integer-typed events.
*
* @author ajs6f
*
*/
public enum EventType {
NODE_ADDED, NODE_REMOVED, PROPERTY_ADDED, PROPERTY_REMOVED, PROPERTY_CHANGED, NODE_MOVED, PERSIST;

Expand All @@ -25,6 +31,10 @@ public static EventType getEventType(final Integer i) {
}
}

/**
* @param jcrEvent
* @return A human-readable name for the type of this JCR event.
*/
public static String getEventName(final Integer jcrEvent) {

switch (getEventType(jcrEvent)) {
Expand Down

0 comments on commit ed29128

Please sign in to comment.