[exo-jcr-commits] exo-jcr SVN: r986 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/version and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Dec 10 09:30:52 EST 2009


Author: pnedonosko
Date: 2009-12-10 09:30:52 -0500 (Thu, 10 Dec 2009)
New Revision: 986

Modified:
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
   jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
Log:
EXOJCR-274 save don't copy persistent items; VersionHistoryImpl cleanup.


Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2009-12-10 14:13:56 UTC (rev 985)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java	2009-12-10 14:30:52 UTC (rev 986)
@@ -1041,6 +1041,7 @@
       NodeData nextSibling =
          (NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause.getQPath()
             .getIndex() + 1));
+
       String reindexedId = null;
       // repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
       // reindexed

Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java	2009-12-10 14:13:56 UTC (rev 985)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java	2009-12-10 14:30:52 UTC (rev 986)
@@ -75,7 +75,9 @@
       super(data, session);
 
       if (!this.isNodeType(Constants.NT_VERSIONHISTORY))
+      {
          throw new RepositoryException("Node " + getLocation().getAsString(true) + " is not nt:versionHistory type");
+      }
    }
 
    /**
@@ -147,7 +149,6 @@
     */
    public VersionIterator getAllVersions() throws RepositoryException
    {
-
       checkValid();
 
       List<NodeData> versionsDataList = getData().getAllVersionsData();
@@ -168,7 +169,6 @@
     */
    public Version getVersion(String versionName) throws VersionException, RepositoryException
    {
-
       checkValid();
 
       return version(versionName, true);
@@ -196,7 +196,6 @@
     */
    public Version getVersionByLabel(String label) throws RepositoryException
    {
-
       checkValid();
 
       NodeData versionData = getVersionDataByLabel(label);
@@ -218,7 +217,6 @@
     */
    public boolean hasVersionLabel(String label) throws RepositoryException
    {
-
       checkValid();
 
       if (this.getVersionDataByLabel(label) == null)
@@ -232,7 +230,6 @@
     */
    public boolean hasVersionLabel(Version version, String label) throws VersionException, RepositoryException
    {
-
       checkValid();
 
       NodeData versionData = getVersionDataByLabel(label);
@@ -247,7 +244,6 @@
     */
    public String[] getVersionLabels() throws RepositoryException
    {
-
       checkValid();
 
       List<PropertyData> versionLabels = getData().getVersionLabels();
@@ -263,8 +259,10 @@
    protected List<String> getVersionLabelsList(Version version) throws VersionException, RepositoryException
    {
       if (!isVersionBelongToThis(version))
+      {
          throw new VersionException("There are no version '" + version.getPath() + "' in the version history "
             + getPath());
+      }
 
       List<PropertyData> labelsList = getData().getVersionLabels();
       List<String> vlabels = new ArrayList<String>();
@@ -293,7 +291,6 @@
     */
    public String[] getVersionLabels(Version version) throws VersionException, RepositoryException
    {
-
       checkValid();
 
       List<String> vlabels = getVersionLabelsList(version);
@@ -310,7 +307,6 @@
    public void removeVersion(String versionName) throws ReferentialIntegrityException, AccessDeniedException,
       UnsupportedRepositoryOperationException, VersionException, RepositoryException
    {
-
       // get version (pool it to be able to invalidate the version on final)
       VersionImpl version = (VersionImpl)version(versionName, true);
 
@@ -444,14 +440,15 @@
    {
       NodeData labels = getData().getVersionLabelsData();
       if (labels == null)
+      {
          throw new VersionException("Mandatory node jcr:versionLabels is not found for version history " + getPath());
+      }
 
       return labels;
    }
 
    protected NodeData getVersionDataByLabel(String labelName) throws VersionException, RepositoryException
    {
-
       JCRName jcrLabelName = locationFactory.parseJCRName(labelName);
       InternalQName labelQName = jcrLabelName.getInternalName();
 
@@ -460,10 +457,11 @@
 
    protected NodeData getVersionDataByIdentifier(String versionIdentifier) throws VersionException, RepositoryException
    {
-
       NodeData version = (NodeData)dataManager.getItemData(versionIdentifier);
       if (version == null)
+      {
          throw new VersionException("Version is not found, uuid: " + versionIdentifier);
+      }
 
       return version;
    }
@@ -474,7 +472,6 @@
    public void addVersionLabel(String versionName, String label, boolean moveLabel) throws VersionException,
       RepositoryException
    {
-
       checkValid();
 
       JCRName jcrLabelName = locationFactory.parseJCRName(label);
@@ -514,7 +511,6 @@
     */
    public void removeVersionLabel(String labelName) throws VersionException, RepositoryException
    {
-
       checkValid();
 
       JCRName jcrLabelName = locationFactory.parseJCRName(labelName);
@@ -539,7 +535,6 @@
    public void addVersion(NodeData versionableNodeData, String uuid, SessionChangesLog changesLog)
       throws RepositoryException
    {
-
       // nt:version
       NodeData versionData =
          TransientNodeData.createNodeData(nodeData(), new InternalQName(null, nextVersionName()), Constants.NT_VERSION,
@@ -616,15 +611,15 @@
             new TransientValueData(frozenData.getIdentifier()));
       changesLog.add(ItemState.createAddedState(propData));
 
-      // NodeTypeManagerImpl ntManager =
-      // session.getWorkspace().getNodeTypesHolder();
       FrozenNodeInitializer visitor =
          new FrozenNodeInitializer(frozenData, session.getTransientNodesManager(), session.getWorkspace()
             .getNodeTypesHolder(), changesLog, session.getValueFactory());
 
       if (LOG.isDebugEnabled())
+      {
          LOG.debug("Before frozen visitor: " + changesLog.dump());
-
+      }
+      
       versionableNodeData.accept(visitor);
 
    }

Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java	2009-12-10 14:13:56 UTC (rev 985)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java	2009-12-10 14:30:52 UTC (rev 986)
@@ -29,6 +29,7 @@
 import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
 import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListenerFilter;
 import org.exoplatform.services.jcr.dataflow.persistent.MandatoryItemsPersistenceListener;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedItemData;
 import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
 import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
 import org.exoplatform.services.jcr.datamodel.ItemData;
@@ -214,7 +215,9 @@
 
       // check if this workspace container is not read-only
       if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
+      {
          throw new ReadOnlyWorkspaceException("Workspace container '" + dataContainer.getName() + "' is read-only.");
+      }
 
       ChangesLogPersister persister = new ChangesLogPersister();
 
@@ -402,73 +405,75 @@
          for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
          {
             ItemState prevState = iter.next();
+            ItemData newData;
 
-            ItemData newData;
-            if (prevState.isNode())
+            if (prevState.getData() instanceof PersistedItemData)
             {
-               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());
+               // use existing if persisted 
+               newData = prevState.getData();
             }
             else
             {
-               PropertyData prevData = (PropertyData)prevState.getData();
+               // 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();
 
-               newData =
-                  new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
-                     .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
-                     .isMultiValued(), prevData.getValues());
+                  //               newData =
+                  //                  new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
+                  //                     .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
+                  //                     .isMultiValued(), prevData.getValues());
 
-               //               if (prevData.getValues() != null)
-               //               {
-               //                  List<ValueData> values = new ArrayList<ValueData>();
-               //                  for (ValueData vd : prevData.getValues())
-               //                  {
-               //                     if (vd.isByteArray())
-               //                     {
-               //                        values.add(new ByteArrayPersistedValueData(vd.getAsByteArray(), vd.getOrderNumber()));
-               //                     }
-               //                     else
-               //                     {
-               //                        // TODO ask dest file from VS provider, can be null after
-               //                        // TODO what if JDBC spool used, i.e. without VS = storage will setPersistedFile()
-               //                        // TODO for JBC case, the storage connection will evict the replicated Value to read it from the DB
-               //                        File destFile = null;
-               //
-               //                        if (vd instanceof TransientValueData)
-               //                        {
-               //                           TransientValueData tvd = (TransientValueData)vd;
-               //                           // TODO review TransientValueData logic about spool file and stream
-               //                           values.add(new StreamPersistedValueData(destFile, tvd.getSpoolFile(),
-               //                              tvd.getSpoolFile() == null ? tvd.getAsStream(false) : null, vd.getOrderNumber()));
-               //                        }
-               //                        else if (vd instanceof PersistedValueData)
-               //                        {
-               //                           values.add(((PersistedValueData)vd).createTransientCopy());
-               //                        }
-               //                        else
-               //                        {
-               //                           throw new RepositoryException(
-               //                              "Unexpected ValueData implementaion on persistent level, only TransientValueData or PersistedValueData allowed. "
-               //                                 + vd.getClass());
-               //                        }
-               //                     }
-               //                  }
-               //
-               //                  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);
-               //               }
+                  if (prevData.getValues() != null)
+                  {
+                     List<ValueData> values = new ArrayList<ValueData>();
+                     for (ValueData vd : prevData.getValues())
+                     {
+                        if (vd.isByteArray())
+                        {
+                           values.add(new ByteArrayPersistedValueData(vd.getAsByteArray(), vd.getOrderNumber()));
+                        }
+                        else
+                        {
+                           // TODO ask dest file from VS provider, can be null after
+                           // TODO what if JDBC spool used, i.e. without VS = storage will setPersistedFile()
+                           // TODO for JBC case, the storage connection will evict the replicated Value to read it from the DB
+                           File destFile = null;
+
+                           TransientValueData tvd = (TransientValueData)vd;
+                           // TODO review TransientValueData logic about spool file and stream
+                           values.add(new StreamPersistedValueData(destFile, tvd.getSpoolFile(),
+                              tvd.getSpoolFile() == null ? tvd.getAsStream(false) : null, vd.getOrderNumber()));
+
+                           //                        {
+                           //                           throw new RepositoryException(
+                           //                              "Unexpected stream based ValueData implementaion on persistent level, only TransientValueData or PersistedValueData allowed. "
+                           //                                 + vd.getClass());
+                           //                        }
+                        }
+                     }
+
+                     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 =



More information about the exo-jcr-commits mailing list