Package org.apache.clerezza.rdf.utils

Examples of org.apache.clerezza.rdf.utils.GraphNode


    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);
    } finally {
      readLock.unlock();
    }
   
  }
View Full Code Here


    AccessController.checkPermission(new SecurityPermission("getPolicy"));
    if (role == null) {
      return;
    }
    LockableMGraph systemGraph = getSystemGraph();
    GraphNode graphNode = new GraphNode(role, systemGraph);
    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      graphNode.deleteProperties(PERMISSION.hasPermission);
    } finally {
      writeLock.unlock();
    }   
    //refresh the policy so it will recheck the permissions
    Policy.getPolicy().refresh();
View Full Code Here

    NonLiteral user = getUserByUserName(name);
    if (user == null) {
      throw new UserNotExistsException(name);
    }
    LockableMGraph systemGraph = getSystemGraph();
    GraphNode userGraphNode = new GraphNode(user, systemGraph);
    Lock writeLock = userGraphNode.writeLock();
    writeLock.lock();
    try {
      if (email != null) {
        updateProperty(userGraphNode, FOAF.mbox, new UriRef("mailto:" + email));
      }

      if (password != null) {
        try {
          String pswSha1 = bytes2HexString(MessageDigest.getInstance("SHA1").digest(password.getBytes("UTF-8")));
          updateProperty(userGraphNode, PERMISSION.passwordSha1, new PlainLiteralImpl(pswSha1));
        } catch (UnsupportedEncodingException ex) {
          throw new RuntimeException(ex);
        } catch (NoSuchAlgorithmException ex) {
          throw new RuntimeException(ex);
        }
      }
      if (pathPrefix != null && pathPrefix.trim().length() != 0) {
        updateProperty(userGraphNode, OSGI.agent_path_prefix,
            new PlainLiteralImpl(pathPrefix));
      }
      if (!assignedRoles.isEmpty()) {
        userGraphNode.deleteProperties(SIOC.has_function);
        addRolesToUser(assignedRoles, (NonLiteral) userGraphNode.getNode());
        //refresh the policy so it will recheck the permissions
        Policy.getPolicy().refresh();
      }
    } finally {
      writeLock.unlock();
View Full Code Here

  @Override
  public GraphNode getUserInSystemGraph(final String name) {
    LockableMGraph systemGraph = getSystemGraph();
    NonLiteral user = getUserByUserName(name);
    if (user != null) {
      return new GraphNode(user, systemGraph);
    } else {
      return null;
    }
  }
View Full Code Here

  @Override
  public GraphNode getUserInContentGraph(final String name) {
    final LockableMGraph contentGraph = (LockableMGraph) cgProvider.getContentGraph();
    Iterator<Triple> triples = contentGraph.filter(null, PLATFORM.userName,
        new PlainLiteralImpl(name));
    GraphNode resultNode = null;
    if (triples.hasNext()) {
      Lock readLock = contentGraph.getLock().readLock();
      readLock.lock();
      try {
        resultNode = new GraphNode(triples.next().getSubject(), contentGraph);
      } finally {
        readLock.unlock();
      }     
    } else {
      NonLiteral user = AccessController.doPrivileged(
          new PrivilegedAction<NonLiteral>() {

            @Override
            public NonLiteral run() {
              return getUserByUserName(name);
            }
          });
      if (user != null) {
        Lock writeLock = contentGraph.getLock().writeLock();
        writeLock.lock();
        try {
          resultNode = new GraphNode(new BNode(), contentGraph);
        resultNode.addProperty(PLATFORM.userName,
            new PlainLiteralImpl(name));
        } finally {
          writeLock.unlock();
        }
       
View Full Code Here

    List<ConceptProvider> conceptProviderList = conceptProviderManager
        .getConceptProviders();

    MGraph resultMGraph = new SimpleMGraph();
    GraphNode resultNode = new GraphNode(new BNode(), resultMGraph);
    boolean first = true;
    for (ConceptProvider cp : conceptProviderList) {
      if (!freeConceptProviderFound) {
        if (cp instanceof LocalConceptProvider) {
          if (((LocalConceptProvider) cp).getSelectedScheme().equals(
              freeConceptScheme)) {
            freeConceptProviderFound = true;
          }
        }
      }
      retrieveConcepts(cp, first, resultNode, searchTerm);
      if (first) {
        first = false;
      }
    }
    if (!freeConceptProviderFound && freeConceptProvider != null) {
      retrieveConcepts(freeConceptProvider, first, resultNode, searchTerm);
    }
    addCreationOfNewFreeConceptSuggested(resultNode, searchTerm);
    resultNode.addProperty(RDF.type, QUERYRESULT.QueryResult);
    return resultNode;
  }
View Full Code Here

  @Override
  public GraphNode getUserGraphNode(final String name) {
    LockableMGraph systemGraph = getSystemGraph();
    NonLiteral user = getUserByUserName(name);
    if (user != null) {
      GraphNode userNodeInSystemGraph =
          new GraphNode(getUserByUserName(name), systemGraph);
      MGraph copiedUserContext = new SimpleMGraph(userNodeInSystemGraph.getNodeContext());
      return new GraphNode(userNodeInSystemGraph.getNode(),
          copiedUserContext);
    } else {
      return null;
    }
  }
View Full Code Here

      }
      resultMGraph.addAll(graph);
    } else {
      while (concepts.hasNext()) {
        NonLiteral concept = concepts.next().getSubject();
        GraphNode conceptGraphNode = new GraphNode(concept, graph);
        Iterator<Resource> sameAsConcepts = conceptGraphNode
            .getObjects(OWL.sameAs);
        if (!(hasSameAs(resultMGraph, concept) || hasAnyConcept(
            resultMGraph, sameAsConcepts))) {
          resultNode.addProperty(QUERYRESULT.concept, concept);
          addConceptToResultMGraph(resultMGraph, conceptGraphNode);
View Full Code Here

  @Reference
  UserManager userManager;

  @Override
  public void userLoggedIn(String userName) {
    GraphNode userNode  = userManager.getUserInSystemGraph(userName);
    Lock l = userNode.writeLock();
    l.lock();
    try {
      userNode.deleteProperties(PLATFORM.lastLogin);
      userNode.addProperty(PLATFORM.lastLogin, LiteralFactory.getInstance().createTypedLiteral(new Date()));
    } finally {
      l.unlock();
    }
  }
View Full Code Here

  }

  @GET
  public GraphNode overviewPage() {
    MGraph resultGraph = new SimpleMGraph();
    GraphNode result = new GraphNode(new BNode(), resultGraph);
    result.addProperty(RDF.type, BACKUP.BackupAdminPage);
    result.addProperty(RDF.type, PLATFORM.HeadedPage);
    return result;
  }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.utils.GraphNode

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.