Package org.structr.core.property

Examples of org.structr.core.property.PropertyMap


        // Clear properties set by us from the user-defined props
        propertySet.remove(credentialKey.jsonName());
        propertySet.remove(User.name.jsonName());
        propertySet.remove(User.confirmationKey.jsonName());

        PropertyMap props = PropertyMap.inputTypeToJavaType(securityContext, Principal.class, propertySet);

        props.put(credentialKey, credentialValue);
        props.put(User.name, credentialValue);
        props.put(User.confirmationKey, confKey);
       
        // Remove security-relevant properties
        props.remove(Principal.isAdmin);
        props.remove(Principal.ownedNodes);
        props.remove(Principal.salt);
        props.remove(Principal.sessionIds);

        user = (Principal) StructrApp.getInstance(securityContext).create(userClass, props);

      }
View Full Code Here


  }

  @Override
  public RestMethodResult doPost(Map<String, Object> propertySet) throws FrameworkException {

    PropertyMap properties = PropertyMap.inputTypeToJavaType(securityContext, User.class, propertySet);

    String name          = properties.get(User.name);
    String email         = properties.get(User.eMail);
    String password      = properties.get(User.password);

    String emailOrUsername = StringUtils.isNotEmpty(email) ? email : name;

    if (StringUtils.isNotEmpty(emailOrUsername) && StringUtils.isNotEmpty(password)) {
View Full Code Here

      DOMNode parentNode        = (DOMNode) getNode(parentId);
      DOMNode nodeToInsert      = null;

      try {

        PropertyMap nodeProperties = PropertyMap.inputTypeToJavaType(securityContext, properties);

        nodeToInsert = app.create(DOMNode.class, nodeProperties);
       
      } catch (FrameworkException fex) {

        logger.log(Level.WARNING, "Could not create node.", fex);
        getWebSocket().send(MessageBuilder.status().code(fex.getStatus()).message(fex.getMessage()).build(), true);

      }

      if ((nodeToInsert != null) && (parentNode != null)) {

        try {

          PropertyMap relProperties = PropertyMap.inputTypeToJavaType(securityContext, relData);
          app.create(parentNode, nodeToInsert, DOMChildren.class, relProperties);
         
        } catch (FrameworkException t) {

          getWebSocket().send(MessageBuilder.status().code(400).message(t.getMessage()).build(), true);
View Full Code Here

  @Override
  public void updateFromNode(final DOMNode newNode) throws FrameworkException {

    if (newNode instanceof Content) {

      final PropertyMap properties = new PropertyMap();
      properties.put(Content.content, newNode.getProperty(Content.content));

      updateFromPropertyMap(properties);
    }
  }
View Full Code Here

        // commit and close transaction
        tx.success();
      }

      final PropertyMap properties         = PropertyMap.inputTypeToJavaType(this.getWebSocket().getSecurityContext(), obj.getClass(), webSocketData.getNodeData());
      final Iterator<GraphObject> iterator = entities.iterator();

      while (iterator.hasNext()) {

        count = 0;
View Full Code Here

    return createTestNodes(type, number, 0);

  }

  protected <T extends AbstractNode> T createTestNode(final Class<T> type) throws FrameworkException {
    return (T)createTestNode(type, new PropertyMap());
  }
View Full Code Here

  private static final Logger logger = Logger.getLogger(CreateNodeCommand.class.getName());

  public T execute(Collection<NodeAttribute<?>> attributes) throws FrameworkException {
   
    PropertyMap properties = new PropertyMap();
    for (NodeAttribute attribute : attributes) {
     
      properties.put(attribute.getKey(), attribute.getValue());
    }
   
    return execute(properties);
   
  }
View Full Code Here

   
  }
 
  public T execute(NodeAttribute<?>... attributes) throws FrameworkException {
   
    PropertyMap properties = new PropertyMap();
    for (NodeAttribute attribute : attributes) {
     
      properties.put(attribute.getKey(), attribute.getValue());
    }
   
    return execute(properties);
  }
View Full Code Here

    if (graphDb != null) {

      Date now                            = new Date();

      // Determine node type
      PropertyMap properties     = new PropertyMap(attributes);
      Object typeObject          = properties.get(AbstractNode.type);
      Class nodeType             = typeObject != null ? SchemaHelper.getEntityClassForRawType(typeObject.toString()) : StructrApp.getConfiguration().getFactoryDefinition().getGenericNodeType();
      NodeFactory<T> nodeFactory = new NodeFactory<>(securityContext);
      boolean isCreation         = true;

      // Create node with type
      node = (T) nodeFactory.instantiateWithType(graphDb.createNode(), nodeType, isCreation);
      if(node != null) {
       
        TransactionCommand.nodeCreated(node);

        // set type
        if (nodeType != null) {
         
          node.unlockReadOnlyPropertiesOnce();
          node.setProperty(GraphObject.type, nodeType.getSimpleName());
        }

        // set UUID
        node.unlockReadOnlyPropertiesOnce();
        node.setProperty(GraphObject.id, getNextUuid());

        // set created date
        node.unlockReadOnlyPropertiesOnce();
        node.setProperty(AbstractNode.createdDate, now);

        // set last modified date
        node.unlockReadOnlyPropertiesOnce();
        node.setProperty(AbstractNode.lastModifiedDate, now);

        // properties.remove(AbstractNode.type);
       
        if ((user != null) && user instanceof AbstractNode) {

          // Create new relationship to user and grant permissions to user or group
          Principal owner = (Principal)user;

          App app = StructrApp.getInstance(securityContext);
         
          app.create(owner, (NodeInterface)node, PrincipalOwnsNode.class);
         
          Security securityRel = app.create(owner, (NodeInterface)node, Security.class);
          securityRel.setAllowed(Permission.values());

          node.unlockReadOnlyPropertiesOnce();
          node.setProperty(AbstractNode.createdBy, user.getProperty(GraphObject.id));
        }

        for (Entry<PropertyKey, Object> attr : properties.entrySet()) {

          Object value = attr.getValue();
          PropertyKey key = attr.getKey();
          if (key.isReadOnly()) {
            node.unlockReadOnlyPropertiesOnce();
          }
          node.setProperty(key, value);

        }

        properties.clear();
      }

    }

    if (node != null) {
View Full Code Here

      Result<T> results = Result.EMPTY_RESULT;
     
      if (source instanceof JsonInput) {

        JsonInput properties = (JsonInput) source;
        PropertyMap map      = PropertyMap.inputTypeToJavaType(securityContext, type, properties.getAttributes());
       
        // If property map contains the uuid, search only for uuid
        if (map.containsKey(GraphObject.id)) {
       
          return (T) app.get(map.get(GraphObject.id));

         
        } else {
         
          throw new FrameworkException(type.getSimpleName(), new IdNotFoundToken(source));
View Full Code Here

TOP

Related Classes of org.structr.core.property.PropertyMap

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.