Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-15 16:06:43 -0400
committerEike Stepper2008-10-15 16:06:43 -0400
commitc66eaef4ae5b96497f5df43c5724995b0514a808 (patch)
tree887c615bf991968b4cf826e8084c9f7a54b2c67d
parent3ef4cd444ef6ffd5be15fe9f3ea8289a1981845b (diff)
downloadcdo-c66eaef4ae5b96497f5df43c5724995b0514a808.tar.gz
cdo-c66eaef4ae5b96497f5df43c5724995b0514a808.tar.xz
cdo-c66eaef4ae5b96497f5df43c5724995b0514a808.zip
[249847] Store resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249847
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java68
4 files changed, 39 insertions, 47 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
index 8d6685f4f5..1255b8ea30 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
@@ -273,8 +273,8 @@ public class MEMStore extends LongIDStore implements IMEMStore
if (CDOIDUtil.equals(revisionFolder, folderID))
{
String revisionName = (String)revision.getData().get(getResourceNameFeature(), 0);
- boolean match = exactMatch || name == null ? ObjectUtil.equals(revisionName, name) : revisionName
- .startsWith(name);
+ boolean match = exactMatch || revisionName == null || name == null ? ObjectUtil
+ .equals(revisionName, name) : revisionName.startsWith(name);
if (match)
{
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 cd783f8618..759db2ab2d 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
@@ -118,7 +118,7 @@ public class ResourceTest extends AbstractCDOTest
assertActive(resource);
transaction.commit();
- Assert.assertEquals(1, rset.getResources().size());
+ Assert.assertEquals(2, rset.getResources().size());
Assert.assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
transaction.close();
@@ -158,18 +158,18 @@ public class ResourceTest extends AbstractCDOTest
tobeRemoved.add(resource1);
tobeRemoved.add(resource3);
- assertEquals(3, transaction.getResourceSet().getResources().size());
+ assertEquals(4, transaction.getResourceSet().getResources().size());
transaction.getResourceSet().getResources().removeAll(tobeRemoved);
- assertEquals(1, transaction.getResourceSet().getResources().size());
+ assertEquals(2, transaction.getResourceSet().getResources().size());
assertEquals(null, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
assertEquals(null, transaction.getResourceSet().getResource(resource3.getURI(), false));
transaction.getResourceSet().getResources().addAll(tobeRemoved);
- assertEquals(3, transaction.getResourceSet().getResources().size());
+ assertEquals(4, transaction.getResourceSet().getResources().size());
assertEquals(resource1, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
assertEquals(resource3, transaction.getResourceSet().getResource(resource3.getURI(), false));
@@ -192,11 +192,11 @@ public class ResourceTest extends AbstractCDOTest
tobeRemoved.add(resource1);
tobeRemoved.add(resource3);
- assertEquals(3, transaction.getResourceSet().getResources().size());
+ assertEquals(4, transaction.getResourceSet().getResources().size());
transaction.getResourceSet().getResources().removeAll(tobeRemoved);
- assertEquals(1, transaction.getResourceSet().getResources().size());
+ assertEquals(2, transaction.getResourceSet().getResources().size());
assertEquals(null, transaction.getResourceSet().getResource(resource1.getURI(), false));
assertEquals(resource2, transaction.getResourceSet().getResource(resource2.getURI(), false));
assertEquals(null, transaction.getResourceSet().getResource(resource3.getURI(), false));
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index d2e0344bca..c31a8c5b78 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -196,7 +196,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
try
{
- CDOID id = getResourceIDByRevision(path);
+ CDOID id = getResourceID(path);
if (id != null && !id.isNull())
{
return (CDOResource)getObject(id);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 185dede713..a74d207315 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -321,7 +321,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
try
{
- getResourceIDByRevision(path);
+ getResourceID(path);
return true;
}
catch (Exception ex)
@@ -339,34 +339,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
return new CDOQueryImpl(this, language, queryString);
}
- // protected CDOID getResourceID(String path)
- // {
- // if (StringUtil.isEmpty(path))
- // {
- // throw new IllegalArgumentException("path");
- // }
- //
- // CDOResourceNode node = null;
- // CDOID folderID = null;
- // List<String> names = CDOURIUtil.analyzePath(path);
- // for (String name : names)
- // {
- // node = getResourceNode(folderID, name);
- // folderID = node.cdoID();
- // }
- //
- // if (node instanceof CDOResource)
- // {
- // return folderID;
- // }
- //
- // throw new CDOException("Path does not denote a resource: " + path);
- // }
-
/**
* @since 2.0
*/
- protected CDOID getResourceIDByRevision(String path)
+ protected CDOID getResourceID(String path)
{
if (StringUtil.isEmpty(path))
{
@@ -374,19 +350,32 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
}
CDOID folderID = null;
- List<String> names = CDOURIUtil.analyzePath(path);
- for (String name : names)
+ if (CDOURIUtil.SEGMENT_SEPARATOR.equals(path))
+ {
+ folderID = getResourceID(null, null);
+ }
+ else
{
- folderID = getResourceNodeID(folderID, name);
- if (folderID == null)
+ List<String> names = CDOURIUtil.analyzePath(path);
+ for (String name : names)
{
- throw new CDOException("CAnnot find " + name);
+ folderID = getResourceID(folderID, name);
}
}
return folderID;
}
+ private CDOID getResourceID(CDOID folderID, String name)
+ {
+ folderID = getResourceNodeID(folderID, name);
+ if (folderID == null)
+ {
+ throw new CDOException("Can not find " + name);
+ }
+ return folderID;
+ }
+
/**
* @return never <code>null</code>
* @since 2.0
@@ -413,15 +402,14 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
*/
protected CDOID getResourceNodeID(CDOID folderID, String name)
{
- if (name == null)
- {
- throw new IllegalArgumentException("name");
- }
-
if (folderID == null)
{
return getRootOrTopLevelResourceNodeID(name);
}
+ else if (name == null)
+ {
+ throw new IllegalArgumentException("name");
+ }
InternalCDORevision folderRevision = getLocalRevision(folderID);
CDOResourcePackage resourcePackage = getSession().getPackageManager().getCDOResourcePackage();
@@ -805,11 +793,15 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
CDOResourceNodeClass resourceNodeClass = resourcePackage.getCDOResourceNodeClass();
CDONameFeature nameFeature = resourceNodeClass.getCDONameFeature();
- // CDOID folderID = (CDOID)revision.getData().get(folderFeature, 0);
CDOID folderID = (CDOID)revision.getData().getContainerID();
String name = (String)revision.getData().get(nameFeature, 0);
if (folderID == null || folderID.isNull())
{
+ if (name == null)
+ {
+ return CDOURIUtil.SEGMENT_SEPARATOR;
+ }
+
return name;
}
@@ -984,7 +976,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
try
{
- CDOID id = getResourceIDByRevision(path);
+ CDOID id = getResourceID(path);
resource.cdoInternalSetID(id);
resource.cdoInternalSetResource(resource);
registerObject(resource);

Back to the top