Skip to content

Commit

Permalink
Bumped Sesame version and some nonfunctional code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Dec 3, 2013
1 parent b63c416 commit 144951d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 69 deletions.
Expand Up @@ -16,8 +16,24 @@

package org.fcrepo.transform.http;

import static javax.jcr.nodetype.NodeType.NT_BASE;
import static javax.jcr.nodetype.NodeType.NT_FILE;
import static javax.jcr.nodetype.NodeType.NT_FOLDER;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.apache.jena.riot.WebContent.contentTypeN3;
import static org.apache.jena.riot.WebContent.contentTypeNTriples;
import static org.apache.jena.riot.WebContent.contentTypeRDFXML;
import static org.apache.jena.riot.WebContent.contentTypeResultsBIO;
import static org.apache.jena.riot.WebContent.contentTypeResultsJSON;
import static org.apache.jena.riot.WebContent.contentTypeResultsXML;
import static org.apache.jena.riot.WebContent.contentTypeSPARQLQuery;
import static org.apache.jena.riot.WebContent.contentTypeSSE;
import static org.apache.jena.riot.WebContent.contentTypeTextCSV;
import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
import static org.apache.jena.riot.WebContent.contentTypeTextTSV;
import static org.apache.jena.riot.WebContent.contentTypeTurtle;
import static org.fcrepo.transform.transformations.LDPathTransform.APPLICATION_RDF_LDPATH;
import static org.fcrepo.transform.transformations.LDPathTransform.CONFIGURATION_FOLDER;
import static org.fcrepo.transform.transformations.LDPathTransform.getNodeTypeTransform;
import static org.slf4j.LoggerFactory.getLogger;

Expand All @@ -29,7 +45,6 @@
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
Expand All @@ -40,7 +55,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment;

import org.apache.jena.riot.WebContent;
import org.apache.marmotta.ldpath.exception.LDPathParseException;
import org.fcrepo.http.api.FedoraNodes;
import org.fcrepo.http.commons.AbstractResource;
Expand All @@ -49,7 +63,6 @@
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.transform.Transformation;
import org.fcrepo.transform.TransformationFactory;
import org.fcrepo.transform.transformations.LDPathTransform;
import org.modeshape.jcr.api.JcrTools;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -80,38 +93,39 @@ public class FedoraTransform extends AbstractResource {
*/
@PostConstruct
public void setUpRepositoryConfiguration() throws RepositoryException,
IOException {
IOException {

if (transformationFactory == null) {
transformationFactory = new TransformationFactory();
}

final Session session = sessions.getInternalSession();
final JcrTools jcrTools = new JcrTools(true);

// register our CND
jcrTools.registerNodeTypes(session, "ldpath.cnd");

// create the configuration base path
jcrTools.findOrCreateNode(session,
"/fedora:system/fedora:transform", "fedora:configuration",
"fedora:node_type_configuration");
final Node node =
jcrTools.findOrCreateNode(session,
LDPathTransform.CONFIGURATION_FOLDER + "default",
NodeType.NT_FOLDER, NodeType.NT_FOLDER);
logger.debug("Transforming node: {}", node.getPath());
// register an initial demo program
if (!node.hasNode(NodeType.NT_BASE)) {
final Node base_config =
node.addNode(NodeType.NT_BASE, NodeType.NT_FILE);
jcrTools.uploadFile(session, base_config.getPath(), getClass()
.getResourceAsStream(
"/ldpath/default/nt_base_ldpath_program.txt"));
try {
final JcrTools jcrTools = new JcrTools(true);

// register our CND
jcrTools.registerNodeTypes(session, "ldpath.cnd");

// create the configuration base path
jcrTools.findOrCreateNode(session,
"/fedora:system/fedora:transform", "fedora:configuration",
"fedora:node_type_configuration");
final Node node =
jcrTools.findOrCreateNode(session, CONFIGURATION_FOLDER
+ "default", NT_FOLDER, NT_FOLDER);
logger.debug("Transforming node: {}", node.getPath());
// register an initial demo program
if (!node.hasNode(NT_BASE)) {
final Node base_config = node.addNode(NT_BASE, NT_FILE);
jcrTools.uploadFile(session, base_config.getPath(), getClass()
.getResourceAsStream(
"/ldpath/default/nt_base_ldpath_program.txt"));
}

session.save();
} finally {
session.logout();
}

session.save();
session.logout();
}

/**
Expand All @@ -123,7 +137,7 @@ public void setUpRepositoryConfiguration() throws RepositoryException,
*/
@GET
@Path("{program}")
@Produces({MediaType.APPLICATION_JSON})
@Produces({APPLICATION_JSON})
@Timed
public Object evaluateLdpathProgram(@PathParam("path")
final List<PathSegment> pathList, @PathParam("program")
Expand Down Expand Up @@ -159,14 +173,10 @@ public Object evaluateLdpathProgram(@PathParam("path")
*/
@POST
@Consumes({APPLICATION_RDF_LDPATH, contentTypeSPARQLQuery})
@Produces({MediaType.APPLICATION_JSON, WebContent.contentTypeTextTSV,
WebContent.contentTypeTextCSV, WebContent.contentTypeSSE,
WebContent.contentTypeTextPlain,
WebContent.contentTypeResultsJSON,
WebContent.contentTypeResultsXML,
WebContent.contentTypeResultsBIO,
WebContent.contentTypeTurtle, WebContent.contentTypeN3,
WebContent.contentTypeNTriples, WebContent.contentTypeRDFXML})
@Produces({APPLICATION_JSON, contentTypeTextTSV, contentTypeTextCSV,
contentTypeSSE, contentTypeTextPlain, contentTypeResultsJSON,
contentTypeResultsXML, contentTypeResultsBIO, contentTypeTurtle,
contentTypeN3, contentTypeNTriples, contentTypeRDFXML})
@Timed
public Object evaluateTransform(@PathParam("path")
final List<PathSegment> pathList, @HeaderParam("Content-Type")
Expand Down
Expand Up @@ -17,10 +17,8 @@
package org.fcrepo.transform.transformations;

import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
Expand All @@ -40,6 +38,8 @@
import java.util.List;
import java.util.Map;

import static com.google.common.collect.Collections2.transform;
import static com.google.common.collect.Maps.transformValues;
import static org.fcrepo.kernel.rdf.SerializationUtils.getDatasetSubject;
import static org.fcrepo.kernel.rdf.SerializationUtils.unifyDatasetModel;

Expand Down Expand Up @@ -74,7 +74,7 @@ public static LDPathTransform getNodeTypeTransform(final Node node,
final String key)
throws RepositoryException {

final Node programNode = node.getSession().getNode(LDPathTransform.CONFIGURATION_FOLDER + key);
final Node programNode = node.getSession().getNode(CONFIGURATION_FOLDER + key);

final NodeType primaryNodeType = node.getPrimaryNodeType();

Expand All @@ -84,7 +84,7 @@ public static LDPathTransform getNodeTypeTransform(final Node node,
Iterables.concat(ImmutableList.of(primaryNodeType),
ImmutableList.copyOf(supertypes));

for (NodeType nodeType : nodeTypes) {
for (final NodeType nodeType : nodeTypes) {
if (programNode.hasNode(nodeType.toString())) {
return new LDPathTransform(programNode.getNode(nodeType.toString())
.getNode("jcr:content")
Expand Down Expand Up @@ -120,7 +120,7 @@ public InputStream getQuery() {
}

@Override
public boolean equals(Object other) {
public boolean equals(final Object other) {
return other instanceof LDPathTransform &&
query.equals(((LDPathTransform)other).getQuery());
}
Expand All @@ -137,7 +137,7 @@ private LDPath<RDFNode> getLdpathResource(final Dataset dataset) throws Reposito

final GenericJenaBackend genericJenaBackend = new GenericJenaBackend(model);

LDPath<RDFNode> ldpath = new LDPath<RDFNode>(genericJenaBackend);
final LDPath<RDFNode> ldpath = new LDPath<RDFNode>(genericJenaBackend);

return ldpath;
}
Expand All @@ -148,30 +148,30 @@ private LDPath<RDFNode> getLdpathResource(final Dataset dataset) throws Reposito
* @param collectionMap
* @return
*/
private Map<String, Collection<Object>>
transformLdpathOutputToSomethingSerializable(Map<String, Collection<?>> collectionMap) {
private Map<String, Collection<Object>> transformLdpathOutputToSomethingSerializable(
final Map<String, Collection<?>> collectionMap) {

return Maps.transformValues(collectionMap,
WILDCARD_COLLECTION_TO_OBJECT_COLLECTION);
return transformValues(collectionMap,
WILDCARD_COLLECTION_TO_OBJECT_COLLECTION);
}

private static final Function<Collection<?>, Collection<Object>> WILDCARD_COLLECTION_TO_OBJECT_COLLECTION =
new Function<Collection<?>, Collection<Object>>() {

@Override
public Collection<Object> apply(Collection<?> input) {
return Collections2.transform(input,
ANYTHING_TO_OBJECT_FUNCTION);
}
};


private static final Function<Object,Object> ANYTHING_TO_OBJECT_FUNCTION =
new Function<Object, Object>() {
@Override
public Object apply(Object input) {
return input;
}
};
new Function<Collection<?>, Collection<Object>>() {

@Override
public Collection<Object> apply(final Collection<?> input) {
return transform(input, ANYTHING_TO_OBJECT_FUNCTION);
}
};


private static final Function<Object, Object> ANYTHING_TO_OBJECT_FUNCTION =
new Function<Object, Object>() {

@Override
public Object apply(final Object input) {
return input;
}
};

}
Expand Up @@ -55,7 +55,7 @@ public QueryExecution apply(final Dataset dataset) {
QueryFactory.create(IOUtils.toString(query));

return QueryExecutionFactory.create(sparqlQuery, model);
} catch (IOException e) {
} catch (final IOException e) {
throw new IllegalStateException(e);
}
}
Expand All @@ -66,9 +66,9 @@ public InputStream getQuery() {
}

@Override
public boolean equals(Object other) {
return other instanceof SparqlQueryTransform &&
query.equals(((SparqlQueryTransform)other).getQuery());
public boolean equals(final Object other) {
return other instanceof SparqlQueryTransform
&& query.equals(((SparqlQueryTransform) other).getQuery());
}

}
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -29,7 +29,7 @@
<logback.version>1.0.13</logback.version>
<metrics.version>3.0.0</metrics.version>
<modeshape.version>3.4.0.Final</modeshape.version>
<sesame.version>2.7.2</sesame.version>
<sesame.version>2.7.7</sesame.version>
<slf4j.version>1.7.5</slf4j.version>
<spring.version>3.2.3.RELEASE</spring.version>
<grizzly.version>2.2.21</grizzly.version>
Expand Down

0 comments on commit 144951d

Please sign in to comment.