Skip to content

Commit

Permalink
Formatting to pass checkstyle rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Shin committed Jun 26, 2013
1 parent 5e57cb9 commit 7f91216
Showing 1 changed file with 56 additions and 33 deletions.
89 changes: 56 additions & 33 deletions src/main/java/org/fcrepo/webdav/FedoraContentMapper.java
Expand Up @@ -20,9 +20,9 @@
import org.modeshape.web.jcr.webdav.ContentMapper;

/**
* This class is almost entirely borrowed from {@link org.modeshape.web.jcr.webdav.DefaultContentMapper}
* except for the Fedora-specific behaviors.
*
* This class is almost entirely borrowed from
* {@link org.modeshape.web.jcr.webdav.DefaultContentMapper} except for the
* Fedora-specific behaviors.
*/
public class FedoraContentMapper implements ContentMapper {

Expand Down Expand Up @@ -76,15 +76,18 @@ public void initialize(ServletContext servletContext) {
String newContentPrimaryType =
getParam(servletContext, INIT_NEW_CONTENT_PRIMARY_TYPE_NAME);

logger.debug("FedoraContentMapper initial content primary types = " +
logger.debug("FedoraContentMapper initial content primary types = {}",
contentPrimaryTypes);
logger.debug("FedoraContentMapper initial file primary types = " +
logger.debug("FedoraContentMapper initial file primary types = {}",
filePrimaryTypes);
logger.debug("FedoraContentMapper initial new folder primary types = " +
logger.debug(
"FedoraContentMapper initial new folder primary types = {}",
newFolderPrimaryType);
logger.debug("FedoraContentMapper initial new resource primary types = " +
logger.debug(
"FedoraContentMapper initial new resource primary types = {}",
newResourcePrimaryType);
logger.debug("FedoraContentMapper initial new content primary types = " +
logger.debug(
"FedoraContentMapper initial new content primary types = {}",
newContentPrimaryType);

this.contentPrimaryTypes =
Expand All @@ -103,10 +106,13 @@ protected String getParam(ServletContext servletContext, String name) {
}

/**
* Returns an unmodifiable set containing the elements passed in to this method
* Returns an unmodifiable set containing the elements passed in to this
* method
*
* @param elements a set of elements; may not be null
* @return an unmodifiable set containing all of the elements in {@code elements}; never null
* @param elements
* a set of elements; may not be null
* @return an unmodifiable set containing all of the elements in
* {@code elements}; never null
*/
private static Set<String> setFor(String... elements) {
Set<String> set = new HashSet<String>(elements.length);
Expand All @@ -116,19 +122,25 @@ private static Set<String> setFor(String... elements) {
}

/**
* Splits a comma-delimited string into an unmodifiable set containing the substrings between the commas in the source string.
* The elements in the set will be {@link String#trim() trimmed}.
* Splits a comma-delimited string into an unmodifiable set containing the
* substrings between the commas in the source string. The elements in the
* set will be {@link String#trim() trimmed}.
*
* @param commaDelimitedString input string; may not be null, but need not contain any commas
* @return an unmodifiable set whose elements are the trimmed substrings of the source string; never null
* @param commaDelimitedString
* input string; may not be null, but need not contain any commas
* @return an unmodifiable set whose elements are the trimmed substrings of
* the source string; never null
*/
private static Set<String> split(String commaDelimitedString) {
return setFor(commaDelimitedString.split("\\s*,\\s*"));
}

@Override
public InputStream getResourceContent(Node node) throws RepositoryException {
if (!node.hasNode(CONTENT_NODE_NAME)) return null;
public InputStream getResourceContent(Node node)
throws RepositoryException {
if (!node.hasNode(CONTENT_NODE_NAME)) {
return null;
}
return node.getProperty(CONTENT_NODE_NAME + "/" + DATA_PROP_NAME)
.getBinary().getStream();
}
Expand All @@ -144,7 +156,9 @@ public long getResourceLength(Node node) throws RepositoryException {

@Override
public Date getLastModified(Node node) throws RepositoryException {
if (!node.hasNode(CONTENT_NODE_NAME)) return null;
if (!node.hasNode(CONTENT_NODE_NAME)) {
return null;
}

return node.getProperty(CONTENT_NODE_NAME + "/" + MODIFIED_PROP_NAME)
.getDate().getTime();
Expand All @@ -156,53 +170,62 @@ public boolean isFolder(Node node) throws RepositoryException {
}

/**
* @param node the node to check
* @return true if {@code node}'s primary type is one of the types in {@link #filePrimaryTypes}; may not be null
* @throws RepositoryException if an error occurs checking the node's primary type
* @param node
* the node to check
* @return true if {@code node}'s primary type is one of the types in
* {@link #filePrimaryTypes}; may not be null
* @throws RepositoryException
* if an error occurs checking the node's primary type
*/
@Override
public boolean isFile(Node node) throws RepositoryException {
for (String nodeType : filePrimaryTypes) {
if (node.isNodeType(nodeType)) return true;
if (node.isNodeType(nodeType)) {
return true;
}
}

return false;
}

/**
* @param node the node to check
* @return true if {@code node}'s primary type is one of the types in {@link #contentPrimaryTypes}; may not be null
* @throws RepositoryException if an error occurs checking the node's primary type
* @param node
* the node to check
* @return true if {@code node}'s primary type is one of the types in
* {@link #contentPrimaryTypes}; may not be null
* @throws RepositoryException
* if an error occurs checking the node's primary type
*/
private boolean isContent(Node node) throws RepositoryException {
for (String nodeType : contentPrimaryTypes) {
if (node.isNodeType(nodeType)) return true;
if (node.isNodeType(nodeType)) {
return true;
}
}

return false;
}

@Override
public void createFile(Node parentNode, String fileName)
throws RepositoryException {
new Datastream(parentNode.getSession(), parentNode.getPath() +
"/" + fileName);
throws RepositoryException {
new Datastream(parentNode.getSession(), parentNode.getPath() + "/" +
fileName);

}

@Override
public void createFolder(Node parentNode, String folderName)
throws RepositoryException {
throws RepositoryException {
Node newFolder = parentNode.addNode(folderName, newFolderPrimaryType);
new FedoraObject(newFolder);
}

@Override
public long
setContent(Node parentNode, String resourceName,
public long setContent(Node parentNode, String resourceName,
InputStream newContent, String contentType,
String characterEncoding) throws RepositoryException,
IOException {
IOException {

Datastream ds = new Datastream(parentNode);
try {
Expand Down

0 comments on commit 7f91216

Please sign in to comment.