Package org.apache.clerezza.rdf.core.access

Examples of org.apache.clerezza.rdf.core.access.LockableMGraph


    }
  }

  @Override
  public NonLiteral getRoleByTitle(String title) {
    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      Iterator<Triple> triples = systemGraph.filter(null, DC.title,
          new PlainLiteralImpl(title));
      NonLiteral role = null;
      while (triples.hasNext()) {
        role = triples.next().getSubject();
        if (systemGraph.filter(role, RDF.type, PERMISSION.Role).hasNext()) {
          return role;
        }
      }
    } finally {
      readLock.unlock();
View Full Code Here


    return getRoleByTitle(title) != null;
  }

  @Override
  public Iterator<NonLiteral> getRoles() {
    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      final Iterator<NonLiteral> allRolesIter = getResourcesOfType(PERMISSION.Role);
      final Set<NonLiteral> allRolesSet = new HashSet<NonLiteral>();
      while (allRolesIter.hasNext()) {
        allRolesSet.add(allRolesIter.next());
      }
      final Set<NonLiteral> nonBaseRolesSet = new HashSet<NonLiteral>();
      for (NonLiteral role : allRolesSet) {
        if (!systemGraph.filter(role, RDF.type, PERMISSION.BaseRole).hasNext()) {
          nonBaseRolesSet.add(role);
        }
      }
      return nonBaseRolesSet.iterator();
    } finally {
View Full Code Here

    }   
  }

  @Override
  public Iterator<NonLiteral> getRolesOfUser(NonLiteral user){
    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      final Iterator<Triple> triples = systemGraph.filter(user,SIOC.has_function, null);
      Set<NonLiteral> userRoles = new HashSet<NonLiteral>();
      while (triples.hasNext()) {
        userRoles.add((NonLiteral) triples.next().getObject());
      }
      return userRoles.iterator();
View Full Code Here

    }
    deleteTriplesOfASubject(role);
  }

  private boolean isBaseRole(NonLiteral role) {
    LockableMGraph systemGraph = getSystemGraph();
    GraphNode roleNode = new GraphNode(role, systemGraph);
    Lock readLock = roleNode.readLock();
    readLock.lock();
    try {
      return roleNode.hasProperty(RDF.type, PERMISSION.BaseRole);
View Full Code Here

    }
   
  }

  private void deleteTriplesOfASubject(NonLiteral subject) {
    LockableMGraph systemGraph = getSystemGraph();
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      Iterator<Triple> triples = systemGraph.filter(subject, null, null);
      while (triples.hasNext()) {
        triples.next();
        triples.remove();
      }
    } finally {
View Full Code Here

      return;
    }
    if (permissionEntries.isEmpty()) {
      return;
    }
    LockableMGraph systemGraph = getSystemGraph();
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      for (String permissionEntry : permissionEntries) {
        if (permissionEntry.trim().length() == 0) {
          continue;
        }
        systemGraph.add(new TripleImpl(role, PERMISSION.hasPermission,
            getPermissionOfAJavaPermEntry(permissionEntry)));
      }
    } finally {
      writeLock.unlock();
    }
View Full Code Here

   * @param permissionString the specified java permission entry
   * @return permission node
   */
  private NonLiteral getPermissionOfAJavaPermEntry(
      String permissionString) {
    LockableMGraph systemGraph = getSystemGraph();
    PlainLiteral javaPermEntry = new PlainLiteralImpl(permissionString);
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      Iterator<Triple> javaPermTriples = systemGraph.filter(null,
          PERMISSION.javaPermissionEntry, javaPermEntry);
      if (javaPermTriples.hasNext()) {
        return javaPermTriples.next().getSubject();
      }
    } finally {
      readLock.unlock();
    }

    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      BNode result = new BNode();
      systemGraph.add(new TripleImpl(result,
          PERMISSION.javaPermissionEntry, javaPermEntry));
      return result;
    } finally {
      writeLock.unlock();
    }
View Full Code Here

    }
  }

  @Override
  public Iterator<NonLiteral> getPermissionsOfRole(NonLiteral role) {
    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      final Iterator<Triple> triples = systemGraph.filter(role,
          PERMISSION.hasPermission, null);
      Set<NonLiteral> permissions = new HashSet<NonLiteral>();
      while (triples.hasNext()) {
        permissions.add((NonLiteral) triples.next().getObject());
      }
View Full Code Here

      return;
    }
    if (permissionEntries.isEmpty()) {
      return;
    }
    LockableMGraph systemGraph = getSystemGraph();
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      for (String permissionEntry : permissionEntries) {
        NonLiteral permission = getPermissionOfAJavaPermEntry(permissionEntry);
        systemGraph.remove(new TripleImpl(role, PERMISSION.hasPermission,
            permission));
      }
    } finally {
      writeLock.unlock();
    }
View Full Code Here

    if (defaultBaseUri.charAt(defaultBaseUri.length() - 1) != SLASH) {
      defaultBaseUri += SLASH;
    }
    UriRef uri = new UriRef(defaultBaseUri);
    GraphNode node = platformConfig.getPlatformInstance();
    LockableMGraph sysGraph = (LockableMGraph) node.getGraph();
    Lock writeLock = sysGraph.getLock().writeLock();
    writeLock.lock();
    try {
      node.deleteProperties(PLATFORM.defaultBaseUri);
      node.addProperty(PLATFORM.defaultBaseUri, uri);
    } finally {
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.access.LockableMGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.