Package org.exoplatform.services.jcr.dataflow

Examples of org.exoplatform.services.jcr.dataflow.ItemState


               nextSibling.getPrimaryTypeName(), nextSibling.getMixinTypeNames(), nextSibling.getOrderNumber(),
               nextSibling.getParentIdentifier(), nextSibling.getACL());

         reindexedId = reindexed.getIdentifier();

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

         // reload pooled implies... it's actual for session and workspace scope
         // operations
         // TODO this operation must respect all sub-tree of reindexed node
View Full Code Here


      for (Iterator<ItemImpl> removedIter = invalidated.iterator(); removedIter.hasNext();)
      {
         ItemImpl removed = removedIter.next();

         QPath removedPath = removed.getLocation().getInternalPath();
         ItemState rstate = changes.getItemState(removedPath);

         if (rstate == null)
         {
            exceptions +=
               "Can't find removed item " + removed.getLocation().getAsString(false) + " in changes for rollback.\n";
            continue;
         }

         if (rstate.getState() == ItemState.RENAMED)
         {
            // find DELETED
            rstate = changes.findItemState(rstate.getData().getIdentifier(), false, new int[]{ItemState.DELETED});
            if (rstate == null)
            {
               exceptions +=
                  "Can't find removed item (of move operation) " + removed.getLocation().getAsString(false)
                     + " in changes for rollback.\n";
               continue;
            }
         }

         NodeData parent = (NodeData)transactionableManager.getItemData(rstate.getData().getParentIdentifier());
         if (parent != null)
         {
            ItemData persisted =
               transactionableManager.getItemData(parent, rstate.getData().getQPath().getEntries()[rstate.getData()
                  .getQPath().getEntries().length - 1], ItemType.getItemType(rstate.getData()));

            if (persisted != null)
            {
               // reload item data
               removed.loadData(persisted);
View Full Code Here

   {

      if (!enabled)
         return;

      ItemState prevState = null;
      for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
      {
         ItemState state = iter.next();
         ItemData item = state.getData();
         if (LOG.isDebugEnabled())
            LOG.debug(name + ", onSaveItems() " + ItemState.nameFromValue(state.getState()) + " "
               + item.getQPath().getAsString() + " " + item.getIdentifier() + " parent:" + item.getParentIdentifier());

         try
         {
            if (state.isAdded())
            {
               put(item);
            }
            else if (state.isDeleted())
            {
               remove(item);
            }
            else if (state.isRenamed())
            {
               // MOVE operation (DESTENATION changes, same as ADDED), states for whole subtree!
               // RENAME goes before DELETE
               put(item);
            }
            else if (state.isUpdated())
            {
               // UPDATE occurs on reordered (no subtree!) and merged nodes (for each
               // merged-updated)
               if (item.isNode())
               {
                  if (prevState != null)
                  {
                     // play only for reorder, UPDATE goes after DELETE of same path
                     // item
                     // we have to unload node and its parent child nodes to be loaded
                     // back from the persistence
                     if (prevState.isDeleted()
                        && prevState.getData().getParentIdentifier().equals(item.getParentIdentifier()))
                        removeSiblings((NodeData)item);
                  }
               }
               else if (item.getQPath().getName().equals(Constants.EXO_PERMISSIONS))
               {
                  // TODO EXOJCR-12 place to put workaround for JCR cache exo:permissions updated
                  // get parent Node

                  // check if parent is mix:privilegeable
                  ItemData parent = get(item.getParentIdentifier());
                  // delete parent
                  remove(parent);

                  writeLock.lock();
                  try
                  {
                     // delete parent containing child nodes list
                     nodesCache.remove(parent.getParentIdentifier());

                     // traverse itemCache
                     Iterator<CacheValue> cacheIterator = cache.values().iterator();
                     while (cacheIterator.hasNext())
                     {
                        ItemData cachedItem = cacheIterator.next().getItem();
                        if (cachedItem.isNode())
                        {
                           if (cachedItem.getQPath().isDescendantOf(parent.getQPath()))
                           {
                              cacheIterator.remove();
                           }
                        }
                     }

                     // traverse child node Cache
                     Iterator<List<NodeData>> childNodesIterator = nodesCache.values().iterator();
                     while (childNodesIterator.hasNext())
                     {
                        List<NodeData> list = childNodesIterator.next();
                        if (list != null && list.size() > 0)
                        {
                           if (list.get(0).getQPath().isDescendantOf(parent.getQPath()))
                           {
                              childNodesIterator.remove();
                           }
                        }
                     }
                  }
                  finally
                  {
                     writeLock.unlock();
                  }
               }
               put(item);
            }
            else if (state.isMixinChanged())
            {
               // MIXIN_CHANGED, on Node
               put(item);
            }
         }
View Full Code Here

         // sv:property element

         ImportPropertyData propertyData = endProperty();
         if (propertyData != null)
         {
            changesLog.add(new ItemState(propertyData, ItemState.ADDED, true, getAncestorToSave()));

            ImportNodeData currentNodeInfo = (ImportNodeData)getParent();

            NodePropertiesInfo currentNodePropertiesInfo = mapNodePropertiesInfo.get(currentNodeInfo.getIdentifier());
View Full Code Here

         // preset of ACL
         newNodeData.setACL(parentData.getACL());
         newNodeData.setOrderNumber(getNextChildOrderNum(parentData));
         newNodeData.setIdentifier(IdGenerator.generate());

         changesLog.add(new ItemState(newNodeData, ItemState.ADDED, true, getAncestorToSave()));

         mapNodePropertiesInfo.put(newNodeData.getIdentifier(), new NodePropertiesInfo(newNodeData));

         tree.push(newNodeData);
View Full Code Here

            currentNodeInfo.setVersionHistoryIdentifier(versionHistoryIdentifier);

            // check if node contains VH
            if (dataConsumer.getItemData(versionHistoryIdentifier) != null)
            {
               ItemState vhLastState = getLastItemState(versionHistoryIdentifier);
               currentNodeInfo.setContainsVersionhistory(vhLastState == null || !vhLastState.isDeleted());
            }
            else
            {
               currentNodeInfo.setContainsVersionhistory(false);
            }
View Full Code Here

      if (isNeedReloadAncestorToSave)
      {
         PlainChangesLogImpl newChangesLog = new PlainChangesLogImpl();
         for (ItemState itemState : changesLog.getAllStates())
         {
            newChangesLog.add(new ItemState(itemState.getData(), itemState.getState(), itemState.isEventFire(),
               ancestorToSave, itemState.isInternallyCreated(), itemState.isPersisted(), itemState.getOldPath()));
         }
         changesLog.clear();
         changesLog.addAll(newChangesLog.getAllStates());
         isNeedReloadAncestorToSave = false;
View Full Code Here

      if (identifier != null)
      {
         try
         {
            NodeData sameUuidItem = (NodeData)dataConsumer.getItemData(identifier);
            ItemState lastState = getLastItemState(identifier);

            if (sameUuidItem != null && (lastState == null || !lastState.isDeleted()))
            {
               boolean isMixVersionable =
                  nodeTypeDataManager.isNodeType(Constants.MIX_VERSIONABLE, sameUuidItem.getMixinTypeNames());

               switch (uuidBehavior)
View Full Code Here

   protected ItemState getLastItemState(String identifer)
   {
      List<ItemState> allStates = changesLog.getAllStates();
      for (int i = allStates.size() - 1; i >= 0; i--)
      {
         ItemState state = allStates.get(i);
         if (state.getData().getIdentifier().equals(identifer))
            return state;
      }
      return null;
   }
View Full Code Here

      {
         TransientNodeData nodeData =
            TransientNodeData.createNodeData(getParent(), Constants.JCR_XMLTEXT, Constants.NT_UNSTRUCTURED,
               getNodeIndex(getParent(), Constants.JCR_XMLTEXT, null), getNextChildOrderNum(getParent()));

         changesLog.add(new ItemState(nodeData, ItemState.ADDED, true, getAncestorToSave()));
         if (log.isDebugEnabled())
         {
            log.debug("New node " + nodeData.getQPath().getAsString());
         }

         ImportPropertyData newProperty =
            new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), Constants.JCR_PRIMARYTYPE),
               IdGenerator.generate(), -1, PropertyType.NAME, nodeData.getIdentifier(), false);

         newProperty.setValue(new TransientValueData(Constants.NT_UNSTRUCTURED));
         changesLog.add(new ItemState(newProperty, ItemState.ADDED, true, getAncestorToSave()));
         newProperty =
            new ImportPropertyData(QPath.makeChildPath(nodeData.getQPath(), Constants.JCR_XMLCHARACTERS),
               IdGenerator.generate(), -1, PropertyType.STRING, nodeData.getIdentifier(), false);
         newProperty.setValue(new TransientValueData(text.toString()));

         changesLog.add(new ItemState(newProperty, ItemState.ADDED, true, getAncestorToSave()));
         xmlCharactersProperty = newProperty;
         xmlCharactersPropertyValue = text.toString();
      }

   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.dataflow.ItemState

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.