Search in sources :

Example 1 with Bag

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));
}
Also used : Bag(org.apache.jena.rdf.model.Bag)

Example 2 with 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);
}
Also used : Bag(org.apache.jena.rdf.model.Bag) Before(org.junit.Before)

Example 3 with 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");
}
Also used : Model(org.apache.jena.rdf.model.Model) Bag(org.apache.jena.rdf.model.Bag) Seq(org.apache.jena.rdf.model.Seq) BeforeClass(org.junit.BeforeClass)

Example 4 with Bag

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));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredBag(org.apache.jena.permissions.model.SecuredBag) SecuredBag(org.apache.jena.permissions.model.SecuredBag) Bag(org.apache.jena.rdf.model.Bag)

Example 5 with Bag

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()));
        }
    }
}
Also used : ReadDeniedException(org.apache.jena.shared.ReadDeniedException) SecuredBag(org.apache.jena.permissions.model.SecuredBag) Bag(org.apache.jena.rdf.model.Bag) SecuredBag(org.apache.jena.permissions.model.SecuredBag) Test(org.junit.Test)

Aggregations

Bag (org.apache.jena.rdf.model.Bag)6 SecuredBag (org.apache.jena.permissions.model.SecuredBag)2 ItemHolder (org.apache.jena.permissions.impl.ItemHolder)1 SecuredItemInvoker (org.apache.jena.permissions.impl.SecuredItemInvoker)1 Model (org.apache.jena.rdf.model.Model)1 Seq (org.apache.jena.rdf.model.Seq)1 ReadDeniedException (org.apache.jena.shared.ReadDeniedException)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1