Search in sources :

Example 1 with UnsupportedPolymorphismException

use of org.apache.jena.enhanced.UnsupportedPolymorphismException in project jena by apache.

the class SecuredRDFNodeImpl method as.

@SuppressWarnings("unchecked")
@Override
public <T extends RDFNode> T as(final Class<T> view) throws ReadDeniedException, AuthenticationRequiredException, SecuredUnsupportedPolymorphismException {
    checkRead();
    // see if the base Item can as
    T baseAs = holder.getBaseItem().as(view);
    if (view.equals(SecuredRDFNodeImpl.class) || view.equals(RDFNode.class)) {
        return (T) this;
    }
    final Method m = getConstructor(view);
    if (m == null) {
        throw new SecuredUnsupportedPolymorphismException(this, view);
    }
    try {
        return (T) m.invoke(null, securedModel, baseAs);
    } catch (final UnsupportedPolymorphismException e) {
        throw new SecuredUnsupportedPolymorphismException(this, view);
    } catch (final IllegalArgumentException e) {
        throw new RuntimeException(e);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (final InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : SecuredUnsupportedPolymorphismException(org.apache.jena.permissions.model.SecuredUnsupportedPolymorphismException) UnsupportedPolymorphismException(org.apache.jena.enhanced.UnsupportedPolymorphismException) SecuredUnsupportedPolymorphismException(org.apache.jena.permissions.model.SecuredUnsupportedPolymorphismException) Method(java.lang.reflect.Method) SecuredRDFNode(org.apache.jena.permissions.model.SecuredRDFNode) RDFNode(org.apache.jena.rdf.model.RDFNode) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 UnsupportedPolymorphismException (org.apache.jena.enhanced.UnsupportedPolymorphismException)1 SecuredRDFNode (org.apache.jena.permissions.model.SecuredRDFNode)1 SecuredUnsupportedPolymorphismException (org.apache.jena.permissions.model.SecuredUnsupportedPolymorphismException)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1