Package org.apache.clerezza.rdf.core.impl

Examples of org.apache.clerezza.rdf.core.impl.PlainLiteralImpl


    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      systemGraph.add(new TripleImpl(role, RDF.type, PERMISSION.Role));
      systemGraph.add(new TripleImpl(role, DC.title,
          new PlainLiteralImpl(title)));
    } finally {
      writeLock.unlock();
    }
  }
View Full Code Here


    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;
View Full Code Here

   * @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);
View Full Code Here

    Lock writeLock = systemGraph.getLock().writeLock();
    writeLock.lock();
    try {
      systemGraph.add(new TripleImpl(user, RDF.type, FOAF.Agent));
      systemGraph.add(new TripleImpl(user, PLATFORM.userName,
          new PlainLiteralImpl(name)));
      if (email != null) {
        systemGraph.add(new TripleImpl(user, FOAF.mbox,
            new UriRef("mailto:" + email)));
      }
      if (password != null) {
        try {
          String pswSha1 = bytes2HexString(MessageDigest.getInstance("SHA1").digest(password.getBytes("UTF-8")));
          systemGraph.add(new TripleImpl(user, 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) {
        systemGraph.add(new TripleImpl(user, OSGI.agent_path_prefix,
            new PlainLiteralImpl(pathPrefix)));
      }
      if (!assignedRoles.isEmpty()) {
        addRolesToUser(assignedRoles, user);
      }     
    } finally {
View Full Code Here

      }

      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
View Full Code Here

    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      return systemGraph.filter(null, PLATFORM.userName,
        new PlainLiteralImpl(name)).hasNext();
    } finally {
      readLock.unlock();
    }   
  }
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

    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      Iterator<Triple> triples = systemGraph.filter(null, PLATFORM.userName,
          new PlainLiteralImpl(name));
      if (triples.hasNext()) {
        return triples.next().getSubject();
      }
      return null;
    } finally {
View Full Code Here

  @Test
  public void simple() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, simpleFunctions);

    StringReader reader = new StringReader("${ns:rdfs=http://www.w3.org/2000/01/rdf-schema#}${rdfs:comment}");
    StringWriter writer = new StringWriter();
View Full Code Here

  @Test
  public void defaultFunction() throws IOException {
    TripleCollection mGraph = new SimpleMGraph();
    NonLiteral resource = new BNode() {
    };
    mGraph.add(new TripleImpl(resource, RDFS.comment, new PlainLiteralImpl("a resource")));
    GraphNode node = new GraphNode(resource, mGraph);
    DataFieldResolver dataFieldResolver = new GraphNodeDataFieldResolver(node, new RenderingFunctions() {

      @Override
      public RenderingFunction<Object, String> getDefaultFunction() {
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.impl.PlainLiteralImpl

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.