use of org.apache.jena.rdf.model.ListIndexException in project jena by apache.
the class SecuredRDFListImpl method replace.
/**
* @sec.graph Update
* @sec.triple Update for triple i, and value.
* @throws UpdateDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
* @throws AuthenticationRequiredException if user is not authenticated and is
* required to be.
*/
@Override
public SecuredRDFNode replace(final int i, final RDFNode value) throws UpdateDeniedException, AuthenticationRequiredException, ListIndexException {
checkUpdate();
// get all the ones we can see since the replace must be against one we could
// see.
final ExtendedIterator<RDFList> iter = getFilteredRDFListIterator(Action.Read);
int idx = 0;
try {
while (iter.hasNext()) {
// seek to the proper position.
if (i == idx) {
// verify we can delete and if so delete.
final RDFList list = iter.next();
final RDFNode retval = list.getRequiredProperty(RDF.first).getObject();
final Triple t = new Triple(list.asNode(), RDF.first.asNode(), retval.asNode());
final Triple t2 = new Triple(list.asNode(), RDF.first.asNode(), value.asNode());
checkUpdate(t, t2);
list.getRequiredProperty(RDF.first).changeObject(value);
return SecuredRDFNodeImpl.getInstance(getModel(), retval);
}
idx++;
iter.next();
}
throw new ListIndexException();
} finally {
iter.close();
}
}
Aggregations