use of org.apache.jena.rdf.model.Bag in project jena by apache.
the class TestContainerConstructors method testCreateAnonBag.
public void testCreateAnonBag() {
final Bag tv = model.createBag();
Assert.assertTrue(tv.isAnon());
Assert.assertTrue(model.contains(tv, RDF.type, RDF.Bag));
}
use of org.apache.jena.rdf.model.Bag in project jena by apache.
the class SecuredBagTest method setup.
@Override
@Before
public void setup() {
super.setup();
final Bag bag = baseModel.getBag("http://example.com/testContainer");
bag.add("SomeDummyItem");
setSecuredRDFNode(SecuredBagImpl.getInstance(securedModel, bag), bag);
}
use of org.apache.jena.rdf.model.Bag in project jena by apache.
the class TestPathPF method beforeClass.
@BeforeClass
public static void beforeClass() {
Model m = ModelFactory.createModelForGraph(graph1);
Bag bag0 = m.createBag(base + "node0");
Bag bag1 = m.createBag(base + "node1");
Seq seq2 = m.createSeq(base + "node2");
bag1.add("elt1");
seq2.add("elt1");
seq2.add("elt2");
}
use of org.apache.jena.rdf.model.Bag in project jena by apache.
the class SecuredBagImpl method getInstance.
/**
* Get an instance of SecuredBag
*
* @param securedModel
* The Secured Model to use.
* @param bag
* The bag to secure
* @return The SecuredBag
*/
public static SecuredBag getInstance(final SecuredModel securedModel, final Bag bag) {
if (securedModel == null) {
throw new IllegalArgumentException("Secured securedModel may not be null");
}
if (bag == null) {
throw new IllegalArgumentException("Bag may not be null");
}
final ItemHolder<Bag, SecuredBag> holder = new ItemHolder<>(bag);
final SecuredBagImpl checker = new SecuredBagImpl(securedModel, holder);
// one.
if (bag instanceof SecuredBag) {
if (checker.isEquivalent((SecuredBag) bag)) {
return (SecuredBag) bag;
}
}
return holder.setSecuredItem(new SecuredItemInvoker(bag.getClass(), checker));
}
use of org.apache.jena.rdf.model.Bag in project jena by apache.
the class SecuredSeqTest method testGetBag.
@Test
public void testGetBag() {
try {
final Bag a = getSecuredSeq().getBag(1);
Assert.assertTrue("Should be a secured Bag", a instanceof SecuredBag);
if (!securityEvaluator.evaluate(Action.Read)) {
Assert.fail("Should have thrown ReadDeniedException Exception");
}
} catch (final ReadDeniedException e) {
if (securityEvaluator.evaluate(Action.Read)) {
Assert.fail(String.format("Should not have thrown ReadDeniedException Exception: %s - %s", e, e.getTriple()));
}
}
}
Aggregations