Examples of ItemState


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

    *
    * @param identifier
    */
   public void eraseEventFire(String identifier)
   {
      ItemState item = getItemState(identifier);
      if (item != null)
      {
         item.eraseEventFire();
         Map<String, ItemState> children = lastChildPropertyStates.get(identifier);
         if (children != null)
         {
            // Call the method ItemState.eraseEventFire() on each properties
            for (ItemState child : children.values())
View Full Code Here

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

   public List<ItemState> getDescendantsChanges(QPath rootPath)
   {
      List<ItemState> list = new ArrayList<ItemState>();
      for (int i = 0, length = items.size(); i < length; i++)
      {
         ItemState item = items.get(i);
         if (item.isDescendantOf(rootPath))
         {
            list.add(item);
         }
      }
      return list;
View Full Code Here

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

   {
      List<ItemState> states = new ArrayList<ItemState>();
      List<ItemState> currentStates = getAllStates();
      for (int i = 0, length = currentStates.size(); i < length; i++)
      {
         ItemState state = currentStates.get(i);
         if (state.getData().getIdentifier().equals(itemIdentifier))
         {
            states.add(state);
         }
      }
      return states;
View Full Code Here

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

      {
         return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, itemType));
      }
      else
      {
         ItemState state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.NODE));
         if (state == null)
         {
            state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.PROPERTY));
         }
         return state;
View Full Code Here

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

      List<ItemState> allStates = getAllStates();
      // search from the end for DELETED state.
      // RENAMED comes after the DELETED in the log immediately (in back order)
      for (int i = allStates.size() - 1; i >= 0; i--)
      {
         ItemState state = allStates.get(i);
         if (state.getState() == ItemState.DELETED
            && !state.isPersisted()
            && (deletedPath.isDescendantOf(state.getData().getQPath()) || deletedPath
               .equals(state.getData().getQPath())))
         {
            // 1. if it's an item or ancestor of logged data
            try
            {
               ItemState delete = state;
               ItemState rename = allStates.get(i + 1);

               if (rename.getState() == ItemState.RENAMED && rename.isPersisted()
                  && rename.getData().getIdentifier().equals(delete.getData().getIdentifier()))
               {

                  // 2. search of most fresh state for searched rename state
                  for (int bi = allStates.size() - 1; bi >= i + 2; bi--)
                  {
                     state = allStates.get(bi);
                     if (state.getState() == ItemState.RENAMED && state.isPersisted()
                        && state.getData().getIdentifier().equals(rename.getData().getIdentifier()))
                     {
                        // got much fresh
                        rename = state;
                        delete = allStates.get(i - 1); // try the fresh delete state
                        if (delete.getData().getIdentifier().equals(rename.getData().getIdentifier()))
                           return new ItemState[]{delete, rename}; // 3. ok, got it
                     }
                  }

                  return new ItemState[]{delete, rename}; // 4. ok, there are no
View Full Code Here

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

            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

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

   {
      List<ItemState> allStates = getAllStates();
      // search from the end for state
      for (int i = allStates.size() - 1; i >= 0; i--)
      {
         ItemState istate = allStates.get(i);
         boolean byState = false;
         if (states != null)
         {
            for (int state : states)
            {
               if (istate.getState() == state)
               {
                  byState = true;
                  break;
               }
            }
         }
         else
            byState = true;
         if (byState
            && (isPersisted != null ? istate.isPersisted() == isPersisted : true)
            && ((orAncestor != null && orAncestor ? rootPath.isDescendantOf(istate.getData().getQPath()) : true) || rootPath
               .equals(istate.getData().getQPath())))
         {
            return istate;
         }
      }
      return null;
View Full Code Here

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

   {
      List<ItemState> allStates = getAllStates();
      // search from the end for state
      for (int i = allStates.size() - 1; i >= 0; i--)
      {
         ItemState istate = allStates.get(i);
         boolean byState = false;
         if (states != null)
         {
            for (int state : states)
            {
               if (istate.getState() == state)
               {
                  byState = true;
                  break;
               }
            }
         }
         else
            byState = true;
         if (byState && (isPersisted != null ? istate.isPersisted() == isPersisted : true)
            && istate.getData().getIdentifier().equals(id))
         {
            return istate;
         }
      }
      return null;
View Full Code Here

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

      values.add(new TransientValueData(type.getName()));

      PropertyData prop =
         (PropertyData)dataManager.getItemData(((NodeData)getData()), new QPathEntry(Constants.JCR_MIXINTYPES, 0),
            ItemType.PROPERTY);
      ItemState state;

      if (prop != null)
      {// there was mixin prop
         prop =
            new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(),
View Full Code Here

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

         }
      }

      if (newMixin.size() > 0)
      {
         dataManager.update(new ItemState(prop, ItemState.UPDATED, true, ancestorToSave), false);
      }
      else
      {
         dataManager.delete(prop, ancestorToSave);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.