Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-07-20 01:06:21 -0400
committerEike Stepper2009-07-20 01:06:21 -0400
commit8f84dfafb71b6634d1774f45773f994d7b81b8ea (patch)
tree4eba2b216bf9d1edb665021ef97935b7053fba0b /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction
parent6e9da438713b73fae130737624b01cead345bb4c (diff)
downloadcdo-8f84dfafb71b6634d1774f45773f994d7b81b8ea.tar.gz
cdo-8f84dfafb71b6634d1774f45773f994d7b81b8ea.tar.xz
cdo-8f84dfafb71b6634d1774f45773f994d7b81b8ea.zip
[283945] Prevent EObjects from being passed to a repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=283945
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java58
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java14
2 files changed, 62 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index 538e32fe0f..b27eb24f2a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -83,6 +83,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
/**
@@ -107,7 +108,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private long lastCommitTime = CDORevision.UNSPECIFIED_DATE;
- private int lastTemporaryID;
+ private AtomicInteger lastTemporaryID = new AtomicInteger();
private CDOTransactionStrategy transactionStrategy;
@@ -320,7 +321,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
public CDOIDTemp getNextTemporaryID()
{
- return CDOIDUtil.createTempObject(++lastTemporaryID);
+ return CDOIDUtil.createTempObject(lastTemporaryID.incrementAndGet());
}
/**
@@ -544,6 +545,27 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return null;
}
+ // TTT Map<InternalEObject, CDOIDDanglingImpl> danglingObjects = new HashMap<InternalEObject, CDOIDDanglingImpl>();
+ //
+ // @Override
+ // public CDOIDDangling convertDanglingObjectToID(InternalCDOObject source, EStructuralFeature feature,
+ // InternalEObject target)
+ // {
+ // CDOIDDanglingImpl id;
+ // synchronized (danglingObjects)
+ // {
+ // id = danglingObjects.get(target);
+ // if (id == null)
+ // {
+ // id = new CDOIDDanglingImpl(lastTemporaryID.incrementAndGet(), target);
+ // danglingObjects.put(target, id);
+ // }
+ // }
+ //
+ // id.addReference(source, feature);
+ // return id;
+ // }
+
/**
* @since 2.0
*/
@@ -595,6 +617,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
try
{
+ // TTT convertDanglingObjects();
getTransactionStrategy().commit(this, progressMonitor);
}
catch (TransactionException ex)
@@ -612,6 +635,35 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
commit(null);
}
+ // TTT private void convertDanglingObjects()
+ // {
+ // for (CDOIDDanglingImpl id : danglingObjects.values())
+ // {
+ //
+ // for (Reference reference : id.getReferences())
+ // {
+ // convertDanglingObject(reference.getSourceObject(), reference.getSourceFeature(), id);
+ // }
+ // }
+ // }
+ //
+ // private void convertDanglingObject(CDOObject object, EStructuralFeature feature, CDOIDDangling id)
+ // {
+ // InternalCDORevision revision = (InternalCDORevision)object.cdoRevision();
+ // Object value = revision.getValue(feature);
+ // if (value instanceof List<?>)
+ // {
+ // List<?> list = (List<?>)value;
+ // for (int i = 0; i < list.size(); i++)
+ // {
+ // if (list.get(i) == id)
+ // {
+ //
+ // }
+ // }
+ // }
+ // }
+
/**
* @since 2.0
*/
@@ -1148,7 +1200,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
firstSavepoint.getSharedDetachedObjects().clear();
dirty = false;
conflict = 0;
- lastTemporaryID = 0;
+ lastTemporaryID.set(0);
}
public Map<CDOID, CDOObject> getDirtyObjects()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
index d55c2dd1ac..29221b5e63 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
@@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalTempImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.messages.Messages;
@@ -54,9 +54,9 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
private InternalCDOCommitContext delegateCommitContext;
- private Map<CDOIDExternalTempImpl, InternalCDOTransaction> requestedIDs = new HashMap<CDOIDExternalTempImpl, InternalCDOTransaction>();
+ private Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> requestedIDs = new HashMap<CDOIDTempObjectExternalImpl, InternalCDOTransaction>();
- private Map<InternalCDOObject, CDOIDExternalTempImpl> objectToID = new HashMap<InternalCDOObject, CDOIDExternalTempImpl>();
+ private Map<InternalCDOObject, CDOIDTempObjectExternalImpl> objectToID = new HashMap<InternalCDOObject, CDOIDTempObjectExternalImpl>();
public CDOXACommitContextImpl(CDOXATransactionImpl manager, InternalCDOCommitContext commitContext)
{
@@ -99,7 +99,7 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
return delegateCommitContext.getTransaction();
}
- public Map<CDOIDExternalTempImpl, InternalCDOTransaction> getRequestedIDs()
+ public Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> getRequestedIDs()
{
return requestedIDs;
}
@@ -144,11 +144,11 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
{
CDOID id = getTransaction().provideCDOID(idOrObject);
- if (id instanceof CDOIDExternalTempImpl)
+ if (id instanceof CDOIDTempObjectExternalImpl)
{
if (idOrObject instanceof InternalEObject)
{
- CDOIDExternalTempImpl proxyTemp = (CDOIDExternalTempImpl)id;
+ CDOIDTempObjectExternalImpl proxyTemp = (CDOIDTempObjectExternalImpl)id;
if (!requestedIDs.containsKey(proxyTemp))
{
InternalCDOObject cdoObject = (InternalCDOObject)CDOUtil.getCDOObject((InternalEObject)idOrObject);
@@ -181,7 +181,7 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
{
public Object adjustReference(Object id)
{
- CDOIDExternalTempImpl externalID = objectToID.get(id);
+ CDOIDTempObjectExternalImpl externalID = objectToID.get(id);
if (externalID != null)
{
id = externalID;

Back to the top