jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r800483 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ version/
Date Mon, 03 Aug 2009 18:10:46 GMT
Author: jukka
Date: Mon Aug  3 18:10:46 2009
New Revision: 800483

URL: http://svn.apache.org/viewvc?rev=800483&view=rev
Log:
JCR-1972: Preserving UUID and document version history on repository migration

Add the new NodeImpl.checkin(Calendar) and VersionManagerImpl.checkin(String, Calendar)signatures
based on contribution by Paco Avila.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Mon Aug  3 18:10:46 2009
@@ -3305,6 +3305,17 @@
     }
 
     /**
+     * Use {@link VersionManagerImpl#checkin(String, Calendar)} instead
+     *
+     * @since Apache Jackrabbit 1.6
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-1972">JCR-1972</a>
+     */
+    @Deprecated
+    public Version checkin(Calendar created) throws RepositoryException {
+        return getVersionManagerImpl().checkin(getPath(), created);
+    }
+
+    /**
      * Use {@link VersionManager#checkout(String)} instead
      */
     @Deprecated

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/VersionManagerImpl.java
Mon Aug  3 18:10:46 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -84,10 +85,25 @@
      * {@inheritDoc}
      */
     public Version checkin(String absPath) throws RepositoryException {
+        return checkin(absPath, null);
+    }
+
+    /**
+     * Creates a new version of the node at the given path.
+     *
+     * @param absPath node path
+     * @param created create time of the new version,
+     *                or <code>null</code> for the current time
+     * @return new version
+     * @throws RepositoryException if the version can not be created
+     */
+    public Version checkin(String absPath, Calendar created)
+            throws RepositoryException {
         NodeStateEx state = getNodeState(absPath,
-                ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE,
+                ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD
+                | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE,
                 Permission.VERSION_MNGMT);
-        NodeId baseId = checkoutCheckin(state, true, false);
+        NodeId baseId = checkoutCheckin(state, true, false, created);
         return (VersionImpl) session.getNodeById(baseId);
     }
 
@@ -98,7 +114,7 @@
         NodeStateEx state = getNodeState(absPath,
                 ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD,
                 Permission.VERSION_MNGMT);
-        checkoutCheckin(state, false, true);
+        checkoutCheckin(state, false, true, null);
     }
 
     /**
@@ -108,7 +124,7 @@
         NodeStateEx state = getNodeState(absPath,
                 ItemValidator.CHECK_LOCK | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE,
                 Permission.VERSION_MNGMT);
-        NodeId baseId = checkoutCheckin(state, true, true);
+        NodeId baseId = checkoutCheckin(state, true, true, null);
         return (VersionImpl) session.getNodeById(baseId);
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Mon Aug  3 18:10:46 2009
@@ -499,7 +499,7 @@
      * @return the newly created version
      * @throws RepositoryException if an error occurs
      */
-    InternalVersionImpl checkin(Name name, NodeStateEx src)
+    InternalVersionImpl checkin(Name name, NodeStateEx src, Calendar created)
             throws RepositoryException {
 
         // copy predecessors from src node
@@ -540,7 +540,10 @@
         }
 
         // initialize 'created', 'predecessors' and 'successors'
-        vNode.setPropertyValue(NameConstants.JCR_CREATED, InternalValue.create(getCurrentTime()));
+        if (created == null) {
+            created = getCurrentTime();
+        }
+        vNode.setPropertyValue(NameConstants.JCR_CREATED, InternalValue.create(created));
         vNode.setPropertyValues(NameConstants.JCR_PREDECESSORS, PropertyType.REFERENCE, predecessors);
         vNode.setPropertyValues(NameConstants.JCR_SUCCESSORS, PropertyType.REFERENCE, InternalValue.EMPTY_ARRAY);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManager.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManager.java
Mon Aug  3 18:10:46 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Calendar;
+
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -61,10 +63,12 @@
      *
      * @param session session that invokes the checkin
      * @param node node to checkin
+     * @param created create time of the new version,
+     *                or <code>null</code> for the current time
      * @return the newly created version
      * @throws RepositoryException if an error occurs
      */
-    InternalVersion checkin(Session session, NodeStateEx node)
+    InternalVersion checkin(Session session, NodeStateEx node, Calendar created)
             throws RepositoryException;
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerBase.java
Mon Aug  3 18:10:46 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Calendar;
+
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ReferentialIntegrityException;
 import javax.jcr.RepositoryException;
@@ -548,14 +550,16 @@
      * @throws javax.jcr.RepositoryException if an error occurs
      * @see javax.jcr.Node#checkin()
      */
-    protected InternalVersion internalCheckin(InternalVersionHistoryImpl history,
-                                      NodeStateEx node, boolean simple)
+    protected InternalVersion internalCheckin(
+            InternalVersionHistoryImpl history,
+            NodeStateEx node, boolean simple, Calendar created)
             throws RepositoryException {
         WriteOperation operation = startWriteOperation();
         try {
             String versionName = calculateCheckinVersionName(history, node, simple);
             InternalVersionImpl v = history.checkin(
-                    NameFactoryImpl.getInstance().create("", versionName), node);
+                    NameFactoryImpl.getInstance().create("", versionName),
+                    node, created);
 
             // check for jcr:activity
             if (node.hasProperty(NameConstants.JCR_ACTIVITY)) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionManagerImpl.java
Mon Aug  3 18:10:46 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Calendar;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -417,22 +418,24 @@
      * This method must not be synchronized since it could cause deadlocks with
      * item-reading listeners in the observation thread.
      */
-    public InternalVersion checkin(final Session session, final NodeStateEx node)
+    public InternalVersion checkin(
+            final Session session,
+            final NodeStateEx node, final Calendar created)
             throws RepositoryException {
         return (InternalVersion)
                 escFactory.doSourced((SessionImpl) session, new SourcedTarget() {
             public Object run() throws RepositoryException {
-                InternalVersionHistory vh;
+                InternalVersionHistoryImpl vh;
                 if (node.getEffectiveNodeType().includesNodeType(NameConstants.MIX_VERSIONABLE))
{
                     // in full versioning, the history id can be retrieved via
                     // the property
                     NodeId histId = node.getPropertyValue(NameConstants.JCR_VERSIONHISTORY).getNodeId();
-                    vh = getVersionHistory(histId);
-                    return internalCheckin((InternalVersionHistoryImpl) vh, node, false);
+                    vh = (InternalVersionHistoryImpl) getVersionHistory(histId);
+                    return internalCheckin(vh, node, false, created);
                 } else {
                     // in simple versioning the history id needs to be calculated
-                    vh = getVersionHistoryOfNode(node.getNodeId());
-                    return internalCheckin((InternalVersionHistoryImpl) vh, node, true);
+                    vh = (InternalVersionHistoryImpl) getVersionHistoryOfNode(node.getNodeId());
+                    return internalCheckin(vh, node, true, created);
                 }
             }
         });

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalXAVersionManager.java
Mon Aug  3 18:10:46 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -212,25 +213,26 @@
     /**
      * {@inheritDoc}
      */
-    public InternalVersion checkin(Session session, NodeStateEx node)
+    public InternalVersion checkin(
+            Session session, NodeStateEx node, Calendar created)
             throws RepositoryException {
         if (isInXA()) {
-            InternalVersionHistory vh;
+            InternalVersionHistoryImpl vh;
             InternalVersion version;
             if (node.getEffectiveNodeType().includesNodeType(NameConstants.MIX_VERSIONABLE))
{
                 // in full versioning, the history id can be retrieved via
                 // the property
                 NodeId histId = node.getPropertyValue(NameConstants.JCR_VERSIONHISTORY).getNodeId();
-                vh = getVersionHistory(histId);
-                version = internalCheckin((InternalVersionHistoryImpl) vh, node, false);
+                vh = (InternalVersionHistoryImpl) getVersionHistory(histId);
+                version = internalCheckin(vh, node, false, created);
             } else {
                 // in simple versioning the history id needs to be calculated
-                vh = getVersionHistoryOfNode(node.getNodeId());
-                version = internalCheckin((InternalVersionHistoryImpl) vh, node, true);
+                vh = (InternalVersionHistoryImpl) getVersionHistoryOfNode(node.getNodeId());
+                version = internalCheckin(vh, node, true, created);
             }
             return version;
         } else {
-            return vMgr.checkin(session, node);
+            return vMgr.checkin(session, node, created);
         }
     }
 
@@ -442,15 +444,17 @@
      * <p/>
      * Before modifying version history given, make a local copy of it.
      */
-    protected InternalVersion internalCheckin(InternalVersionHistoryImpl history,
-                                      NodeStateEx node, boolean simple)
+    protected InternalVersion internalCheckin(
+            InternalVersionHistoryImpl history,
+            NodeStateEx node, boolean simple, Calendar created)
             throws RepositoryException {
 
         if (history.getVersionManager() != this) {
             history = makeLocalCopy(history);
             xaItems.put(history.getId(), history);
         }
-        InternalVersion version = super.internalCheckin(history, node, simple);
+        InternalVersion version =
+            super.internalCheckin(history, node, simple, created);
         NodeId frozenNodeId = version.getFrozenNodeId();
         InternalVersionItem frozenNode = createInternalVersionItem(frozenNodeId);
         if (frozenNode != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplBase.java
Mon Aug  3 18:10:46 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.version;
 
+import java.util.Calendar;
 import java.util.Set;
 import java.util.HashSet;
 
@@ -119,11 +120,15 @@
      * @param state node state
      * @param checkin if <code>true</code> the node is checked in.
      * @param checkout if <code>true</code> the node is checked out.
+     * @param created create time of the new version (if any),
+     *                or <code>null</code> for the current time
      * @return the node id of the base version or <code>null</code> for a pure
      *         checkout.
      * @throws RepositoryException if an error occurs
      */
-    protected NodeId checkoutCheckin(NodeStateEx state, boolean checkin, boolean checkout)
+    protected NodeId checkoutCheckin(
+            NodeStateEx state,
+            boolean checkin, boolean checkout, Calendar created)
             throws RepositoryException {
         assert(checkin || checkout);
 
@@ -174,7 +179,7 @@
                     state.setPropertyValues(NameConstants.REP_VERSIONS, PropertyType.REFERENCE,
vs);
                     state.store();
                 }
-                InternalVersion v = vMgr.checkin(session, state);
+                InternalVersion v = vMgr.checkin(session, state, created);
                 baseId = v.getId();
                 if (isFull) {
                     state.setPropertyValue(

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java?rev=800483&r1=800482&r2=800483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImplRestore.java
Mon Aug  3 18:10:46 2009
@@ -299,7 +299,7 @@
         } else {
             // with simple versioning, the node is checked in automatically,
             // thus not allowing any branches
-            vMgr.checkin(session, state);
+            vMgr.checkin(session, state, null);
         }
         // 3. N's jcr:isCheckedOut property is set to false.
         state.setPropertyValue(NameConstants.JCR_ISCHECKEDOUT, InternalValue.create(false));
@@ -512,13 +512,13 @@
                 //   special node containing a reference to the version history of
                 //   C. On restore, the following occurs:
                 //   - If the workspace currently has an already existing node corresponding
-                //     to CÕs version history and the removeExisting flag of the restore
is
+                //     to C's version history and the removeExisting flag of the restore
is
                 //     set to true, then that instance of C becomes the child of the restored
N.
                 //   - If the workspace currently has an already existing node corresponding
-                //     to CÕs version history and the removeExisting flag of the restore
is
+                //     to C's version history and the removeExisting flag of the restore
is
                 //     set to false then an ItemExistsException is thrown.
                 //   - If the workspace does not have an instance of C then one is restored
from
-                //     CÕs version history:
+                //     C's version history:
                 //     - If the restore was initiated through a restoreByLabel where L is
                 //       the specified label and there is a version of C with the label L
then
                 //       that version is restored.



Mime
View raw message