Skip to content

Commit

Permalink
Merge branch 'FCREPO-1640'
Browse files Browse the repository at this point in the history
  • Loading branch information
acoburn committed Aug 26, 2015
2 parents 99397f6 + ac5a256 commit 3bee67c
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 201 deletions.
Expand Up @@ -30,6 +30,7 @@
import static javax.ws.rs.core.Response.Status.REQUESTED_RANGE_NOT_SATISFIABLE;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.jena.riot.RDFLanguages.contentTypeToLang;

import static org.fcrepo.kernel.api.FedoraJcrTypes.LDP_BASIC_CONTAINER;
import static org.fcrepo.kernel.api.FedoraJcrTypes.LDP_DIRECT_CONTAINER;
import static org.fcrepo.kernel.api.FedoraJcrTypes.LDP_INDIRECT_CONTAINER;
Expand Down Expand Up @@ -102,7 +103,6 @@
import org.apache.jena.riot.Lang;
import org.glassfish.jersey.media.multipart.ContentDisposition;
import org.jvnet.hk2.annotations.Optional;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.hp.hpl.jena.graph.Triple;
Expand Down Expand Up @@ -180,19 +180,20 @@ protected Response getContent(final String rangeValue,

} else {
rdfStream.concat(getResourceTriples());

if (prefer != null) {
prefer.getReturn().addResponseHeaders(servletResponse);
}

}
servletResponse.addHeader("Vary", "Accept, Range, Accept-Encoding, Accept-Language");

return Response.ok(rdfStream).build();
return ok(rdfStream).build();
}

protected RdfStream getResourceTriples() {

// use the thing described, not the description, for the subject of descriptive triples
if (resource() instanceof NonRdfSourceDescription) {
resource = ((NonRdfSourceDescription) resource()).getDescribedResource();
}
final PreferTag returnPreference;

if (prefer != null && prefer.hasReturn()) {
Expand All @@ -207,12 +208,8 @@ protected RdfStream getResourceTriples() {

final RdfStream rdfStream = new RdfStream();

final Predicate<Triple> tripleFilter;
if (ldpPreferences.prefersServerManaged()) {
tripleFilter = x -> true;
} else {
tripleFilter = IS_MANAGED_TYPE.or(isManagedTriple).negate();
}
final Predicate<Triple> tripleFilter = ldpPreferences.prefersServerManaged() ? x -> true :
IS_MANAGED_TYPE.or(isManagedTriple::test).negate();

if (ldpPreferences.prefersServerManaged()) {
rdfStream.concat(getTriples(LdpRdfContext.class));
Expand Down Expand Up @@ -243,17 +240,6 @@ protected RdfStream getResourceTriples() {
rdfStream.concat(getTriples(LdpIsMemberOfRdfContext.class));
}

// Include binary properties if this is a binary description
if (resource() instanceof NonRdfSourceDescription) {
final FedoraResource described = ((NonRdfSourceDescription) resource()).getDescribedResource();
rdfStream.concat(filter(described.getTriples(translator(), ImmutableList.of(TypeRdfContext.class,
PropertiesRdfContext.class,
ContentRdfContext.class)), tripleFilter::test));
if (ldpPreferences.prefersServerManaged()) {
rdfStream.concat(getTriples(described,LdpRdfContext.class));
}
}

// Embed all hash and blank nodes
rdfStream.concat(filter(getTriples(HashRdfContext.class), tripleFilter::test));
rdfStream.concat(filter(getTriples(SkolemNodeRdfContext.class), tripleFilter::test));
Expand Down Expand Up @@ -396,7 +382,6 @@ protected FedoraResource resource() {
if (resource == null) {
resource = getResourceFromPath(externalPath());
}

return resource;
}

Expand Down
Expand Up @@ -123,6 +123,8 @@ public class StreamingBaseHtmlProvider implements MessageBodyWriter<RdfStream> {
public static final String velocityPropertiesLocation =
"/velocity.properties";

private static final ViewHelpers VIEW_HELPERS = ViewHelpers.getInstance();

private static final Logger LOGGER =
getLogger(StreamingBaseHtmlProvider.class);

Expand Down Expand Up @@ -196,7 +198,7 @@ public void writeTo(final RdfStream rdfStream, final Class<?> type,

rdfStream.namespaces(nsRdfStream.namespaces());

final Node subject = rdfStream.topic();
final Node subject = VIEW_HELPERS.getContentNode(rdfStream.topic());

final Model model = rdfStream.asModel();

Expand All @@ -221,7 +223,7 @@ protected Context getContext(final Model model, final Node subject) {

final Context context = new VelocityContext();
context.put("rdfLexicon", fieldTool.in(RdfLexicon.class));
context.put("helpers", ViewHelpers.getInstance());
context.put("helpers", VIEW_HELPERS);
context.put("esc", escapeTool);
context.put("rdf", model.getGraph());

Expand All @@ -244,7 +246,7 @@ private Template getTemplate(final Model rdf, final Node subject,
.findFirst();

if (!template.isPresent()) {
LOGGER.trace("Attempting to discover the mixin types of the node for the resource in question...");
LOGGER.trace("Attempting to discover mixin types of node for resource in question: {}", subject);
template = rdf.listObjectsOfProperty(createResource(subject.getURI()),
createProperty(getRDFNamespaceForJcrNamespace(JCR_NAMESPACE) +
"mixinTypes"))
Expand All @@ -259,7 +261,7 @@ private Template getTemplate(final Model rdf, final Node subject,
LOGGER.debug("Choosing template: {}", template.get().getName());
return template.get();
} else {
LOGGER.trace("Attempting to discover the primary type of the node for the resource in question...");
LOGGER.trace("Attempting to discover primary type of node for resource in question: {}", subject);
return rdf.listObjectsOfProperty(createResource(subject.getURI()),
createProperty(getRDFNamespaceForJcrNamespace(JCR_NAMESPACE) +
"primaryType"))
Expand Down
Expand Up @@ -26,6 +26,7 @@
import static org.fcrepo.kernel.api.RdfLexicon.HAS_VERSION_HISTORY;
import static org.fcrepo.kernel.api.RdfLexicon.RDFS_LABEL;
import static org.fcrepo.kernel.api.RdfLexicon.REPOSITORY_NAMESPACE;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.fcrepo.kernel.api.RdfLexicon.DC_NAMESPACE;

import com.hp.hpl.jena.rdf.model.Model;
Expand Down Expand Up @@ -101,8 +102,9 @@ private static void addContentStatements(final IdentifierConverter<Resource,Fedo
private void addNodeStatements(final FedoraResource resource, final UriInfo uriInfo,
final Model model, final Resource s) {

final Map<String, String> pathMap =
singletonMap("path", resource.getPath().substring(1));
String path = resource.getPath();
path = path.endsWith(JCR_CONTENT) ? path.replace("/" + JCR_CONTENT, "") : path;
final Map<String, String> pathMap = singletonMap("path", path.substring(1));

// fcr:versions
if (resource.isVersioned()) {
Expand Down
@@ -1,4 +1,4 @@
#set ($content = $helpers.getObjectsAsString($rdf, $topic, $rdfLexicon.DESCRIBES, false))
#set ($content = $helpers.getContentNode($topic))
#set ($writable = $helpers.isWritable($rdf, $topic))
#set ($frozen = $helpers.isFrozenNode($rdf, $topic))

Expand All @@ -14,7 +14,7 @@
<button type="submit" class="btn btn-danger standalone">Delete this Version</button>
</form>
#else
#if ($content != "")
#if ($helpers.isRdfResource($rdf, $content, "http://fedora.info/definitions/v4/repository#", "Binary"))
<a href="$content" class="btn btn-success btn-lg"><span class="glyphicon glyphicon-download"></span> Download Content</a><br/><br/>
<a href="$content/fcr:fixity" class="btn btn-success btn-lg">Fixity</a>
#if ($writable == true)
Expand Down
2 changes: 1 addition & 1 deletion fcrepo-http-api/src/main/resources/views/common.js
Expand Up @@ -261,7 +261,7 @@ function sendSparqlQuery() {
}

function sendSparqlUpdate() {
var postURI = $('#main').attr('resource');
var postURI = this.baseURI;


$.ajax({url: postURI, type: "PATCH", contentType: "application/sparql-update", data: $("#sparql_update_query").val(), success: function(data, textStatus, request) {
Expand Down
36 changes: 1 addition & 35 deletions fcrepo-http-api/src/main/resources/views/nt-file.vsl
Expand Up @@ -47,7 +47,7 @@
<h4 class="panel-title">Properties</h4>
</div>
<div class="panel-body">
#triples($topic)
#triples($contentNode)
</div>

## output triples for the content node
Expand All @@ -63,40 +63,6 @@
#end
</div>

## output other nodes

<h2>Other Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if ($subject.getURI() != $contentNode.getURI())
#if( $subject != $topic)
#if ( $subject.getURI() )
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading collapsed" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples" >
<h3 class="panel-title ctitle"><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#else
<div class="panel panel-default" resource="$subject.getId()">
<div class="panel-heading collapsed" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getId())_triples" >
<h3 class="panel-title ctitle"><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getId())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
#end
#end
</div>
</div>


Expand Down
19 changes: 0 additions & 19 deletions fcrepo-http-api/src/main/resources/views/nt-resource.vsl
Expand Up @@ -47,25 +47,6 @@
</div>
</div>

## output other nodes

<h2>Other Resources</h2>
<div class="panel-group" id="accordion">
#foreach($subject in $model.listSubjects())
#if( $subject != $topic )
<div class="panel panel-default" resource="$subject.getURI()">
<div class="panel-heading collapsed" data-toggle="collapse" data-target="#$helpers.parameterize($subject.getURI())_triples" >
<h3 class="panel-title ctitle"><a href="$subject.getURI()">$esc.html($helpers.getObjectTitle($rdf, $subject.asNode()))</a></h3>
</div>
<div class="panel-collapse collapse" id="$helpers.parameterize($subject.getURI())_triples">
<div class="panel-body">
#triples($subject.asNode())
</div>
</div>
</div>
#end
#end
</div>
</div>

</div>
Expand Down

0 comments on commit 3bee67c

Please sign in to comment.