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

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


  @Path("save")
  public Response savePrefixBinding(@Context UriInfo uriInfo,
      @FormParam("prefix") String prefix,
      @FormParam("binding") String bindingValue,
       @FormParam("oldBinding") String oldBindingValue) {
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    Lock l = contentGraph.getLock().writeLock();
    l.lock();
   
    try {
      NonLiteral binding = getBindingWithValue(bindingValue, contentGraph);
      if (binding == null) {
View Full Code Here


  @POST
  @Path("delete")
  public Response delete(@Context UriInfo uriInfo,
      @FormParam("binding") String bindingValue) {
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    Lock l = contentGraph.getLock().writeLock();
    l.lock();
    try {
      NonLiteral binding = getBindingWithValue(bindingValue, contentGraph);
      GraphNode bindingNode = new GraphNode(binding, contentGraph);
      bindingNode.deleteProperty(RDF.type, CURIE.CuriePrefixBinding);
View Full Code Here

  @GET
  public GraphNode list(@Context UriInfo uriInfo) {
    TrailingSlash.enforcePresent(uriInfo);
    TripleCollection resultGraph = new SimpleMGraph();
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    GraphNode result = new GraphNode(new BNode(), new UnionMGraph(resultGraph, contentGraph));
    RdfList list = new RdfList(result);   
    Lock l = contentGraph.getLock().readLock();
    l.lock();
    try {
      Iterator<Triple> greetings = contentGraph.filter(null, RDF.type, CURIE.CuriePrefixBinding);
      while (greetings.hasNext()) {
        list.add(greetings.next().getSubject());
      }
    } finally {
      l.unlock();
View Full Code Here

  @GET
  @Path("get")
  public GraphNode getSingle(@QueryParam("binding") String bindingValue) {
    TripleCollection resultGraph = new SimpleMGraph();
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    MGraph unionMGraph = new UnionMGraph(resultGraph, contentGraph);
    Lock l = contentGraph.getLock().readLock();
    l.lock();
    try {
      GraphNode result = new GraphNode(getBindingWithValue(bindingValue, contentGraph), unionMGraph);
      result.addProperty(RDF.type, PLATFORM.HeadedPage);
      return result;
View Full Code Here

    }
  }

  @Override
  public String getRecommendedPrefix(String iriPrefix) {
    LockableMGraph contentGraph = cgProvider.getContentGraph();
    Lock l = contentGraph.getLock().readLock();
    l.lock();
    try {
      NonLiteral binding = getBindingWithValue(iriPrefix, contentGraph);
      if (binding == null) {
        return null;
View Full Code Here

  private void deleteAllPermissionEntriesOfARole(NonLiteral role) {
    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();
View Full Code Here

      if (storedName != null && !name.equals(storedName)) {
        throw new EmailAlreadyAssignedException(email, storedName);
      }
    }
    BNode user = new BNode();
    LockableMGraph systemGraph = getSystemGraph();
    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);
      }     
View Full Code Here

  public String getNameByEmail(String email)
      throws UserHasNoNameException {
    if (email == null) {
      return null;
    }
    LockableMGraph systemGraph = getSystemGraph();
    Lock readLock = systemGraph.getLock().readLock();
    readLock.lock();
    try {
      Iterator<Triple> triples = systemGraph.filter(null, FOAF.mbox,
          new UriRef("mailto:" + email));
      if (!triples.hasNext()) {
        return null;
      }
      NonLiteral user = triples.next().getSubject();
      triples = systemGraph.filter(user, PLATFORM.userName, null);
      if (!triples.hasNext()) {
        throw new UserHasNoNameException("User with email address" + email
            + " does not have a name");
      }
      return ((PlainLiteral) triples.next().getObject()).getLexicalForm();
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) {
View Full Code Here

      writeLock.unlock();
    }
  }

  private void addRolesToUser(Collection<String> assignedRoles, NonLiteral user) throws RoleUnavailableException {
    LockableMGraph systemGraph = getSystemGraph();
    for (String roleTitle : assignedRoles) {
      // skip empty strings
      if ((roleTitle == null) || (roleTitle.trim().length() == 0)) {
        continue;
      }
      NonLiteral role = getRoleByTitle(roleTitle);
      if (role == null) {
        throw new RoleUnavailableException(roleTitle);
      }
      systemGraph.add(new TripleImpl(user, SIOC.has_function, role));
    }
  }
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.