Skip to content

Commit

Permalink
Filtering out server-managed triples about hash URI fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Nov 2, 2015
1 parent 9d28989 commit 8d15050
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -141,6 +141,7 @@ public abstract class ContentExposingResource extends FedoraBaseResource {

private static final Predicate<Triple> IS_MANAGED_TYPE = t -> t.getPredicate().equals(type.asNode()) &&
isManagedNamespace.test(t.getObject().getNameSpace());
private static final Predicate<Triple> IS_MANAGED_TRIPLE = IS_MANAGED_TYPE.or(isManagedTriple::test);

protected abstract String externalPath();

Expand Down Expand Up @@ -209,7 +210,7 @@ protected RdfStream getResourceTriples() {
final RdfStream rdfStream = new RdfStream();

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

if (ldpPreferences.prefersServerManaged()) {
rdfStream.concat(getTriples(LdpRdfContext.class));
Expand Down Expand Up @@ -241,7 +242,8 @@ protected RdfStream getResourceTriples() {
}

// Embed all hash and blank nodes
rdfStream.concat(filter(getTriples(HashRdfContext.class), tripleFilter::test));
// using IS_MANAGED_TRIPLE directly to avoid Prefer header logic (we never want them for hash fragments)
rdfStream.concat(filter(getTriples(HashRdfContext.class), IS_MANAGED_TRIPLE.negate()::test));
rdfStream.concat(filter(getTriples(SkolemNodeRdfContext.class), tripleFilter::test));

// Include inbound references to this object
Expand Down
Expand Up @@ -1735,6 +1735,10 @@ public void testWithHashUris() throws IOException {
createURI(location), createURI("info:some-predicate"), createURI(location + "#abc")));
assertTrue(graphStore.contains(ANY,
createURI(location + "#abc"), createURI("info:test#label"), createLiteral("asdfg")));
assertFalse(graphStore.contains(ANY,
createURI(location + "#abc"), createURI(REPOSITORY_NAMESPACE + "lastModified"), ANY));
assertFalse(graphStore.contains(ANY,
createURI(location + "#abc"), rdfType, createURI(REPOSITORY_NAMESPACE + "Resource")));
}
}
}
Expand Down

0 comments on commit 8d15050

Please sign in to comment.