Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-10-09 07:05:23 -0400
committerSimon McDuff2008-10-09 07:05:23 -0400
commit17adfc98b257ca7aafc0f227ac4ccb526e7d3c16 (patch)
tree5fbdd803226c8fa9162b015c77c25bd79862e095 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parent2897655c3f0fcc5d76e68a20a2c0134a7b2e7940 (diff)
downloadcdo-17adfc98b257ca7aafc0f227ac4ccb526e7d3c16.tar.gz
cdo-17adfc98b257ca7aafc0f227ac4ccb526e7d3c16.tar.xz
cdo-17adfc98b257ca7aafc0f227ac4ccb526e7d3c16.zip
[248771] CDOObject id, state, view and revision are not properly updated after CDOResource.delete()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248771
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index 436ae1247d..254289eee5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -14,23 +14,36 @@ package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.CDOViewSet;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.InvalidObjectException;
+import org.eclipse.emf.cdo.util.ObjectNotFoundException;
import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
import org.eclipse.emf.internal.cdo.CDOMetaWrapper;
+import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
+import org.eclipse.emf.internal.cdo.CDOViewSetImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
+import org.eclipse.net4j.util.ImplementationError;
+
import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
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.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import java.util.Collection;
import java.util.Iterator;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -165,6 +178,23 @@ public final class FSMUtil
// return getLegacyWrapper(object.eReadListeners());
}
+ public static void validate(CDOObject object, CDORevision revision)
+ {
+ if (revision == null)
+ {
+ CDOStateMachine.INSTANCE.detachRemote((InternalCDOObject)object);
+ throw new InvalidObjectException(object.cdoID());
+ }
+ }
+
+ public static void validate(CDOID id, CDORevision revision)
+ {
+ if (revision == null)
+ {
+ throw new ObjectNotFoundException(id);
+ }
+ }
+
/**
* Similar to {@link EcoreUtil#getAllProperContents(Resource, boolean)} except gives only one depth
*/
@@ -244,4 +274,34 @@ public final class FSMUtil
{
return iterator(instances.iterator(), view);
}
+
+ public static CDOViewSet prepareResourceSet(ResourceSet resourceSet)
+ {
+ CDOViewSetImpl viewSet = null;
+ synchronized (resourceSet)
+ {
+ viewSet = (CDOViewSetImpl)CDOUtil.getViewSet(resourceSet);
+
+ if (viewSet == null)
+ {
+ if (resourceSet instanceof ResourceSetImpl)
+ {
+ Map<URI, Resource> resourceMap = null;
+ ResourceSetImpl rs = (ResourceSetImpl)resourceSet;
+ resourceMap = rs.getURIResourceMap();
+ rs.setURIResourceMap(new ProxyResolverURIResourceMap(null, resourceMap));
+ }
+ else
+ {
+ throw new ImplementationError("Not a " + ResourceSetImpl.class.getName() + ": "
+ + resourceSet.getClass().getName());
+ }
+
+ viewSet = new CDOViewSetImpl();
+ resourceSet.eAdapters().add(viewSet);
+ }
+ }
+
+ return viewSet;
+ }
}

Back to the top