Package org.exoplatform.services.jcr.impl.dataflow

Examples of org.exoplatform.services.jcr.impl.dataflow.TransientNodeData


      DataManager mergeDataManager = mergeSession.getTransientNodesManager().getTransactManager();

      QPath mergePath = mergeNode.getQPath();

      TransientNodeData mergedNode =
         new TransientNodeData(mergePath, mergeNode.getIdentifier(), mergeNode.getPersistedVersion(),
            corrNode.getPrimaryTypeName(), corrNode.getMixinTypeNames(), mergeNode.getOrderNumber(),
            mergeNode.getParentIdentifier(), mergeNode.getACL());

      if (!mergeNode.getIdentifier().equals(corrNode.getIdentifier()))
      {

         NodeData existedSameIdentifier = (NodeData)mergeDataManager.getItemData(corrNode.getIdentifier());
         if (existedSameIdentifier != null)
         {
            // if an incoming node has the same
            // UUID as a node already existing in this workspace,
            // the already existing node is removed

            RemoveVisitor remover = new RemoveVisitor();
            existedSameIdentifier.accept(remover);

            changes.addAll(remover.getRemovedStates());
         }
      }

      changes.add(new ItemState(mergedNode, ItemState.UPDATED, true, mergeNode.getQPath(), true));

      // replace set of properties of n with those of n'.
      DataManager corrDataManager = corrSession.getTransientNodesManager().getTransactManager();
      List<PropertyData> corrChildProps = corrDataManager.getChildPropertiesData(corrNode);
      List<PropertyData> mergeChildProps = mergeDataManager.getChildPropertiesData(mergeNode);

      Map<InternalQName, PropertyData> existedProps = new HashMap<InternalQName, PropertyData>();
      for (PropertyData cp : mergeChildProps)
      {
         TransientPropertyData existed =
            new TransientPropertyData(cp.getQPath(), cp.getIdentifier(), cp.getPersistedVersion(), cp.getType(),
               cp.getParentIdentifier(), cp.isMultiValued(), copyValues(cp));
         changes.add(new ItemState(existed, ItemState.DELETED, true, mergedNode.getQPath(), true));

         existedProps.put(existed.getQPath().getName(), existed);
      }

      for (PropertyData cp : corrChildProps)
      {
         PropertyData existed = existedProps.get(cp.getQPath().getName());
         TransientPropertyData mcp =
            new TransientPropertyData(QPath.makeChildPath(mergePath, cp.getQPath().getName()), existed != null
               ? existed.getIdentifier() : cp.getIdentifier(), existed != null ? existed.getPersistedVersion()
               : cp.getPersistedVersion(), cp.getType(), mergedNode.getIdentifier(), cp.isMultiValued(), copyValues(cp));

         changes.add(new ItemState(mcp, ItemState.ADDED, true, mergedNode.getQPath(), true));
      }

      List<NodeData> childNodes = corrDataManager.getChildNodesData(corrNode);
      parents.push(new ContextParent(mergedNode, childNodes, UPDATE));
View Full Code Here


         {
            if (parent != null)
            {
               // use parent ACL
               node =
                  new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
                     node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
                     node.getParentIdentifier(), parent.getACL());
            }
            else
            {
               if (search == null)
               {
                  search = new ACLSearch(null, null);
               }
               // use nearest ancestor ACL... case of get by id
               node =
                  new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
                     node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
                     node.getParentIdentifier(), getNearestACAncestorAcl(node, search));
            }
         }
         else if (!acl.hasPermissions())
         {
            // use nearest ancestor permissions
            if (search == null)
            {
               search = new ACLSearch(acl.getOwner(), null);
            }
            else
            {
               search.setOwner(acl.getOwner());
               if (search.found())
               {
                  return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
                     node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
                     node.getParentIdentifier(), new AccessControlList(acl.getOwner(), null));
               }
            }
            AccessControlList ancestorAcl =
               parent != null && parent.getACL() != null && parent.getACL().hasPermissions() ? parent.getACL()
                  : getNearestACAncestorAcl(node, search);

            node =
               new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
                  .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
                  new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
         }
         else if (!acl.hasOwner())
         {
            if (search == null)
            {
               search = new ACLSearch(null, acl.getPermissionEntries());
            }
            else
            {
               search.setPermissions(acl.getPermissionEntries());
               if (search.found())
               {
                  return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
                     node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
                     node.getParentIdentifier(), new AccessControlList(null, acl.getPermissionEntries()));
               }
            }
            // use nearest ancestor owner
            AccessControlList ancestorAcl =
               parent != null && parent.getACL() != null && parent.getACL().hasOwner() ? parent.getACL()
                  : getNearestACAncestorAcl(node, search);

            node =
               new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
                  .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
                  new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));

         }
      }
View Full Code Here

         QPath siblingPath =
            QPath.makeChildPath(nextSibling.getQPath().makeParentPath(), nextSibling.getQPath().getName(), nextSibling
               .getQPath().getIndex() - 1);

         NodeData reindexed =
            new TransientNodeData(siblingPath, nextSibling.getIdentifier(), nextSibling.getPersistedVersion(),
               nextSibling.getPrimaryTypeName(), nextSibling.getMixinTypeNames(), nextSibling.getOrderNumber(),
               nextSibling.getParentIdentifier(), nextSibling.getACL());

         reindexedId = reindexed.getIdentifier();

         ItemState reindexedState = ItemState.createUpdatedState(reindexed);
         changes.add(reindexedState);

         itemsPool.reload(reindexed);
View Full Code Here

            // update with new index
            QPath siblingPath =
               QPath.makeChildPath(newData.getQPath().makeParentPath(), newData.getQPath().getName(), sameNameIndex);

            newData =
               new TransientNodeData(siblingPath, newData.getIdentifier(), newData.getPersistedVersion(), newData
                  .getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(), newData
                  .getACL());
         }
         else
         {
            newData =
               new TransientNodeData(newData.getQPath(), newData.getIdentifier(), newData.getPersistedVersion(),
                  newData.getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(), newData
                     .getACL());
         }

         /*
 
View Full Code Here

      AccessControlList acl = parentNode.getACL();

      // create new nodedata, [PN] fix of use index as persisted version
      NodeData nodeData =
         new TransientNodeData(path, identifier, -1, primaryTypeName, mixinTypeNames, orderNum, parentNode
            .getInternalIdentifier(), acl);

      // Create new Node
      ItemState state = ItemState.createAddedState(nodeData, false);
      NodeImpl node = (NodeImpl)dataManager.update(state, true);
View Full Code Here

   private void setACL(AccessControlList acl)
   {
      NodeData nodeData = (NodeData)data;
      data =
         new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
            .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
            .getParentIdentifier(), acl);
   }
View Full Code Here

      newMixin.toArray(mixins);

      NodeData nodeData = (NodeData)data;

      data =
         new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
            .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());

      //      ((TransientNodeData)data).setMixinTypeNames(mixins);

      dataManager.update(new ItemState(data, ItemState.MIXIN_CHANGED, false, null), false);
View Full Code Here

            + userSession.getLocationFactory().createJCRPath(frozenPrimaryType.getQPath()).getAsString(false), e);
      }

      // create restored version of the node
      NodeData restoredData =
         new TransientNodeData(nodePath, fidentifier, (existing != null ? existing.getPersistedVersion() : -1), ptName,
            mixins == null ? new InternalQName[0] : mixins, 0, parentData.getIdentifier(), acl);

      if (updatingPath.contains(nodePath))
      {
         changes.add(ItemState.createUpdatedState(restoredData));
View Full Code Here

               acl = new AccessControlList(owner, permissionEntries);
            }

            NodeData restoredData =
               new TransientNodeData(restoredPath, jcrUuid, frozen.getPersistedVersion(), frozen.getPrimaryTypeName(),
                  frozen.getMixinTypeNames(), frozen.getOrderNumber(), currentNode().getIdentifier(), acl);

            if (updatingPath.contains(restoredPath))
            {
               changes.add(ItemState.createUpdatedState(restoredData));
View Full Code Here

   }

   public NodeData initNodetypesRoot(NodeData nsSystem, boolean addACL) throws RepositoryException
   {
      PlainChangesLog changesLog = new PlainChangesLogImpl();
      TransientNodeData jcrNodetypes;

      long start = System.currentTimeMillis();

      if (addACL)
      {
         InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};

         jcrNodetypes =
            TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
               Constants.NODETYPESROOT_UUID);

         AccessControlList acl = jcrNodetypes.getACL();

         TransientPropertyData primaryType =
            TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
               new TransientValueData(jcrNodetypes.getPrimaryTypeName()));

         changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));

         // jcr:mixinTypes
         List<ValueData> mixValues = new ArrayList<ValueData>();
         for (InternalQName mixin : mixins)
         {
            mixValues.add(new TransientValueData(mixin));
         }
         TransientPropertyData exoMixinTypes =
            TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_MIXINTYPES, PropertyType.NAME, true,
               mixValues);

         TransientPropertyData exoOwner =
            TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_OWNER, PropertyType.STRING, false,
               new TransientValueData(acl.getOwner()));

         List<ValueData> permsValues = new ArrayList<ValueData>();
         for (int i = 0; i < acl.getPermissionEntries().size(); i++)
         {
            AccessControlEntry entry = acl.getPermissionEntries().get(i);
            permsValues.add(new TransientValueData(entry));
         }
         TransientPropertyData exoPerms =
            TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_PERMISSIONS,
               ExtendedPropertyType.PERMISSION, true, permsValues);

         changesLog.add(ItemState.createAddedState(exoMixinTypes)).add(ItemState.createAddedState(exoOwner)).add(
            ItemState.createAddedState(exoPerms));
         changesLog.add(new ItemState(jcrNodetypes, ItemState.MIXIN_CHANGED, false, null));
      }
      else
      {
         jcrNodetypes =
            TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED,
               Constants.NODETYPESROOT_UUID);

         TransientPropertyData primaryType =
            TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
               new TransientValueData(jcrNodetypes.getPrimaryTypeName()));

         changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
      }

      if (log.isDebugEnabled())
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.dataflow.TransientNodeData

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.