Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2014-08-20 15:36:51 +0000
committerEsteban Dugueperoux2014-09-02 14:25:06 +0000
commita9c4ebc430092b4bd902167ad57e0d958d2e5082 (patch)
tree5477ffcfc9ff9f57fcddd2c0d713cfd108c14783 /plugins
parentf598dd582396a00cd84bc2d5a0ee6bc15166460e (diff)
downloadcdo-a9c4ebc430092b4bd902167ad57e0d958d2e5082.tar.gz
cdo-a9c4ebc430092b4bd902167ad57e0d958d2e5082.tar.xz
cdo-a9c4ebc430092b4bd902167ad57e0d958d2e5082.zip
[442178] ResourcePermission doesn't work with fragmented resource
Fix CDORevisionUtil.getResourceNodePath() when called with CDOObject contained in fragmented resource Bug: 442178 Change-Id: I2aa34a768e399c26e60577944b10d9ea900e2ef1 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF68
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_442178_Test.java136
3 files changed, 209 insertions, 35 deletions
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 944c02b250..f43900e3b2 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
-Bundle-Version: 4.3.0.qualifier
+Bundle-Version: 4.3.100.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -14,21 +14,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.3.0",
- org.eclipse.emf.cdo.common.admin;version="4.3.0",
- org.eclipse.emf.cdo.common.branch;version="4.3.0",
- org.eclipse.emf.cdo.common.commit;version="4.3.0",
- org.eclipse.emf.cdo.common.commit.handler;version="4.3.0",
- org.eclipse.emf.cdo.common.id;version="4.3.0",
- org.eclipse.emf.cdo.common.lob;version="4.3.0",
- org.eclipse.emf.cdo.common.lock;version="4.3.0",
- org.eclipse.emf.cdo.common.model;version="4.3.0",
- org.eclipse.emf.cdo.common.protocol;version="4.3.0",
- org.eclipse.emf.cdo.common.revision;version="4.3.0",
- org.eclipse.emf.cdo.common.revision.delta;version="4.3.0",
- org.eclipse.emf.cdo.common.security;version="4.3.0",
- org.eclipse.emf.cdo.common.util;version="4.3.0",
- org.eclipse.emf.cdo.internal.common;version="4.3.0";
+Export-Package: org.eclipse.emf.cdo.common;version="4.3.100",
+ org.eclipse.emf.cdo.common.admin;version="4.3.100",
+ org.eclipse.emf.cdo.common.branch;version="4.3.100",
+ org.eclipse.emf.cdo.common.commit;version="4.3.100",
+ org.eclipse.emf.cdo.common.commit.handler;version="4.3.100",
+ org.eclipse.emf.cdo.common.id;version="4.3.100",
+ org.eclipse.emf.cdo.common.lob;version="4.3.100",
+ org.eclipse.emf.cdo.common.lock;version="4.3.100",
+ org.eclipse.emf.cdo.common.model;version="4.3.100",
+ org.eclipse.emf.cdo.common.protocol;version="4.3.100",
+ org.eclipse.emf.cdo.common.revision;version="4.3.100",
+ org.eclipse.emf.cdo.common.revision.delta;version="4.3.100",
+ org.eclipse.emf.cdo.common.security;version="4.3.100",
+ org.eclipse.emf.cdo.common.util;version="4.3.100",
+ org.eclipse.emf.cdo.internal.common;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -38,11 +38,11 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
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.3.0";
+ org.eclipse.emf.cdo.internal.common.branch;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.common.bundle;version="4.3.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.commit;version="4.3.0";
+ org.eclipse.emf.cdo.internal.common.bundle;version="4.3.100";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.commit;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -51,7 +51,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
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.3.0";
+ org.eclipse.emf.cdo.internal.common.id;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -62,9 +62,9 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
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.3.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.messages;version="4.3.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.model;version="4.3.0";
+ org.eclipse.emf.cdo.internal.common.lock;version="4.3.100";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.messages;version="4.3.100";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.model;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -73,7 +73,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
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.3.0";
+ org.eclipse.emf.cdo.internal.common.revision;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -82,7 +82,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
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.3.0";
+ org.eclipse.emf.cdo.internal.common.revision.delta;version="4.3.100";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -91,12 +91,12 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.3.0",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.spi.common;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.admin;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.branch;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.commit;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.id;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.lock;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.model;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.protocol;version="4.3.0",
- org.eclipse.emf.cdo.spi.common.revision;version="4.3.0"
+ org.eclipse.emf.cdo.spi.common;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.admin;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.branch;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.commit;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.id;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.lock;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.model;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.protocol;version="4.3.100",
+ org.eclipse.emf.cdo.spi.common.revision;version="4.3.100"
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
index 15352ef0db..6e305ebb94 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
@@ -383,7 +383,15 @@ public final class CDORevisionUtil
private static void getResourceNodePath(InternalCDORevision revision, CDORevisionProvider provider,
StringBuilder result)
{
- InternalCDORevision container = getParentRevision(revision, provider);
+ InternalCDORevision container = null;
+ if (!revision.isResourceNode())
+ {
+ container = getResourceRevision(revision, provider);
+ }
+ else
+ {
+ container = getParentRevision(revision, provider);
+ }
if (container != null)
{
getResourceNodePath(container, provider, result);
@@ -406,6 +414,36 @@ public final class CDORevisionUtil
}
}
+ private static InternalCDORevision getResourceRevision(InternalCDORevision revision, CDORevisionProvider provider)
+ {
+ CDOID resourceID = revision.getResourceID();
+ if (revision.isResourceNode())
+ {
+ return null;
+ }
+ if (CDOIDUtil.isNull(resourceID))
+ {
+ CDOID parentID = null;
+ Object containerID = revision.getContainerID();
+ if (containerID instanceof CDOWithID)
+ {
+ parentID = ((CDOWithID)containerID).cdoID();
+ }
+ else
+ {
+ parentID = (CDOID)containerID;
+ }
+
+ if (!CDOIDUtil.isNull(parentID))
+ {
+ InternalCDORevision parentRevision = (InternalCDORevision)provider.getRevision(parentID);
+ return getResourceRevision(parentRevision, provider);
+ }
+ }
+
+ return (InternalCDORevision)provider.getRevision(resourceID);
+ }
+
private static EAttribute getResourceNodeNameAttribute(CDORevision revision)
{
if (revision.isResourceNode())
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_442178_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_442178_Test.java
new file mode 100644
index 0000000000..bbf1599658
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_442178_Test.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004-2014 Eike Stepper (Berlin, 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:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Test {@link CDORevisionUtil#getResourceNodePath(org.eclipse.emf.cdo.common.revision.CDORevision, org.eclipse.emf.cdo.common.revision.CDORevisionProvider)} with fragments.
+ *
+ * @author Esteban Dugueperoux
+ */
+public class Bugzilla_442178_Test extends AbstractCDOTest
+{
+ private String path;
+
+ private String resource1Path;
+
+ private String resource2Path;
+
+ private CDOView view;
+
+ private CDOResource resource1;
+
+ private CDOResource resource2;
+
+ private Company company;
+
+ private Category category1;
+
+ private Category category2;
+
+ private Category category3;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+
+ path = getResourcePath("folder");
+ resource1Path = path + "/resource1.model1";
+ resource2Path = path + "/resource2.model1";
+ resource1 = tx.createResource(resource1Path);
+ resource2 = tx.createResource(resource2Path);
+ company = getModel1Factory().createCompany();
+ category1 = getModel1Factory().createCategory();
+ company.getCategories().add(category1);
+ category2 = getModel1Factory().createCategory();
+ category1.getCategories().add(category2);
+ category3 = getModel1Factory().createCategory();
+ category2.getCategories().add(category3);
+ resource1.getContents().add(company);
+ resource2.getContents().add(category2);
+ tx.commit();
+ assertEquals(resource2, category2.eResource());
+ assertEquals(category1, category2.eContainer());
+ tx.close();
+ session.close();
+
+ session = openSession();
+ view = session.openView();
+
+ resource1 = view.getResource(resource1Path);
+ resource2 = view.getResource(resource2Path);
+ company = (Company)resource1.getContents().get(0);
+ category1 = company.getCategories().get(0);
+ category2 = (Category)resource2.getContents().get(0);
+ category3 = category2.getCategories().get(0);
+ assertEquals(resource2, category2.eResource());
+ assertEquals(category1, category2.eContainer());
+
+ assertEquals(resource2, category2.eResource());
+ assertEquals(category1, category2.eContainer());
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithCDOResourceFolder() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(resource1.getFolder(), path);
+ testCDORevisionUtil_GetResourceNodePath(resource2.getFolder(), path);
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithCDOResource() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(resource1, resource1Path);
+ testCDORevisionUtil_GetResourceNodePath(resource2, resource2Path);
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithRootCDOObject() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(company, resource1Path);
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithNotRootCDOObject() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(category1, resource1Path);
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithRootCDOObjectInFragmentedResource() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(category2, resource2Path);
+ }
+
+ public void testCDORevisionUtil_GetResourceNodePath_WithNotRootCDOObjectInFragmentedResource() throws Exception
+ {
+ testCDORevisionUtil_GetResourceNodePath(category3, resource2Path);
+ }
+
+ private void testCDORevisionUtil_GetResourceNodePath(EObject eObject, String expectedResourcePath)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(eObject);
+ String resourceNodePath = CDORevisionUtil.getResourceNodePath(cdoObject.cdoID(), view);
+ assertEquals(expectedResourcePath, resourceNodePath);
+ resourceNodePath = CDORevisionUtil.getResourceNodePath(cdoObject.cdoRevision(), view);
+ assertEquals(expectedResourcePath, resourceNodePath);
+ }
+}

Back to the top