jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1440917 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version: InternalVersionManager.java InternalVersionManagerBase.java InternalVersionManagerImpl.java InternalXAVersionManager.java
Date Thu, 31 Jan 2013 11:30:56 GMT
Author: unico
Date: Thu Jan 31 11:30:56 2013
New Revision: 1440917

URL: http://svn.apache.org/viewvc?rev=1440917&view=rev
Log:
JCR-3507 add ability to remove version history objects from the version storage via the internal
version management API

Modified:
    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

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=1440917&r1=1440916&r2=1440917&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
Thu Jan 31 11:30:56 2013
@@ -92,6 +92,15 @@ public interface InternalVersionManager 
             throws RepositoryException;
 
     /**
+     * Removes the specified version history from storage.
+     *
+     * @param session the session that performs the remove
+     * @param history the version history to remove
+     * @throws RepositoryException if an error occurs
+     */
+    void removeVersionHistory(Session session, InternalVersionHistory history) throws RepositoryException;
+
+    /**
      * Sets the version <code>label</code> to the given <code>version</code>.
      * If the label is already assigned to another version, a VersionException is
      * thrown unless <code>move</code> is <code>true</code>. If <code>version</code>

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=1440917&r1=1440916&r2=1440917&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
Thu Jan 31 11:30:56 2013
@@ -786,6 +786,29 @@ abstract class InternalVersionManagerBas
     }
 
     /**
+     * Removes the specified history from the storage
+     *
+     * @param history the version history to remove
+     * @throws VersionException
+     * @throws RepositoryException
+     */
+    public void internalRemoveVersionHistory(InternalVersionHistoryImpl history)
+            throws VersionException, RepositoryException {
+        String versionableUuid = history.getVersionableId().toString();
+        WriteOperation operation = startWriteOperation();
+        try {
+            NodeStateEx parent = getParentNode(getHistoryRoot(), versionableUuid, null);
+            parent.removeNode(history.node.getName());
+            parent.store();
+            operation.save();
+        } catch (ItemStateException e) {
+            log.error("Error while storing: " + e.toString());
+        } finally {
+            operation.close();
+        }
+    }
+
+    /**
      * Set version label on the specified version.
      *
      * @param history version history

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=1440917&r1=1440916&r2=1440917&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
Thu Jan 31 11:30:56 2013
@@ -448,6 +448,21 @@ public class InternalVersionManagerImpl 
      * This method must not be synchronized since it could cause deadlocks with
      * item-reading listeners in the observation thread.
      */
+    public void removeVersionHistory(Session session, final InternalVersionHistory history)
throws RepositoryException {
+        escFactory.doSourced((SessionImpl) session, new SourcedTarget() {
+            public Object run() throws RepositoryException {
+                internalRemoveVersionHistory((InternalVersionHistoryImpl) history);
+                return null;
+            }
+        });
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p/>
+     * This method must not be synchronized since it could cause deadlocks with
+     * item-reading listeners in the observation thread.
+     */
     public InternalVersion setVersionLabel(Session session,
                                            final InternalVersionHistory history,
                                            final Name version, final Name label,

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=1440917&r1=1440916&r2=1440917&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
Thu Jan 31 11:30:56 2013
@@ -255,6 +255,18 @@ public class InternalXAVersionManager ex
     /**
      * {@inheritDoc}
      */
+    public void removeVersionHistory(Session session, InternalVersionHistory history)
+            throws RepositoryException {
+        if (isInXA()) {
+            internalRemoveVersionHistory((InternalVersionHistoryImpl) history);
+        } else {
+            vMgr.removeVersionHistory(session, history);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public InternalVersion setVersionLabel(Session session,
                                            InternalVersionHistory history,
                                            Name version,



Mime
View raw message