Package org.exoplatform.services.jcr.dataflow

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


      permProp =
         new TransientPropertyData(permProp.getQPath(), permProp.getIdentifier(), permProp.getPersistedVersion(),
            permProp.getType(), permProp.getParentIdentifier(), permProp.isMultiValued(), permValues);

      dataManager.update(new ItemState(data, ItemState.MIXIN_CHANGED, false, null, true), false);
      dataManager.update(ItemState.createUpdatedState(permProp, true), false);

   }
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.getQPath().getAsString());
           
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.getQPath().getAsString(), new NodePropertiesInfo(newNodeData))

         tree.push(newNodeData);
View Full Code Here

   public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
   {
      ItemData data = null;
      if (txStarted())
      {
         ItemState state = transactionLog.getItemState(parentData, name, itemType);
         if (state != null)
         {
            data = state.getData();
         }
      }
      if (data != null)
      {
         return data;
View Full Code Here

   public ItemData getItemData(String identifier) throws RepositoryException
   {
      ItemData data = null;
      if (txStarted())
      {
         ItemState state = transactionLog.getItemState(identifier);
         if (state != null)
         {
            data = state.getData();
         }
      }
      if (data != null)
      {
         return data;
View Full Code Here

      {
         List<ItemState> states = new ArrayList<ItemState>(changesLog.getSize());
         PlainChangesLog changes = logIterator.nextLog();
         for (ItemState change : changes.getAllStates())
         {
            states.add(new ItemState(copyItemData(change.getData()), change.getState(), change.isEventFire(), change
               .getAncestorToSave(), change.isInternallyCreated(), change.isPersisted()));
         }

         newLog.addLog(new PlainChangesLogImpl(states, changes.getSessionId(), changes.getEventType()));
      }
View Full Code Here

            new PlainChangesLogImpl(new ArrayList<ItemState>(), changesLog.getSessionId(), changesLog.getEventType(),
               changesLog.getPairId());

         for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
         {
            ItemState prevState = iter.next();
            ItemData newData;

            if (prevState.getData() instanceof PersistedItemData)
            {
               // use existing if persisted
               newData = prevState.getData();
            }
            else
            {
               // copy transient as persisted
               if (prevState.isNode())
               {
                  NodeData prevData = (NodeData)prevState.getData();
                  newData =
                     new PersistedNodeData(prevData.getIdentifier(), prevData.getQPath(), prevData
                        .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getOrderNumber(), prevData
                        .getPrimaryTypeName(), prevData.getMixinTypeNames(), prevData.getACL());
               }
               else
               {
                  PropertyData prevData = (PropertyData)prevState.getData();

                  if (prevData.getValues() != null) // null if it's DELETE state
                  {
                     List<ValueData> values = new ArrayList<ValueData>();
                     for (int i = 0; i < prevData.getValues().size(); i++)
                     {
                        ValueData vd = prevData.getValues().get(i);

                        if (vd instanceof TransientValueData)
                        {
                           TransientValueData tvd = (TransientValueData)vd;
                           ValueData pvd;

                           if (vd.isByteArray())
                           {
                              pvd = new ByteArrayPersistedValueData(i, vd.getAsByteArray());
                              values.add(pvd);
                           }
                           else
                           {
                              // TODO ask dest file from VS provider, can be null after
                              // TODO for JBC case, the storage connection will evict the replicated Value to read it from the DB
                              File destFile = null;

                              if (tvd.getSpoolFile() != null)
                              {
                                 // spooled to temp file
                                 pvd = new StreamPersistedValueData(i, tvd.getSpoolFile(), destFile);
                              }
                              else
                              {
                                 // with original stream
                                 pvd = new StreamPersistedValueData(i, tvd.getOriginalStream(), destFile);
                              }

                              values.add(pvd);
                           }

                           tvd.delegate(pvd);
                        }
                        else
                        {
                           values.add(vd);
                        }
                     }

                     newData =
                        new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
                           .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
                           .isMultiValued(), values);
                  }
                  else
                  {
                     newData =
                        new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
                           .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
                           .isMultiValued(), null);
                  }
               }
            }

            ItemState itemState =
               new ItemState(newData, prevState.getState(), prevState.isEventFire(), prevState.getAncestorToSave(),
                  prevState.isInternallyCreated(), prevState.isPersisted());

            newLog.add(itemState);

            // save state
            if (itemState.isPersisted())
            {
               long start = System.currentTimeMillis();

               ItemData data = itemState.getData();

               WorkspaceStorageConnection conn;
               if (isSystemDescendant(data.getQPath()))
               {
                  conn = getSystemConnection();
               }
               else
               {
                  conn = getThisConnection();
               }

               if (itemState.isAdded())
               {
                  doAdd(data, conn, addedNodes);
               }
               else if (itemState.isUpdated())
               {
                  doUpdate(data, conn);
               }
               else if (itemState.isDeleted())
               {
                  doDelete(data, conn);
               }
               else if (itemState.isRenamed())
               {
                  doRename(data, conn, addedNodes);
               }

               if (LOG.isDebugEnabled())
               {
                  LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " + (System.currentTimeMillis() - start)
                     + "ms, " + data.getQPath().getAsString());
               }
            }
         }
         return newLog;
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

            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,
View Full Code Here

         // add or update      
         TransientPropertyData newData =
            new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
               multiValue, valueDataList);

         ItemState itemState = new ItemState(newData, state, true, qpath, false);
         prop = (PropertyImpl)dataManager.update(itemState, true);

         // launch event: post-set
         session.getActionHandler().postSetProperty(prevProperty, prop, state);
      }
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.