Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-10-18 13:23:56 -0400
committerEike Stepper2018-10-18 13:23:56 -0400
commitcdc9b7664bef1afaa89756477409f23310b44e18 (patch)
tree2dffcbb1609d9bafee35476e85ac6caedd697db1
parent20f29ab16df76f65f9454ffb70e713fc5354a689 (diff)
downloadcdo-cdc9b7664bef1afaa89756477409f23310b44e18.tar.gz
cdo-cdc9b7664bef1afaa89756477409f23310b44e18.tar.xz
cdo-cdc9b7664bef1afaa89756477409f23310b44e18.zip
[540266] "Duplicate path" exception when moving an existing CDOResourceNode to a different folder
https://bugs.eclipse.org/bugs/show_bug.cgi?id=540266
-rw-r--r--features/org.eclipse.emf.cdo-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo-feature/pom.xml2
-rw-r--r--features/org.eclipse.emf.cdo.sdk-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.sdk-feature/pom.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server-feature/pom.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server.embedded-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server.embedded-feature/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF68
-rw-r--r--plugins/org.eclipse.emf.cdo.common/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDODuplicateResourceException.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java69
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java38
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java30
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java2
16 files changed, 258 insertions, 114 deletions
diff --git a/features/org.eclipse.emf.cdo-feature/feature.xml b/features/org.eclipse.emf.cdo-feature/feature.xml
index 5d77738c13..ae30c5bf7c 100644
--- a/features/org.eclipse.emf.cdo-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo-feature/feature.xml
@@ -13,7 +13,7 @@
<feature
id="org.eclipse.emf.cdo"
label="%featureName"
- version="4.7.100.qualifier"
+ version="4.8.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.emf.cdo.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.emf.cdo-feature/pom.xml b/features/org.eclipse.emf.cdo-feature/pom.xml
index 8d4c20dfd6..7f5062d8b2 100644
--- a/features/org.eclipse.emf.cdo-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo</artifactId>
- <version>4.7.100-SNAPSHOT</version>
+ <version>4.8.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.emf.cdo.sdk-feature/feature.xml b/features/org.eclipse.emf.cdo.sdk-feature/feature.xml
index d8c4b0f462..46031e6b41 100644
--- a/features/org.eclipse.emf.cdo.sdk-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.sdk-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.sdk"
label="%featureName"
- version="5.0.100.qualifier"
+ version="5.1.0.qualifier"
provider-name="%providerName"
image="eclipse_update_120.jpg"
license-feature="org.eclipse.emf.cdo.license"
diff --git a/features/org.eclipse.emf.cdo.sdk-feature/pom.xml b/features/org.eclipse.emf.cdo.sdk-feature/pom.xml
index d75aa0cd0c..b9ad5214af 100644
--- a/features/org.eclipse.emf.cdo.sdk-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.sdk-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.sdk</artifactId>
- <version>5.0.100-SNAPSHOT</version>
+ <version>5.1.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.emf.cdo.server-feature/feature.xml b/features/org.eclipse.emf.cdo.server-feature/feature.xml
index 35a46f958b..9451c99707 100644
--- a/features/org.eclipse.emf.cdo.server-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.server-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.server"
label="%featureName"
- version="4.7.100.qualifier"
+ version="4.8.0.qualifier"
provider-name="%providerName"
image="eclipse_update_120.jpg"
license-feature="org.eclipse.emf.cdo.license"
diff --git a/features/org.eclipse.emf.cdo.server-feature/pom.xml b/features/org.eclipse.emf.cdo.server-feature/pom.xml
index ec2925f6f5..6560bdcb27 100644
--- a/features/org.eclipse.emf.cdo.server-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.server-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.server</artifactId>
- <version>4.7.100-SNAPSHOT</version>
+ <version>4.8.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.emf.cdo.server.embedded-feature/feature.xml b/features/org.eclipse.emf.cdo.server.embedded-feature/feature.xml
index a6c80258d6..dfbd13339c 100644
--- a/features/org.eclipse.emf.cdo.server.embedded-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.server.embedded-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.server.embedded"
label="%featureName"
- version="4.7.100.qualifier"
+ version="4.8.0.qualifier"
provider-name="%providerName"
image="eclipse_update_120.jpg"
license-feature="org.eclipse.emf.cdo.license"
diff --git a/features/org.eclipse.emf.cdo.server.embedded-feature/pom.xml b/features/org.eclipse.emf.cdo.server.embedded-feature/pom.xml
index b13684a8d3..4b597ea1b2 100644
--- a/features/org.eclipse.emf.cdo.server.embedded-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.server.embedded-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.server.embedded</artifactId>
- <version>4.7.100-SNAPSHOT</version>
+ <version>4.8.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
index 5ea7b064df..7c967f5d34 100644
--- a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.common;singleton:=true
-Bundle-Version: 4.7.100.qualifier
+Bundle-Version: 4.8.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -15,21 +15,21 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";visibili
org.eclipse.emf.ecore.change;bundle-version="[2.5.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
- org.eclipse.emf.cdo.common.admin;version="4.7.100",
- org.eclipse.emf.cdo.common.branch;version="4.7.100",
- org.eclipse.emf.cdo.common.commit;version="4.7.100",
- org.eclipse.emf.cdo.common.commit.handler;version="4.7.100",
- org.eclipse.emf.cdo.common.id;version="4.7.100",
- org.eclipse.emf.cdo.common.lob;version="4.7.100",
- org.eclipse.emf.cdo.common.lock;version="4.7.100",
- org.eclipse.emf.cdo.common.model;version="4.7.100",
- org.eclipse.emf.cdo.common.protocol;version="4.7.100",
- org.eclipse.emf.cdo.common.revision;version="4.7.100",
- org.eclipse.emf.cdo.common.revision.delta;version="4.7.100",
- org.eclipse.emf.cdo.common.security;version="4.7.100",
- org.eclipse.emf.cdo.common.util;version="4.7.100",
- org.eclipse.emf.cdo.internal.common;version="4.7.100";
+Export-Package: org.eclipse.emf.cdo.common;version="4.8.0",
+ org.eclipse.emf.cdo.common.admin;version="4.8.0",
+ org.eclipse.emf.cdo.common.branch;version="4.8.0",
+ org.eclipse.emf.cdo.common.commit;version="4.8.0",
+ org.eclipse.emf.cdo.common.commit.handler;version="4.8.0",
+ org.eclipse.emf.cdo.common.id;version="4.8.0",
+ org.eclipse.emf.cdo.common.lob;version="4.8.0",
+ org.eclipse.emf.cdo.common.lock;version="4.8.0",
+ org.eclipse.emf.cdo.common.model;version="4.8.0",
+ org.eclipse.emf.cdo.common.protocol;version="4.8.0",
+ org.eclipse.emf.cdo.common.revision;version="4.8.0",
+ org.eclipse.emf.cdo.common.revision.delta;version="4.8.0",
+ org.eclipse.emf.cdo.common.security;version="4.8.0",
+ org.eclipse.emf.cdo.common.util;version="4.8.0",
+ org.eclipse.emf.cdo.internal.common;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -39,11 +39,11 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.common.branch;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.branch;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.common.bundle;version="4.7.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.commit;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.bundle;version="4.8.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.commit;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -52,7 +52,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.id;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.id;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -63,9 +63,9 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.admin,
org.eclipse.emf.cdo.server.admin",
- org.eclipse.emf.cdo.internal.common.lock;version="4.7.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.messages;version="4.7.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.model;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.lock;version="4.8.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.messages;version="4.8.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.model;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -74,7 +74,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.revision;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.revision;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -83,7 +83,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.revision.delta;version="4.7.100";
+ org.eclipse.emf.cdo.internal.common.revision.delta;version="4.8.0";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -92,14 +92,14 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.spi.common;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.admin;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.branch;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.commit;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.id;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.lock;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.model;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.protocol;version="4.7.100",
- org.eclipse.emf.cdo.spi.common.revision;version="4.7.100"
+ org.eclipse.emf.cdo.spi.common;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.admin;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.branch;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.commit;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.id;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.lock;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.model;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.protocol;version="4.8.0",
+ org.eclipse.emf.cdo.spi.common.revision;version="4.8.0"
Automatic-Module-Name: org.eclipse.emf.cdo.common
Eclipse-RegisterBuddy: org.eclipse.net4j.util
diff --git a/plugins/org.eclipse.emf.cdo.common/pom.xml b/plugins/org.eclipse.emf.cdo.common/pom.xml
index d22fd5b8ca..b889cf444a 100644
--- a/plugins/org.eclipse.emf.cdo.common/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.common/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.common</artifactId>
- <version>4.7.100-SNAPSHOT</version>
+ <version>4.8.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDODuplicateResourceException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDODuplicateResourceException.java
new file mode 100644
index 0000000000..a8ea6c2aac
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDODuplicateResourceException.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Eike Stepper (Loehne, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.util;
+
+/**
+ * @author Eike Stepper
+ * @since 4.8
+ */
+public final class CDODuplicateResourceException extends CDOException
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDODuplicateResourceException()
+ {
+ }
+
+ public CDODuplicateResourceException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public CDODuplicateResourceException(String message)
+ {
+ super(message);
+ }
+
+ public CDODuplicateResourceException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
index c7b27c63ec..6e3e3630b5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.lob.CDOBlob;
import org.eclipse.emf.cdo.common.lob.CDOClob;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.common.util.CDODuplicateResourceException;
import org.eclipse.emf.cdo.eresource.CDOBinaryResource;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
@@ -548,6 +549,89 @@ public class ResourceTest extends AbstractCDOTest
session.close();
}
+ public void testSetPathConflict() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource0 = transaction.createResource(getResourcePath("/my/resource0"));
+ CDOResource resource1 = transaction.createResource(getResourcePath("/my/resource1"));
+ transaction.commit();
+
+ try
+ {
+ resource0.setPath(resource1.getPath());
+ fail("CDODuplicateResourceException expected");
+ }
+ catch (CDODuplicateResourceException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testSetFolder() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ CDOResourceFolder folder = transaction.createResourceFolder(getResourcePath("folder"));
+ transaction.commit();
+
+ resource.setFolder(folder);
+ transaction.commit();
+ }
+
+ public void testSetFolderConflict() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ CDOResourceFolder folder = transaction.createResourceFolder(getResourcePath("folder"));
+ transaction.createResource(getResourcePath("folder/res"));
+ transaction.commit();
+
+ try
+ {
+ resource.setFolder(folder);
+ fail("CDODuplicateResourceException expected");
+ }
+ catch (CDODuplicateResourceException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testMove() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ CDOResourceFolder folder = transaction.createResourceFolder(getResourcePath("folder"));
+ transaction.commit();
+
+ folder.getNodes().add(resource);
+ transaction.commit();
+ }
+
+ public void testMoveConflict() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ CDOResourceFolder folder = transaction.createResourceFolder(getResourcePath("folder"));
+ transaction.createResource(getResourcePath("folder/res"));
+ transaction.commit();
+
+ try
+ {
+ folder.getNodes().add(resource);
+ fail("CDODuplicateResourceException expected");
+ }
+ catch (CDODuplicateResourceException expected)
+ {
+ // SUCCESS
+ }
+ }
+
@CleanRepositoriesBefore(reason = "Root resource access")
@CleanRepositoriesAfter(reason = "Root resource access")
public void testMoveToRoot() throws Exception
@@ -594,30 +678,6 @@ public class ResourceTest extends AbstractCDOTest
assertEquals(true, CDOIDUtil.isNull(data.getResourceID()));
}
- public void testDuplicatePath() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- transaction.createResource(getResourcePath("/my/resource"));
- transaction.commit();
-
- transaction.createResource(getResourcePath("/my/resource"));
-
- try
- {
- transaction.commit();
- fail("CommitException expected");
- }
- catch (CommitException expected)
- {
- // Success
- }
- finally
- {
- session.close();
- }
- }
-
public void testDuplicatePathAfterDetach() throws Exception
{
CDOSession session = openSession();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
index 4795f7823c..a84f613b6f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.cdo.tests.bugzilla;
-import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -18,8 +17,6 @@ import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
-import java.util.Map.Entry;
-
/**
* Bug 334995 - CDOTransaction corrupted by persisted + new resource with same URI
*
@@ -27,38 +24,40 @@ import java.util.Map.Entry;
*/
public class Bugzilla_334995_Test extends AbstractCDOTest
{
- public void test() throws CommitException
- {
- CDOID[] resourceIDs = persistResources("/res1");
-
- {
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
-
- CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- msg("New resource: " + resource);
- msg("newObjects:");
-
- for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- {
- msg(" " + entry + ", state: " + entry.getValue().cdoState());
- assertNew(entry.getValue(), transaction);
- }
-
- // Fetch the persisted resource that has the same URI
- CDOResource resource1 = (CDOResource)transaction.getObject(resourceIDs[0]);
- msg("Persisted resource: " + resource1);
-
- msg("newObjects:");
- for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- {
- msg(" " + entry + ", state: " + entry.getValue().cdoState());
- assertNew(entry.getValue(), transaction);
- }
-
- transaction.commit();
- }
- }
+ // The following test seems obsolete because (as of bug xxxxxx) no local changes can create resource duplicates.
+ //
+ // public void test() throws CommitException
+ // {
+ // CDOID[] resourceIDs = persistResources("/res1");
+ //
+ // {
+ // CDOSession session = openSession();
+ // CDOTransaction transaction = session.openTransaction();
+ //
+ // CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ // msg("New resource: " + resource);
+ // msg("newObjects:");
+ //
+ // for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ // {
+ // msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ // assertNew(entry.getValue(), transaction);
+ // }
+ //
+ // // Fetch the persisted resource that has the same URI
+ // CDOResource resource1 = (CDOResource)transaction.getObject(resourceIDs[0]);
+ // msg("Persisted resource: " + resource1);
+ //
+ // msg("newObjects:");
+ // for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ // {
+ // msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ // assertNew(entry.getValue(), transaction);
+ // }
+ //
+ // transaction.commit();
+ // }
+ // }
public void testRename() throws CommitException
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java
index 983c5b607e..68dc0397af 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.eresource.impl;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.util.CDODuplicateResourceException;
import org.eclipse.emf.cdo.eresource.CDOBinaryResource;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
@@ -21,15 +22,21 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.internal.cdo.messages.Messages;
+
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Iterator;
import java.util.Map;
/**
@@ -120,6 +127,37 @@ public class CDOResourceFolderImpl extends CDOResourceNodeImpl implements CDORes
}
}
+ @Override
+ protected EList<?> createList(EStructuralFeature eStructuralFeature) throws CDODuplicateResourceException
+ {
+ if (eStructuralFeature == EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES)
+ {
+ return new EStoreEObjectImpl.BasicEStoreEList<CDOResourceNode>(this, eStructuralFeature)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected CDOResourceNode validate(int index, CDOResourceNode newNode)
+ {
+ String newName = newNode.getName();
+
+ for (Iterator<CDOResourceNode> it = iterator(); it.hasNext();)
+ {
+ CDOResourceNode existingNode = it.next();
+ if (ObjectUtil.equals(existingNode.getName(), newName))
+ {
+ throw new CDODuplicateResourceException(MessageFormat.format(Messages.getString("CDOResourceNodeImpl.5"), existingNode.getPath())); //$NON-NLS-1$
+ }
+ }
+
+ return super.validate(index, newNode);
+ }
+ };
+ }
+
+ return super.createList(eStructuralFeature);
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java
index 42ff252af1..40eb6ebf6b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java
@@ -12,7 +12,9 @@
*/
package org.eclipse.emf.cdo.eresource.impl;
+import org.eclipse.emf.cdo.common.util.CDODuplicateResourceException;
import org.eclipse.emf.cdo.common.util.CDOException;
+import org.eclipse.emf.cdo.common.util.CDOResourceNodeNotFoundException;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
@@ -120,7 +122,7 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe
String name = getName();
if (name != null)
{
- String newPath = (newFolder == null ? "" : newFolder.getPath()) + CDOURIUtil.SEGMENT_SEPARATOR + name; //$NON-NLS-1$
+ String newPath = (newFolder == null ? "" : newFolder.getPath()) + CDOURIUtil.SEGMENT_SEPARATOR + name; // $NON-NLS-1$
checkDuplicates(newPath);
}
}
@@ -177,7 +179,7 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe
CDOResourceFolder parent = getFolder();
if (parent != null)
{
- String newPath = parent.getPath() + CDOURIUtil.SEGMENT_SEPARATOR + getName();
+ String newPath = parent.getPath() + CDOURIUtil.SEGMENT_SEPARATOR + newName;
checkDuplicates(newPath);
}
}
@@ -223,7 +225,8 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe
String oldPath = getPath();
if (!ObjectUtil.equals(oldPath, newPath))
{
- // TODO check for duplicates
+ checkDuplicates(newPath);
+
List<String> names = CDOURIUtil.analyzePath(newPath);
if (names.isEmpty())
{
@@ -295,17 +298,22 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe
/**
* @ADDED
*/
- private void checkDuplicates(String newPath)
+ private void checkDuplicates(String newPath) throws CDODuplicateResourceException
{
- try
+ InternalCDOView view = cdoView();
+ if (view != null)
{
- InternalCDOView view = cdoView();
view.clearResourcePathCacheIfNecessary(null);
- view.getResourceNodeID(newPath);
- }
- catch (Exception ex)
- {
- throw new CDOException(MessageFormat.format(Messages.getString("CDOResourceNodeImpl.5"), newPath)); //$NON-NLS-1$
+
+ try
+ {
+ view.getResourceNodeID(newPath);
+ throw new CDODuplicateResourceException(MessageFormat.format(Messages.getString("CDOResourceNodeImpl.5"), newPath)); //$NON-NLS-1$
+ }
+ catch (CDOResourceNodeNotFoundException success)
+ {
+ //$FALL-THROUGH$
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index 3a3ba9beaa..4c991641ac 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -1180,7 +1180,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
}
}
- protected CDOID getResourceNodeID(CDOID folderID, String name)
+ protected CDOID getResourceNodeID(CDOID folderID, String name) throws CDOResourceNodeNotFoundException
{
synchronized (getViewMonitor())
{

Back to the top