Commit 061a194b authored by acoburn's avatar acoburn
Browse files

minor code clean-up

parent aaf45870
......@@ -23,8 +23,8 @@ import static org.apache.camel.builder.PredicateBuilder.in;
import static org.apache.camel.builder.PredicateBuilder.not;
import static org.apache.camel.builder.PredicateBuilder.or;
import static org.apache.camel.util.ExchangeHelper.getMandatoryHeader;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_NAMED_GRAPH;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_EVENT_TYPE;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_NAMED_GRAPH;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_URI;
import static org.fcrepo.camel.processor.ProcessorUtils.tokenizePropertyPlaceholder;
import static org.slf4j.LoggerFactory.getLogger;
......
......@@ -15,14 +15,12 @@
*/
package edu.amherst.acdc.exts.pcdm;
import static org.apache.jena.rdf.model.ModelFactory.createDefaultModel;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_MODEL;
import static org.slf4j.LoggerFactory.getLogger;
import static org.apache.jena.rdf.model.ModelFactory.createDefaultModel;
import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;
import org.apache.jena.rdf.model.Model;
import org.slf4j.Logger;
/**
* Aggregate the CamelPcdmModel header values across exchanges
......@@ -32,8 +30,6 @@ import org.slf4j.Logger;
*/
class ModelAggregator implements AggregationStrategy {
private static final Logger LOGGER = getLogger(ModelAggregator.class);
@Override
public Exchange aggregate(final Exchange a, final Exchange b) {
if (a == null) {
......
......@@ -20,7 +20,7 @@ package edu.amherst.acdc.exts.pcdm;
*
* @author acoburn
*/
class PcdmHeaders {
final class PcdmHeaders {
public final static String PCDM_ACCEPT = "CamelPcdmAccept";
public final static String PCDM_MODEL = "CamelPcdmModel";
......
......@@ -15,14 +15,14 @@
*/
package edu.amherst.acdc.exts.pcdm;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_ACCEPT;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_SUBJECT;
import static java.util.Optional.ofNullable;
import static org.apache.camel.Exchange.CONTENT_TYPE;
import static org.apache.camel.Exchange.HTTP_METHOD;
import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_BASE_URL;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_URI;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_ACCEPT;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_SUBJECT;
import java.util.Optional;
......
......@@ -15,19 +15,17 @@
*/
package edu.amherst.acdc.exts.pcdm;
import static java.util.Collections.emptyList;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_FILES;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_MEMBERS;
import static edu.amherst.acdc.exts.pcdm.PcdmHeaders.PCDM_RELATED_OBJECTS;
import static org.slf4j.LoggerFactory.getLogger;
import static java.util.Collections.emptyList;
import java.util.List;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.slf4j.Logger;
/**
* Aggregate all of the pcdm:hasMember, pcdm:hasFile and pcdm:hasRelatedObject values
......@@ -38,8 +36,6 @@ import org.slf4j.Logger;
*/
class RelatedProcessor implements Processor {
private static final Logger LOGGER = getLogger(RelatedProcessor.class);
@Override
public void process(final Exchange exchange) throws Exception {
@SuppressWarnings("unchecked")
......
......@@ -15,14 +15,14 @@
*/
package edu.amherst.acdc.exts.template;
import static org.apache.camel.component.mustache.MustacheConstants.MUSTACHE_RESOURCE_URI;
import static org.apache.camel.Exchange.CONTENT_TYPE;
import static org.apache.camel.Exchange.HTTP_METHOD;
import static org.apache.camel.Exchange.HTTP_QUERY;
import static org.apache.camel.Exchange.HTTP_URI;
import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
import static org.apache.camel.Exchange.HTTP_URI;
import static org.apache.camel.LoggingLevel.INFO;
import static org.apache.camel.builder.PredicateBuilder.and;
import static org.apache.camel.component.mustache.MustacheConstants.MUSTACHE_RESOURCE_URI;
import static org.apache.camel.model.dataformat.JsonLibrary.Jackson;
import static org.slf4j.LoggerFactory.getLogger;
......
......@@ -31,9 +31,10 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.File;
import java.io.IOException;
import org.apache.camel.CamelContext;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.marmotta.ldcache.api.LDCachingBackend;
import org.junit.Test;
......@@ -122,14 +123,17 @@ public class AcrepoTemplateIT extends AbstractOSGiIT {
assertTrue(options(baseSvcUrl).contains("apix:bindsTo ldp:Resource"));
final HttpResponse res = httpclient.execute(new HttpGet(baseSvcUrl + "?context=" + baseUrl));
assumeTrue(SC_OK == res.getStatusLine().getStatusCode());
range(1, 2).mapToObj(x -> post(baseUrl)).forEach(url -> {
patch(url, "PREFIX dcterms: <http://purl.org/dc/terms/>\n" +
"INSERT { <> dcterms:title \"Title\" ; dcterms:description \"A description: " + url + "\" } " +
"WHERE {}");
try (final CloseableHttpResponse res = httpclient.execute(new HttpGet(baseSvcUrl + "?context=" + url))) {
assumeTrue(SC_OK == res.getStatusLine().getStatusCode());
} catch (final IOException ex) {
LOGGER.warn("Error fetching resource: {}", ex.getMessage());
}
final String html = get(baseSvcUrl + "?context=" + url);
assertTrue(html.contains("<title>Title</title>"));
assertTrue(html.contains("<h1>Fedora Template Service: Title</h1>"));
......
......@@ -45,6 +45,7 @@ public class InferenceServiceImpl implements InferenceService {
final Resource inferredType = createResource(rdfType);
final Resource subjectResource = createResource(subject);
final Model model = createDefaultModel();
LOGGER.debug("Reading data into model");
model.read(input, subject, contentTypeToLang(contentType).getName());
final Model schema = createDefaultModel();
......
......@@ -34,8 +34,8 @@ import java.util.Set;
import org.apache.jena.rdf.model.InfModel;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFLanguages;
import org.slf4j.Logger;
......@@ -66,6 +66,7 @@ public class PcdmServiceImpl implements PcdmService {
if (model == null) {
return parseInto(createDefaultModel(), input, contentType);
}
LOGGER.debug("Parsing data into model");
model.read(input, null, getRdfLanguage(contentType).orElse(DEFAULT_LANG));
return model;
}
......@@ -122,6 +123,7 @@ public class PcdmServiceImpl implements PcdmService {
public InputStream serialize(final Model model, final String contentType) {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
model.write(os, getRdfLanguage(contentType).orElse(DEFAULT_LANG));
LOGGER.debug("Writing model as InputStream");
return new ByteArrayInputStream(os.toByteArray());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment