Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import org.apache.commons.rdf.api.Graph;
import org.apache.commons.rdf.api.IRI;
import org.apache.commons.rdf.api.RDFTerm;
import org.apache.commons.rdf.api.Triple;
import org.slf4j.Logger;
import org.trellisldp.api.ConstraintService;
Expand Down Expand Up @@ -106,11 +105,6 @@ private static Predicate<Triple> propertyFilter(final IRI model) {
return of(model).filter(typeMap::containsKey).map(typeMap::get).orElse(basicConstraints);
}

// Don't allow LDP types to be set explicitly
private static final Predicate<Triple> typeFilter = triple ->
of(triple).filter(t -> t.getPredicate().equals(RDF.type)).map(Triple::getObject)
.map(RDFTerm::ntriplesString).filter(str -> str.startsWith("<" + LDP.URI)).isPresent();

// Verify that the object of a triple whose predicate is either ldp:hasMemberRelation or ldp:isMemberOfRelation
// is not equal to ldp:contains or any of the other cardinality-restricted IRIs
private static Predicate<Triple> invalidMembershipProperty = triple ->
Expand Down Expand Up @@ -161,9 +155,6 @@ private Function<Triple, Stream<ConstraintViolation>> checkModelConstraints(fina
of(triple).filter(propertyFilter(model)).map(t -> new ConstraintViolation(Trellis.InvalidProperty, t))
.ifPresent(builder::accept);

of(triple).filter(typeFilter).map(t -> new ConstraintViolation(Trellis.InvalidType, t))
.ifPresent(builder::accept);

of(triple).filter(uriRangeFilter).map(t -> new ConstraintViolation(Trellis.InvalidRange, t))
.ifPresent(builder::accept);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,12 @@ public void testInvalidLdpProps() {
}

@Test
public void testInvalidType() {
public void testLdpType() {
models.stream().forEach(ldpType -> {
final String subject = domain + "foo";
final Optional<ConstraintViolation> res = svc.constrainedBy(ldpType, asGraph("/withLdpType.ttl",
subject), domain).filter(v -> Trellis.InvalidType.equals(v.getConstraint())).findFirst();
assertTrue(res.isPresent());
res.ifPresent(violation -> {
assertEquals(Trellis.InvalidType, violation.getConstraint());
assertEquals(1L, violation.getTriples().size());
assertTrue(violation.getTriples().contains(rdf.createTriple(rdf.createIRI(subject), type,
LDP.Resource)));
});
assertFalse(res.isPresent());
});
}

Expand Down