Search in sources :

Example 6 with PropertyNotFoundException

use of org.apache.jena.shared.PropertyNotFoundException in project jena by apache.

the class SecuredResourceImpl method getRequiredProperty.

@Override
public SecuredStatement getRequiredProperty(Property p, String lang) throws PropertyNotFoundException, ReadDeniedException, AuthenticationRequiredException {
    checkRead();
    final ExtendedIterator<Statement> iter = holder.getBaseItem().listProperties(p, lang).filterKeep(new PermStatementFilter(Action.Read, this));
    try {
        if (iter.hasNext()) {
            return org.apache.jena.permissions.model.impl.SecuredStatementImpl.getInstance(getModel(), iter.next());
        } else {
            throw new PropertyNotFoundException(p);
        }
    } finally {
        iter.close();
    }
}
Also used : PermStatementFilter(org.apache.jena.permissions.utils.PermStatementFilter) PropertyNotFoundException(org.apache.jena.shared.PropertyNotFoundException) SecuredStatement(org.apache.jena.permissions.model.SecuredStatement)

Example 7 with PropertyNotFoundException

use of org.apache.jena.shared.PropertyNotFoundException in project jena by apache.

the class RDFInput method buildBinding.

private Binding buildBinding(Resource soln) {
    // foreach row
    BindingMap rb = BindingFactory.create();
    StmtIterator bindingIter = soln.listProperties(ResultSetGraphVocab.binding);
    for (; bindingIter.hasNext(); ) {
        Resource binding = bindingIter.nextStatement().getResource();
        String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString();
        try {
            RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject();
            rb.add(Var.alloc(var), val.asNode());
        } catch (PropertyNotFoundException ex) {
            Log.warn(this, "Failed to get value for ?" + var);
        }
    // We include the value even if it is the marker term "rs:undefined"
    // if ( val.equals(ResultSetVocab.undefined))
    // continue ;
    // The ResultSetFormatter code equates null (not found) with
    // rs:undefined. When Jena JUnit testing, it does not matter if the
    // recorded result has the term absent or explicitly undefined.
    }
    bindingIter.close();
    return rb;
}
Also used : PropertyNotFoundException(org.apache.jena.shared.PropertyNotFoundException) BindingMap(org.apache.jena.sparql.engine.binding.BindingMap)

Aggregations

PropertyNotFoundException (org.apache.jena.shared.PropertyNotFoundException)7 Statement (org.apache.jena.rdf.model.Statement)3 SecuredStatement (org.apache.jena.permissions.model.SecuredStatement)2 PermStatementFilter (org.apache.jena.permissions.utils.PermStatementFilter)2 ReifiedStatement (org.apache.jena.rdf.model.ReifiedStatement)2 ReadDeniedException (org.apache.jena.shared.ReadDeniedException)2 Resource (org.apache.jena.rdf.model.Resource)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)1 Test (org.junit.Test)1