Package org.exoplatform.services.jcr.dataflow

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


         {
            return;
         }

         PlainChangesLog changesLog =
            new PlainChangesLogImpl(new ArrayList<ItemState>(), IdentityConstants.SYSTEM, ExtendedEvent.UNLOCK);

         ItemData lockOwner =
            copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1),
               ItemType.PROPERTY));

         //Skip removing, because that lock was removed in other node of cluster. 
         if (lockOwner == null)
         {
            return;
         }

         changesLog.add(ItemState.createDeletedState(lockOwner));

         ItemData lockIsDeep =
            copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1),
               ItemType.PROPERTY));

         //Skip removing, because that lock was removed in other node of cluster. 
         if (lockIsDeep == null)
         {
            return;
         }

         changesLog.add(ItemState.createDeletedState(lockIsDeep));

         // lock probably removed by other thread
         if (lockOwner == null && lockIsDeep == null)
         {
            return;
View Full Code Here


         log.warn("Unable save nodetype " + nodeType.getName().getAsString()
            + " in to the storage. Storage not initialized");
         return;
      }

      PlainChangesLog changesLog = new PlainChangesLogImpl();
      definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeType);
      dataManager.save(new TransactionChangesLog(changesLog));
   }
View Full Code Here

      return nodeTypeData != null;
   }

   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())
      {
         log.debug("/jcr:system/jcr:nodetypes is created, creation time: " + (System.currentTimeMillis() - start)
View Full Code Here

      if (!validatate())
      {
         return;
      }

      PlainChangesLog changesLog = new PlainChangesLogImpl();
      for (NodeTypeData nodeTypeData : nodeTypes)
      {
         definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
      }
View Full Code Here

      NodeData nodeTypeData =
         (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeType.getName(), 1), ItemType.NODE);
      ItemDataRemoveVisitor removeVisitor = new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
      nodeTypeData.accept(removeVisitor);

      PlainChangesLog changesLog = new PlainChangesLogImpl();
      changesLog.addAll(removeVisitor.getRemovedStates());
      dataManager.save(new TransactionChangesLog(changesLog));
   }
View Full Code Here

    * {@inheritDoc}
    */
   public void update(List<NodeTypeData> nodeTypes, UpdateNodeTypeObserver observer) throws RepositoryException
   {

      PlainChangesLog changesLog = new PlainChangesLogImpl();

      for (NodeTypeData nodeTypeData : nodeTypes)
      {

         if (observer != null)
         {
            if (observer.shouldSkip(nodeTypeData, changesLog))
            {
               continue;
            }
            observer.beforeUpdate(nodeTypeData, changesLog);
         }
         if (!validatate())
         {
            continue;
         }
         // remove first
         NodeData removeNodeTypeData =
            (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeData.getName(), 1),
               ItemType.NODE);
         if (removeNodeTypeData != null)
         {
            ItemDataRemoveVisitor removeVisitor =
               new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
            removeNodeTypeData.accept(removeVisitor);

            changesLog.addAll(removeVisitor.getRemovedStates());
         }
         // add
         definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
         if (observer != null)
         {
            observer.afterUpdate(nodeTypeData, changesLog);
         }
      }
      //made changes if needed
      if (changesLog.getSize() > 0)
      {
         dataManager.save(new TransactionChangesLog(changesLog));
      }
   }
View Full Code Here

      protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws InvalidItemStateException,
         RepositoryException, IOException
      {
         // copy state
         PlainChangesLogImpl newLog = PlainChangesLogImpl.createCopy(new ArrayList<ItemState>(), changesLog);

         Map<String, PropertyData> lastUpdateStates = new HashMap<String, PropertyData>();

         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>();

                     if (prevState.isRenamed() && lastUpdateStates.containsKey(prevState.getData().getIdentifier()))
                     {
                        values = lastUpdateStates.get(prevState.getData().getIdentifier()).getValues();
                     }
                     else
                     {
                        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
                              {
                                 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);

                     if (prevState.isAdded() || prevState.isUpdated())
                     {
                        lastUpdateStates.put(prevState.getData().getIdentifier(), (PropertyData)newData);
                     }
                  }
                  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(), prevState.getOldPath());

            newLog.add(itemState);

            // save state
            if (itemState.isPersisted())
            {
               long start = 0;
View Full Code Here

               else
                  // another state
                  normalized.add(change);
            }

            PlainChangesLog plog = new PlainChangesLogImpl(normalized, next.getSessionId(), next.getEventType());
            result.addLog(plog);
         }

         return result;
      }
View Full Code Here

      protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws InvalidItemStateException,
         RepositoryException, IOException
      {
         // copy state
         PlainChangesLogImpl newLog = PlainChangesLogImpl.createCopy(new ArrayList<ItemState>(), changesLog);

         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 (!prevState.isDeleted())
                  {
                     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;

                           PersistedValueData pvd = tvd.createPersistedCopy(i);
                           tvd.delegate((AbstractValueData)pvd);

                           values.add(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(), prevState.getOldPath());

            newLog.add(itemState);

            // save state
            if (itemState.isPersisted())
            {
               long start = 0;
View Full Code Here

               else
                  // another state
                  normalized.add(change);
            }

            PlainChangesLog plog = new PlainChangesLogImpl(normalized, next.getSessionId(), next.getEventType());
            result.addLog(plog);
         }

         return result;
      }
View Full Code Here

TOP

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

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.