Package org.structr.core.app

Examples of org.structr.core.app.App


  }

  public static void removeAllDynamicGrants() {

    final App app = StructrApp.getInstance();
    try {

      // delete grants
      for (DynamicResourceAccess grant : app.nodeQuery(DynamicResourceAccess.class).getAsList()) {
        app.delete(grant);
      }

    } catch (Throwable t) {

      t.printStackTrace();
View Full Code Here


    }
  }

  public static void removeDynamicGrants(final String signature) {

    final App app = StructrApp.getInstance();
    try {

      // delete grant
      DynamicResourceAccess grant = app.nodeQuery(DynamicResourceAccess.class).and(DynamicResourceAccess.signature, signature).getFirst();
      if (grant != null) {

        app.delete(grant);
      }

      // delete grant
      DynamicResourceAccess schemaGrant = app.nodeQuery(DynamicResourceAccess.class).and(DynamicResourceAccess.signature, "_schema/" + signature).getFirst();
      if (schemaGrant != null) {

        app.delete(schemaGrant);
      }
      // delete grant
      DynamicResourceAccess viewGrant = app.nodeQuery(DynamicResourceAccess.class).and(DynamicResourceAccess.signature, signature + "/_Ui").getFirst();
      if (viewGrant != null) {

        app.delete(viewGrant);
      }

    } catch (Throwable t) {

      t.printStackTrace();
View Full Code Here

    return null;
  }

  public void addMember(final Principal user) throws FrameworkException {

    final App app = StructrApp.getInstance(securityContext);
    List<Principal> _users = getProperty(members);
    _users.add(user);

    setProperty(members, _users);
  }
View Full Code Here

    setProperty(members, _users);
  }

  public void removeMember(final Principal user) throws FrameworkException {

    final App app = StructrApp.getInstance(securityContext);
    List<Principal> _users = getProperty(members);
    _users.remove(user);

    setProperty(members, _users);
  }
View Full Code Here

    }
  }

  private void unlinkNodes(final Class<R> linkType, final T startNode, final T endNode) throws FrameworkException {

    final App app = StructrApp.getInstance(securityContext);

    for (RelationshipInterface rel : startNode.getRelationships(linkType)) {

      if (rel != null && rel.getTargetNode().equals(endNode)) {
        app.delete(rel);
      }
    }
  }
View Full Code Here

    // Do nothing if new id equals old
    if (getSourceNodeId().equals(startNodeId)) {
      return;
    }

    final App app = StructrApp.getInstance(securityContext);

    final NodeInterface newStartNode = (NodeInterface)app.get(startNodeId);
    final NodeInterface endNode      = getTargetNode();
    final Class relationType         = getClass();
    final PropertyMap _props         = getProperties();
    final String type                = this.getClass().getSimpleName();

    if (newStartNode == null) {
      throw new FrameworkException(type, new IdNotFoundToken(startNodeId));
    }

    // delete this as the new rel will be the container afterwards
    app.delete(this);

    // create new relationship
    app.create(newStartNode, endNode, relationType, _props);
  }
View Full Code Here

    // Do nothing if new id equals old
    if (getTargetNodeId().equals(targetIdNode)) {
      return;
    }

    final App app = StructrApp.getInstance(securityContext);

    final NodeInterface newTargetNode = (NodeInterface)app.get(targetIdNode);
    final NodeInterface startNode     = getSourceNode();
    final Class relationType          = getClass();
    final PropertyMap _props          = getProperties();
    final String type                 = this.getClass().getSimpleName();

    if (newTargetNode == null) {
      throw new FrameworkException(type, new IdNotFoundToken(targetIdNode));
    }

    // delete this as the new rel will be the container afterwards
    app.delete(this);

    // create new relationship and store here
    app.create(startNode, newTargetNode, relationType, _props);
  }
View Full Code Here

  }

  @Override
  public void ensureCardinality(final SecurityContext securityContext, final NodeInterface sourceNode, final NodeInterface targetNode) throws FrameworkException {

    final App app                          = StructrApp.getInstance();
    final Class<? extends OneToMany> clazz = this.getClass();
    final Class<S> sourceType              = getSourceType();

    if (targetNode != null) {

      // check existing relationships
      final Relation<?, T, ?, ?> incomingRel = targetNode.getIncomingRelationship(clazz);
//      if (incomingRel != null && sourceType.isAssignableFrom(incomingRel.getSourceType())) {
      if (incomingRel != null && sourceType.isInstance(incomingRel.getSourceNode())) {

        app.delete(incomingRel);
      }
    }
  }
View Full Code Here

  }

  @Override
  public void set(final SecurityContext securityContext, final NodeInterface sourceNode, final Iterable<T> collection) throws FrameworkException {

    final App app            = StructrApp.getInstance(securityContext);
    final Set<T> toBeDeleted = new LinkedHashSet<>(Iterables.toList(get(securityContext, sourceNode, null)));
    final Set<T> toBeCreated = new LinkedHashSet<>();

    if (collection != null) {
      Iterables.addAll(toBeCreated, collection);
    }

    // create intersection of both sets
    final Set<T> intersection = new LinkedHashSet<>(toBeCreated);
    intersection.retainAll(toBeDeleted);

    // intersection needs no change
    toBeCreated.removeAll(intersection);
    toBeDeleted.removeAll(intersection);
   
    // remove existing relationships
    for (T targetNode : toBeDeleted) {

      for (AbstractRelationship rel : sourceNode.getOutgoingRelationships()) {

        final String relTypeName    = rel.getRelType().name();
        final String desiredRelType = relation.name();
       
        if (relTypeName.equals(desiredRelType) && rel.getTargetNode().equals(targetNode)) {

          app.delete(rel);
        }

      }
    }
   
    // test: obtain properties from notion
    // create new relationships
    for (T targetNode : toBeCreated) {

      relation.ensureCardinality(securityContext, sourceNode, targetNode);

      app.create(sourceNode, targetNode, relation.getClass(), getNotionProperties(securityContext, relation.getClass(), targetNode.getUuid()));
    }
  }
View Full Code Here

      setAllowed(newPermissions);

    } else {

      final App app = StructrApp.getInstance(securityContext);
      app.delete(this);
    }

  }
View Full Code Here

TOP

Related Classes of org.structr.core.app.App

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.