Search in sources :

Example 1 with SecuredProperty

use of org.apache.jena.permissions.model.SecuredProperty in project jena by apache.

the class SecuredPropertyImpl method getInstance.

/**
	 * Get an instance of SecuredProperty
	 * 
	 * @param securedModel
	 *            the Secured Model to use.
	 * @param property
	 *            The property to secure
	 * @return The SecuredProperty
	 */
public static SecuredProperty getInstance(final SecuredModel securedModel, final Property property) {
    if (securedModel == null) {
        throw new IllegalArgumentException("Secured securedModel may not be null");
    }
    if (property == null) {
        throw new IllegalArgumentException("Property may not be null");
    }
    // check that property has a securedModel.
    Property goodProp = property;
    if (goodProp.getModel() == null) {
        final Node n = property.asNode();
        if (property.isAnon()) {
            goodProp = securedModel.createProperty(n.getBlankNodeId().getLabelString());
        } else {
            goodProp = securedModel.createProperty(property.asNode().getURI());
        }
    }
    final ItemHolder<Property, SecuredProperty> holder = new ItemHolder<>(goodProp);
    final SecuredPropertyImpl checker = new SecuredPropertyImpl(securedModel, holder);
    // one.
    if (goodProp instanceof SecuredProperty) {
        if (checker.isEquivalent((SecuredProperty) goodProp)) {
            return (SecuredProperty) goodProp;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(property.getClass(), checker));
}
Also used : ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredProperty(org.apache.jena.permissions.model.SecuredProperty) Node(org.apache.jena.graph.Node) SecuredProperty(org.apache.jena.permissions.model.SecuredProperty) Property(org.apache.jena.rdf.model.Property)

Aggregations

Node (org.apache.jena.graph.Node)1 ItemHolder (org.apache.jena.permissions.impl.ItemHolder)1 SecuredItemInvoker (org.apache.jena.permissions.impl.SecuredItemInvoker)1 SecuredProperty (org.apache.jena.permissions.model.SecuredProperty)1 Property (org.apache.jena.rdf.model.Property)1