use of org.apache.jena.permissions.model.SecuredLiteral in project jena by apache.
the class SecuredLiteralImpl method getInstance.
/**
* Get an instance of SecuredLiteral
*
* @param securedModel
* the item providing the security context.
* @param literal
* the literal to secure
* @return SecuredLiteral
*/
public static SecuredLiteral getInstance(final SecuredModel securedModel, final Literal literal) {
if (securedModel == null) {
throw new IllegalArgumentException("Secured securedModel may not be null");
}
if (literal == null) {
throw new IllegalArgumentException("literal may not be null");
}
// check that literal has a securedModel.
Literal goodLiteral = literal;
if (goodLiteral.getModel() == null) {
goodLiteral = securedModel.createTypedLiteral(literal.getLexicalForm(), literal.getDatatype());
}
final ItemHolder<Literal, SecuredLiteral> holder = new ItemHolder<>(goodLiteral);
final SecuredLiteralImpl checker = new SecuredLiteralImpl(securedModel, holder);
// one.
if (goodLiteral instanceof SecuredLiteral) {
if (checker.isEquivalent((SecuredLiteral) goodLiteral)) {
return (SecuredLiteral) goodLiteral;
}
}
return holder.setSecuredItem(new SecuredItemInvoker(literal.getClass(), checker));
}
Aggregations