예제 #1
0
 private static boolean isGrounded(Triple triple) {
   if (triple.getSubject() instanceof BlankNode) {
     return false;
   }
   if (triple.getObject() instanceof BlankNode) {
     return false;
   }
   return true;
 }
예제 #2
0
 // called withiong write-lock
 private void removeExistingRequiredReadPermissions(IRI GraphUri, Graph permissionMGraph) {
   try {
     Triple t = permissionMGraph.filter(GraphUri, readPermissionListProperty, null).next();
     RDFTerm list = t.getObject();
     removeList((BlankNodeOrIRI) list, permissionMGraph);
     permissionMGraph.remove(t);
   } catch (NoSuchElementException e) {
     // There was no existing to remove
   }
 }
예제 #3
0
 private void readList(BlankNodeOrIRI list, Graph permissionMGraph, LinkedList<String> target) {
   if (list.equals(rdfNil)) {
     return;
   }
   Triple restTriple = permissionMGraph.filter(list, rest, null).next();
   BlankNodeOrIRI restList = (BlankNodeOrIRI) restTriple.getObject();
   readList(restList, permissionMGraph, target);
   Triple firstTriple = permissionMGraph.filter(list, first, null).next();
   Literal firstValue = (Literal) firstTriple.getObject();
   String value = LiteralFactory.getInstance().createObject(String.class, firstValue);
   target.addFirst(value);
 }
예제 #4
0
 static Set<BlankNode> getBNodes(Collection<Triple> s) {
   Set<BlankNode> result = new HashSet<BlankNode>();
   for (Triple triple : s) {
     if (triple.getSubject() instanceof BlankNode) {
       result.add((BlankNode) triple.getSubject());
     }
     if (triple.getObject() instanceof BlankNode) {
       result.add((BlankNode) triple.getObject());
     }
   }
   return result;
 }
예제 #5
0
 private void removeList(BlankNodeOrIRI list, Graph permissionMGraph) {
   try {
     Triple t = permissionMGraph.filter(list, rest, null).next();
     RDFTerm restList = t.getObject();
     removeList((BlankNodeOrIRI) restList, permissionMGraph);
     permissionMGraph.remove(t);
     Iterator<Triple> iter = permissionMGraph.filter(list, first, null);
     iter.next();
     iter.remove();
   } catch (NoSuchElementException e) {
     // if it has no rest its rdf:NIL and has no first
   }
 }
예제 #6
0
 private Collection<String> getRequiredPermissionStrings(final IRI GraphUri, IRI property) {
   try {
     final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName);
     Lock l = permissionMGraph.getLock().readLock();
     l.lock();
     try {
       Triple t = permissionMGraph.filter(GraphUri, property, null).next();
       BlankNodeOrIRI list = (BlankNodeOrIRI) t.getObject();
       LinkedList<String> result = new LinkedList<String>();
       readList(list, permissionMGraph, result);
       return result;
     } catch (NoSuchElementException e) {
       return new ArrayList<String>(0);
     } finally {
       l.unlock();
     }
   } catch (NoSuchEntityException e) {
     return new ArrayList<String>(0);
   }
 }