Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java39
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java114
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java54
9 files changed, 142 insertions, 137 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 c571a7666c..7905de7f55 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
@@ -271,7 +271,8 @@ public class MEMStore extends LongIDStore implements IMEMStore
if (ObjectUtil.equals(revisionFolder, folderID))
{
String revisionName = (String)revision.getData().get(getResourceNameFeature(), 0);
- boolean match = exactMatch ? revisionName.equals(name) : revisionName.startsWith(name);
+ boolean match = exactMatch || 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/ComplexTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
index 6ac73b1061..3e10fa9504 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ComplexTest.java
@@ -478,7 +478,6 @@ public class ComplexTest extends AbstractCDOTest
public void testMultipleTransactions3()
{
-
CDOTransaction transaction1 = session.openTransaction();
String resource1path = "/resources/3/" + uniqueCounter;
CDOResource resource1 = transaction1.createResource(resource1path);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java
index a6eb0fd28c..beda838f38 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: CDOResourceNode.java,v 1.1.2.1 2008-10-14 20:39:30 estepper Exp $
+ * $Id: CDOResourceNode.java,v 1.1.2.2 2008-10-15 19:35:04 estepper Exp $
*/
package org.eclipse.emf.cdo.eresource;
@@ -28,6 +28,24 @@ import org.eclipse.emf.cdo.CDOObject;
public interface CDOResourceNode extends CDOObject
{
/**
+ * @ADDED
+ * @since 2.0
+ */
+ public static final String ROOT_PATH = "/";
+
+ /**
+ * @ADDED
+ * @since 2.0
+ */
+ public static final String ROOT_NAME = null;
+
+ /**
+ * @ADDED
+ * @since 2.0
+ */
+ public boolean isRoot();
+
+ /**
* Returns the value of the '<em><b>Folder</b></em>' container reference. It is bidirectional and its opposite is '
* {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder#getNodes <em>Nodes</em>}'. <!-- begin-user-doc -->
* <p>
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java
index e05e84bdc1..b7be97e353 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java
@@ -59,6 +59,7 @@ public class CDOResourceFactoryImpl implements Resource.Factory, CDOResourceFact
// Important: Set URI *after* registration with the view!
resource.setURI(newURI);
+ resource.setRoot(CDOURIUtil.SEGMENT_SEPARATOR.equals(path));
resource.setExisting(isGetResource());
return resource;
}
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 9abc18d3e2..71d737edf0 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
@@ -2,7 +2,7 @@
* <copyright>
* </copyright>
*
- * $Id: CDOResourceFolderImpl.java,v 1.1.2.2 2008-10-15 17:09:42 estepper Exp $
+ * $Id: CDOResourceFolderImpl.java,v 1.1.2.3 2008-10-15 19:35:04 estepper Exp $
*/
package org.eclipse.emf.cdo.eresource.impl;
@@ -10,11 +10,8 @@ import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
-
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.resource.Resource;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>CDO Resource Folder</b></em>'.
@@ -40,22 +37,30 @@ public class CDOResourceFolderImpl extends CDOResourceNodeImpl implements CDORes
super();
}
- @Override
- public Resource.Internal eDirectResource()
+ /**
+ * @ADDED
+ */
+ public boolean isRoot()
{
- if (FSMUtil.isTransient(this))
- {
- return super.eDirectResource();
- }
-
- if (eStore().getContainer(this) == null)
- {
- return cdoView().getResourceView();
- }
-
- return null;
+ return false;
}
+ // @Override
+ // public Resource.Internal eDirectResource()
+ // {
+ // if (FSMUtil.isTransient(this))
+ // {
+ // return super.eDirectResource();
+ // }
+ //
+ // if (eStore().getContainer(this) == null)
+ // {
+ // return cdoView().getRootResource();
+ // }
+ //
+ // return null;
+ // }
+
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index 0f14e43b45..c4ae2dc845 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -51,14 +51,13 @@ import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.emf.ecore.util.NotifyingInternalEListImpl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
/**
@@ -94,6 +93,11 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
/**
* @ADDED
*/
+ private boolean root;
+
+ /**
+ * @ADDED
+ */
private boolean existing;
/**
@@ -138,6 +142,19 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
}
/**
+ * @since 2.0
+ */
+ public boolean isRoot()
+ {
+ return root;
+ }
+
+ void setRoot(boolean root)
+ {
+ this.root = root;
+ }
+
+ /**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
@@ -832,14 +849,14 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
}
/**
- * TODO Change superclass to NotifyingInternalEListImpl when EMF 2.3 is out of maintenance TODO Reuse
- * {@link ResourceImpl.ContentsEList}!!! --> Bugzilla!
+ * TODO Change superclass to NotifyingInternalEListImpl when EMF 2.3 is out of maintenance
+ * <p>
+ * TODO Reuse {@link ResourceImpl.ContentsEList}!!! --> Bugzilla!
*
* @ADDED
* @author Eike Stepper
*/
- protected class TransientContents<E extends Object & EObject> extends NotifyingListImpl<E> implements
- InternalEList<E>
+ protected class TransientContents<E extends Object & EObject> extends NotifyingInternalEListImpl<E>
{
private static final long serialVersionUID = 1L;
@@ -934,66 +951,6 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
return eObject.eSetResource(null, notifications);
}
- public boolean basicContains(Object object)
- {
- return super.contains(object);
- }
-
- public boolean basicContainsAll(Collection<?> collection)
- {
- return super.containsAll(collection);
- }
-
- public int basicIndexOf(Object object)
- {
- return super.indexOf(object);
- }
-
- public int basicLastIndexOf(Object object)
- {
- return super.lastIndexOf(object);
- }
-
- public Object[] basicToArray()
- {
- return super.toArray();
- }
-
- public <T> T[] basicToArray(T[] array)
- {
- return super.toArray(array);
- }
-
- @Override
- public Iterator<E> basicIterator()
- {
- return super.basicIterator();
- }
-
- @Override
- public ListIterator<E> basicListIterator()
- {
- return super.basicListIterator();
- }
-
- @Override
- public ListIterator<E> basicListIterator(int index)
- {
- return super.basicListIterator(index);
- }
-
- @Override
- public List<E> basicList()
- {
- return super.basicList();
- }
-
- @Override
- protected Object[] newData(int capacity)
- {
- return new EObject[capacity];
- }
-
@Override
protected void didAdd(int index, E object)
{
@@ -1018,8 +975,29 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
@Override
protected void didClear(int oldSize, Object[] oldData)
{
- super.didClear(oldSize, oldData);
- // modified();
+ if (oldSize == 0)
+ {
+ loaded();
+ }
+ else
+ {
+ super.didClear(oldSize, oldData);
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected void loaded()
+ {
+ if (!isLoaded())
+ {
+ Notification notification = setLoaded(true);
+ if (notification != null)
+ {
+ eNotify(notification);
+ }
+ }
}
protected void modified()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
index f30a2a6c2e..04fef03b40 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
@@ -45,11 +45,6 @@ public class CDOURIUtil
{
throw new InvalidURIException(uri);
}
-
- if (!uri.hasAbsolutePath())
- {
- throw new InvalidURIException(uri);
- }
}
public static String extractRepositoryUUID(URI uri)
@@ -87,7 +82,13 @@ public class CDOURIUtil
public static String extractResourcePath(URI uri) throws InvalidURIException
{
validateURI(uri);
- return uri.path();
+ String path = uri.path();
+ if (path == null)
+ {
+ return SEGMENT_SEPARATOR;
+ }
+
+ return path;
}
/**
@@ -112,12 +113,16 @@ public class CDOURIUtil
stringBuilder.append(repositoryUUID);
}
- if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
+ if (!SEGMENT_SEPARATOR.equals(path))
{
- stringBuilder.append(SEGMENT_SEPARATOR_CHAR);
+ if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR)
+ {
+ stringBuilder.append(SEGMENT_SEPARATOR_CHAR);
+ }
+
+ stringBuilder.append(path);
}
- stringBuilder.append(path);
return URI.createURI(stringBuilder.toString());
}
@@ -149,7 +154,8 @@ public class CDOURIUtil
public static List<String> analyzePath(URI uri)
{
- return analyzePath(extractResourcePath(uri));
+ String path = extractResourcePath(uri);
+ return analyzePath(path);
}
public static List<String> analyzePath(String path)
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 bd1a27c1ae..8508f9db7c 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
@@ -176,6 +176,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return CDOIDUtil.createTempObject(++lastTemporaryID);
}
+ @Override
+ protected CDOResourceImpl createRootResource()
+ {
+ return (CDOResourceImpl)getOrCreateResource(CDOResourceNode.ROOT_PATH);
+ }
+
public CDOResource createResource(String path)
{
checkOpen();
@@ -224,7 +230,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
URI uri = resource.getURI();
List<String> names = CDOURIUtil.analyzePath(uri);
- String resourceName = names.remove(names.size() - 1);
+ String resourceName = names.isEmpty() ? null : names.remove(names.size() - 1);
CDOResourceFolder folder = null;
for (String name : names)
@@ -260,7 +266,14 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
newNode.setName(name);
if (folder == null)
{
- CDOStateMachine.INSTANCE.attach((InternalCDOObject)newNode, this);
+ if (newNode.isRoot())
+ {
+ CDOStateMachine.INSTANCE.attach((InternalCDOObject)newNode, this);
+ }
+ else
+ {
+ getRootResource().getContents().add(newNode);
+ }
}
else
{
@@ -321,7 +334,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
* @since 2.0
*/
@Override
- protected CDOID getRootResourceNodeByRevision(String name)
+ protected CDOID getRootOrTopLevelResourceNodeID(String name)
{
if (dirty)
{
@@ -344,7 +357,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- CDOID id = super.getRootResourceNodeByRevision(name);
+ CDOID id = super.getRootOrTopLevelResourceNodeID(name);
if (getLastSavepoint().getAllDetachedObjects().containsKey(id))
{
throw new CDOException("Root resource node " + name + " doesn't exist");
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 d61ae072b4..185dede713 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
@@ -37,7 +37,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
@@ -69,7 +68,6 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -115,7 +113,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
private ReentrantLock lock = new ReentrantLock(true);
- private Resource.Internal resourceView;
+ private CDOResourceImpl rootResource;
@ExcludeFromDump
private transient CDOID lastLookupID;
@@ -181,17 +179,23 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
/**
* @since 2.0
*/
- public synchronized Resource.Internal getResourceView()
+ public synchronized CDOResourceImpl getRootResource()
{
- if (resourceView == null)
+ if (rootResource == null)
{
- CDOResourceFactory factory = getViewSet().getResourceFactory();
- resourceView = (CDOResourceImpl)factory.createResource(CDOURIUtil.createResourceURI(this, "VIEW"));
- ((InternalCDOObject)resourceView).cdoInternalSetView(this);
- ((InternalCDOObject)resourceView).cdoInternalSetState(CDOState.NEW);
+ rootResource = createRootResource();
}
- return resourceView;
+ return rootResource;
+ }
+
+ /**
+ * @return
+ * @since 2.0
+ */
+ protected CDOResourceImpl createRootResource()
+ {
+ return (CDOResourceImpl)getResource(CDOResourceNode.ROOT_PATH);
}
/**
@@ -373,7 +377,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
List<String> names = CDOURIUtil.analyzePath(path);
for (String name : names)
{
- folderID = getResourceNodeByRevision(folderID, name);
+ folderID = getResourceNodeID(folderID, name);
if (folderID == null)
{
throw new CDOException("CAnnot find " + name);
@@ -391,7 +395,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
try
{
- CDOID id = getResourceNodeByRevision(folderID, name);
+ CDOID id = getResourceNodeID(folderID, name);
return (CDOResourceNode)getObject(id);
}
catch (CDOException ex)
@@ -407,7 +411,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
/**
* @since 2.0
*/
- protected CDOID getResourceNodeByRevision(CDOID folderID, String name)
+ protected CDOID getResourceNodeID(CDOID folderID, String name)
{
if (name == null)
{
@@ -416,7 +420,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
if (folderID == null)
{
- return getRootResourceNodeByRevision(name);
+ return getRootOrTopLevelResourceNodeID(name);
}
InternalCDORevision folderRevision = getLocalRevision(folderID);
@@ -446,30 +450,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
throw new CDOException("Node " + name + " not found");
}
- // /**
- // * @return never <code>null</code>
- // * @since 2.0
- // */
- // protected CDOResourceNode getRootResourceNode(String name)
- // {
- // List<CDOResourceNode> nodes = queryResources(null, name, true);
- // if (nodes.isEmpty())
- // {
- // throw new CDOException("No root ResourceNode with the name " + name);
- // }
- //
- // if (nodes.size() > 1)
- // {
- // throw new ImplementationError("Duplicate root ResourceNodes with the same name");
- // }
- //
- // return nodes.get(0);
- // }
-
/**
* @since 2.0
*/
- protected CDOID getRootResourceNodeByRevision(String name)
+ protected CDOID getRootOrTopLevelResourceNodeID(String name)
{
CDOQuery resourceQuery = createResourcesQuery(null, name, true);
resourceQuery.setMaxResults(1);

Back to the top