jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r157348 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version: VersionHistoryImpl.java persistence/InternalVersionHistoryImpl.java
Date Sun, 13 Mar 2005 18:38:17 GMT
Author: tripod
Date: Sun Mar 13 10:38:15 2005
New Revision: 157348

URL: http://svn.apache.org/viewcvs?view=rev&rev=157348
Log:
- fixing VersionHistory.removeVersion()

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java?view=diff&r1=157347&r2=157348
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
Sun Mar 13 10:38:15 2005
@@ -221,14 +221,14 @@
     public void removeVersion(String versionName)
             throws UnsupportedRepositoryOperationException, VersionException,
             RepositoryException {
-
-        // check if any references exist on this version
-        VersionImpl v = (VersionImpl) getVersion(versionName);
-        PropertyIterator iter = v.getReferences();
-        if (iter.hasNext()) {
-            throw new VersionException("Unable to remove version. At least once referenced:
" + ((PropertyImpl) iter.nextProperty()).safeGetJCRPath());
+        try {
+            QName name = QName.fromJCRName(versionName, session.getNamespaceResolver());
+            history.removeVersion(name);
+        } catch (IllegalNameException e) {
+            throw new RepositoryException(e);
+        } catch (UnknownPrefixException e) {
+            throw new RepositoryException(e);
         }
-        history.removeVersion(v.getQName());
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java?view=diff&r1=157347&r2=157348
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/version/persistence/InternalVersionHistoryImpl.java
Sun Mar 13 10:38:15 2005
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.core.InternalValue;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.QName;
+import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.UpdatableItemStateManager;
 import org.apache.jackrabbit.core.util.uuid.UUID;
@@ -32,10 +33,12 @@
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.PropertyIterator;
 import javax.jcr.version.VersionException;
 import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  *
@@ -240,14 +243,19 @@
      */
     public void removeVersion(QName versionName) throws VersionException {
 
-        try {
-            InternalVersionImpl v = (InternalVersionImpl) getVersion(versionName);
-            if (v.equals(rootVersion)) {
-                String msg = "Removal of " + versionName + " not allowed.";
-                log.debug(msg);
-                throw new VersionException(msg);
-            }
+        InternalVersionImpl v = (InternalVersionImpl) getVersion(versionName);
+        if (v.equals(rootVersion)) {
+            String msg = "Removal of " + versionName + " not allowed.";
+            log.debug(msg);
+            throw new VersionException(msg);
+        }
+        // check if any references (from outside the version storage) exist on this version
+        List refs = getVersionManager().getItemReferences(v);
+        if (!refs.isEmpty()) {
+            throw new VersionException("Unable to remove version. At least once referenced.");
+        }
 
+        try {
             boolean succeeded = false;
             UpdatableItemStateManager stateMgr = getVersionManager().getItemStateMgr();
             try {



Mime
View raw message