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));
}
Aggregations