use of org.apache.jena.shared.AddDeniedException in project jena by apache.
the class SecuredModelTest method testGetAnyReifiedStmt_one.
@Test
public void testGetAnyReifiedStmt_one() {
final Statement st = baseModel.listStatements().next();
ReifiedStatement s = baseModel.createReifiedStatement(st);
try {
Resource r = securedModel.getAnyReifiedStatement(st);
if (securityEvaluator.evaluate(Action.Read)) {
Assert.assertEquals(s.getURI(), r.getURI());
}
if (!securityEvaluator.evaluate(Action.Update) && !securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown UpdateDeniedException Exception");
}
if (!securityEvaluator.evaluate(Action.Create) && !securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown AddDeniedException Exception");
}
} catch (final UpdateDeniedException e) {
if (securityEvaluator.evaluate(Action.Update)) {
Assert.fail(String.format("Should not have thrown UpdateDeniedException Exception: %s - %s", e, e.getTriple()));
}
} catch (final AddDeniedException e) {
if (securityEvaluator.evaluate(Action.Create)) {
Assert.fail(String.format("Should not have thrown AddDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
}
use of org.apache.jena.shared.AddDeniedException in project jena by apache.
the class SecuredModelTest method testGetSeq_StringNotExisting.
@Test
public void testGetSeq_StringNotExisting() throws Exception {
Resource r = ResourceFactory.createResource("http://example.com/securedModel/seq");
Triple t = new Triple(r.asNode(), RDF.type.asNode(), RDF.Seq.asNode());
try {
Seq seq = securedModel.getSeq("http://example.com/securedModel/seq");
assertEquals(securedModel, seq.getModel());
if (securedModel.canRead()) {
assertEquals("http://example.com/securedModel/seq", seq.getURI());
} else if (!securedModel.canUpdate() || !securedModel.canCreate(t)) {
fail("Should have thrown AddDeniedException ");
}
} catch (AddDeniedException e) {
if (securedModel.canUpdate() && securedModel.canCreate(t)) {
fail(String.format("Should not have thrown AddDeniedException ", e));
}
}
}
use of org.apache.jena.shared.AddDeniedException in project jena by apache.
the class GraphView method performAdd.
@Override
public void performAdd(Triple t) {
Node g = graphNode(graphName);
if (Quad.isUnionGraph(g))
throw new AddDeniedException("Can't update the union graph of a dataset");
Node s = t.getSubject();
Node p = t.getPredicate();
Node o = t.getObject();
dsg.add(g, s, p, o);
}
Aggregations