Examples of PlainChangesLogImpl


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

      }

      Lock newLock = session.getLockManager().addLock(this, isDeep, isSessionScoped, -1);

      PlainChangesLog changesLog =
         new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(), ExtendedEvent.LOCK);

      PropertyData propData =
         TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKOWNER, PropertyType.STRING, false,
            new TransientValueData(session.getUserID()));
      changesLog.add(ItemState.createAddedState(propData));

      propData =
         TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKISDEEP, PropertyType.BOOLEAN, false,
            new TransientValueData(isDeep));
      changesLog.add(ItemState.createAddedState(propData));

      dataManager.getTransactManager().save(changesLog);

      session.getActionHandler().postLock(this);
      return newLock;
View Full Code Here

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

      }

      Lock newLock = session.getLockManager().addLock(this, isDeep, false, timeOut);

      PlainChangesLog changesLog =
         new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(), ExtendedEvent.LOCK);

      PropertyData propData =
         TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKOWNER, PropertyType.STRING, false,
            new TransientValueData(session.getUserID()));
      changesLog.add(ItemState.createAddedState(propData));

      propData =
         TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKISDEEP, PropertyType.BOOLEAN, false,
            new TransientValueData(isDeep));
      changesLog.add(ItemState.createAddedState(propData));

      dataManager.getTransactManager().save(changesLog);

      session.getActionHandler().postLock(this);
      return newLock;
View Full Code Here

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

    */
   protected void doUnlock() throws RepositoryException
   {

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

      ItemData lockOwner =
         dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKOWNER, 0), ItemType.PROPERTY);

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

      ItemData lockIsDeep =
         dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKISDEEP, 0), ItemType.PROPERTY);

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

      dataManager.getTransactManager().save(changesLog);
   }
View Full Code Here

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

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

      storageDataManager.save(newLog);
   }
View Full Code Here

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

            if (nvstates.size() > 0)
            {
               // we have pair of logs for system and non-system (this) workspaces
               final String pairId = IdGenerator.generate();

               versionLogs.addLog(new PlainChangesLogImpl(vstates, changes.getSessionId(), changes.getEventType(),
                  pairId));
               nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates, changes.getSessionId(), changes.getEventType(),
                  pairId));
            }
            else
            {
               versionLogs.addLog(new PlainChangesLogImpl(vstates, changes.getSessionId(), changes.getEventType()));
            }
         }
         else if (nvstates.size() > 0)
         {
            nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates, changes.getSessionId(), changes.getEventType()));
         }
      }

      if (versionLogs.getSize() > 0)
      {
View Full Code Here

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

      protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws InvalidItemStateException,
         RepositoryException, IOException
      {
         // copy state
         PlainChangesLogImpl newLog =
            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();
View Full Code Here

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

      {
         throw new ReferentialIntegrityException("There are Reference property pointed to this Version "
            + refs.get(0).getQPath().getAsString());
      }

      PlainChangesLog changes = new PlainChangesLogImpl(session.getId());

      // remove labels first
      try
      {
         for (PropertyData vlabel : getData().getVersionLabels())
         {
            String versionUuid = new String(vlabel.getValues().get(0).getAsByteArray());
            if (versionUuid.equals(version.getInternalIdentifier()))
            {
               changes.add(ItemState.createDeletedState(vlabel));
            }
         }
      }
      catch (IOException e)
      {
         throw new RepositoryException("Get version " + version.getPath() + " labels error " + e, e);
      }

      // remove this version from successor anf predecessor list
      // and point successor to predecessor directly

      PropertyData successorsData =
         (PropertyData)dataManager.getItemData((NodeData)version.getData(),
            new QPathEntry(Constants.JCR_SUCCESSORS, 0), ItemType.PROPERTY);

      // jcr:predecessors
      PropertyData predecessorsData =
         (PropertyData)dataManager.getItemData((NodeData)version.getData(), new QPathEntry(Constants.JCR_PREDECESSORS,
            0), ItemType.PROPERTY);

      try
      {
         for (ValueData pvalue : predecessorsData.getValues())
         {
            String pidentifier = new String(pvalue.getAsByteArray());
            VersionImpl predecessor = (VersionImpl)dataManager.getItemByIdentifier(pidentifier, false);
            // actually predecessor is V2's successor
            if (predecessor != null)
            {// V2's successor
               if (successorsData != null)
               {// to redirect V2's successor
                  // case of VH graph merge
                  for (ValueData svalue : successorsData.getValues())
                  {
                     predecessor.removeAddSuccessor(version.getInternalIdentifier(),
                        new String(svalue.getAsByteArray()), changes);
                  }
               }
               else
               {
                  // case of VH last version remove
                  predecessor.removeSuccessor(version.getInternalIdentifier(), changes);
               }
            }
            else
            {
               throw new RepositoryException("A predecessor (" + pidentifier + ") of the version " + version.getPath()
                  + " is not found.");
            }
         }
      }
      catch (IOException e)
      {
         throw new RepositoryException("Get predecessor " + version.getPath() + " error " + e, e);
      }

      try
      {
         if (successorsData != null)
         {
            for (ValueData svalue : successorsData.getValues())
            {
               String sidentifier = new String(svalue.getAsByteArray());
               VersionImpl successor = (VersionImpl)dataManager.getItemByIdentifier(sidentifier, false);
               if (successor != null)
               {
                  // case of VH graph merge
                  for (ValueData pvalue : predecessorsData.getValues())
                  {
                     successor.removeAddPredecessor(version.getInternalIdentifier(),
                        new String(pvalue.getAsByteArray()), changes);
                  }
               }
               else
               {
                  throw new RepositoryException("A successor (" + sidentifier + ") of the version " + version.getPath()
                     + " is not found.");
               }
            }
         }
      }
      catch (IOException e)
      {
         throw new RepositoryException("Get successor " + version.getPath() + " error " + e, e);
      }

      ItemDataRemoveVisitor removeVisitor = new ItemDataRemoveVisitor(dataManager.getTransactManager(), null);
      version.getData().accept(removeVisitor);
      changes.addAll(removeVisitor.getRemovedStates());

      dataManager.getTransactManager().save(changes);

      version.invalidate();
   }
View Full Code Here

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

         (PropertyData)dataManager.getItemData(getData().getVersionLabelsData(), new QPathEntry(labelQName, 0),
            ItemType.PROPERTY);

      if (vldata != null)
      {
         PlainChangesLog changes = new PlainChangesLogImpl(session.getId());
         changes.add(ItemState.createDeletedState(vldata));
         dataManager.getTransactManager().save(changes);
      }
      else
      {
         throw new VersionException("Label not found " + labelName);
View Full Code Here

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

         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

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

      return nodeTypeData != null;
   }

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

      long start = System.currentTimeMillis();

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

         jcrNodetypes =
            TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
               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));

         // 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
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.