Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/.settings/.api_filters6
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java20
5 files changed, 54 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.workspace/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.workspace/.settings/.api_filters
index eee50899ae..f7b8e37609 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.workspace/.settings/.api_filters
@@ -3,6 +3,12 @@
<resource path="src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java" type="org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl">
<filter id="572522506">
<message_arguments>
+ <message_argument value="CommitException"/>
+ <message_argument value="CDOWorkspaceImpl"/>
+ </message_arguments>
+ </filter>
+ <filter id="572522506">
+ <message_arguments>
<message_argument value="ReadOnlyException"/>
<message_argument value="CDOWorkspaceImpl"/>
</message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
index 517e724b1d..190487f9c7 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
@@ -87,6 +87,7 @@ import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ApplyChangeSetResult;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ChangeSetOutdatedException;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.Arrays;
@@ -359,7 +360,7 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
return revision;
}
- }, this, null);
+ }, this, null, false);
return transaction;
}
@@ -397,10 +398,17 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
CDOChangeSetData changes = getLocalChanges();
- ApplyChangeSetResult result = transaction.applyChangeSet(changes, base, this, head);
- if (!result.getIDMappings().isEmpty())
+ try
+ {
+ ApplyChangeSetResult result = transaction.applyChangeSet(changes, base, this, head, true);
+ if (!result.getIDMappings().isEmpty())
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
+ }
+ catch (ChangeSetOutdatedException ex)
{
- throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ throw new CommitException(ex);
}
// Attaching new objects is only supported for IDGenerationLocation.CLIENT
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 9755eea515..92f160cf1a 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
@@ -477,7 +477,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return null;
}
- return applyChangeSet(result, ancestorInfo, targetInfo, source).getChangeSetData();
+ return applyChangeSet(result, ancestorInfo, targetInfo, source, false).getChangeSetData();
}
private CDOChangeSet createChangeSet(Set<CDOID> ids, CDORevisionAvailabilityInfo startInfo,
@@ -496,7 +496,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
public synchronized ApplyChangeSetResult applyChangeSet(CDOChangeSetData changeSetData,
- CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, CDOBranchPoint source)
+ CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, CDOBranchPoint source,
+ boolean keepVersions) throws ChangeSetOutdatedException
{
ApplyChangeSetResult result = new ApplyChangeSetResult();
@@ -515,7 +516,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
// Changed objects
Map<CDOID, InternalCDORevision> oldRevisions = applyChangedObjects(changeSetData.getChangedObjects(),
- ancestorProvider, targetProvider, result.getChangeSetData().getChangedObjects());
+ ancestorProvider, targetProvider, keepVersions, result.getChangeSetData().getChangedObjects());
// Delta notifications
Collection<CDORevisionDelta> notificationDeltas = lastSavepoint.getRevisionDeltas().values();
@@ -612,7 +613,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
private Map<CDOID, InternalCDORevision> applyChangedObjects(List<CDORevisionKey> changedObjects,
- CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, List<CDORevisionKey> result)
+ CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, boolean keepVersions,
+ List<CDORevisionKey> result) throws ChangeSetOutdatedException
{
Map<CDOID, InternalCDORevision> oldRevisions = new HashMap<CDOID, InternalCDORevision>();
@@ -641,7 +643,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
InternalCDORevision goalRevision = ancestorRevision.copy();
goalRevision.setBranchPoint(this);
- goalRevision.setVersion(targetRevision.getVersion());
+ if (!keepVersions)
+ {
+ goalRevision.setVersion(targetRevision.getVersion());
+ }
+
goalRevision.setRevised(CDOBranchPoint.UNSPECIFIED_DATE);
ancestorGoalDelta.apply(goalRevision);
@@ -650,6 +656,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
if (!targetGoalDelta.isEmpty())
{
+ if (keepVersions && targetGoalDelta.getVersion() != ancestorRevision.getVersion())
+ {
+ throw new ChangeSetOutdatedException();
+ }
+
revisionDeltas.put(id, targetGoalDelta);
result.add(targetGoalDelta);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
index dfa0b2a037..b51bf74bcc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
@@ -176,8 +176,8 @@ public abstract class AbstractObjectConflictResolver extends AbstractConflictRes
CDOChangeSetData localChangeSet = transaction.getChangeSetData();
transaction.rollback();
- transaction.applyChangeSet(remoteChangeSet, transaction, transaction, transaction);
- transaction.applyChangeSet(localChangeSet, transaction, transaction, transaction);
+ transaction.applyChangeSet(remoteChangeSet, transaction, transaction, transaction, false);
+ transaction.applyChangeSet(localChangeSet, transaction, transaction, transaction, false);
}
private CDOChangeSetData createChangeSet(List<CDORevisionDelta> revisionDeltas)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
index 71550d6df7..6c96789061 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
@@ -107,7 +107,8 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
* {@link #merge(CDOBranchPoint, org.eclipse.emf.cdo.transaction.CDOMerger) merge} or if the merge was not in
* a {@link CDOBranch#isLocal() local} branch.
* @since 4.0
- * @deprecated Use {@link #applyChangeSet(CDOChangeSetData, CDORevisionProvider, CDORevisionProvider, CDOBranchPoint)}
+ * @deprecated Use
+ * {@link #applyChangeSet(CDOChangeSetData, CDORevisionProvider, CDORevisionProvider, CDOBranchPoint, boolean)}
*/
@Deprecated
public Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>> applyChangeSetData(
@@ -122,7 +123,8 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
* @since 4.1
*/
public ApplyChangeSetResult applyChangeSet(CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider,
- CDORevisionProvider targetProvider, CDOBranchPoint source);
+ CDORevisionProvider targetProvider, CDOBranchPoint source, boolean keepVersions)
+ throws ChangeSetOutdatedException;
/**
* @since 4.0
@@ -179,4 +181,18 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
return adjustedObjects;
}
}
+
+ /**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public static final class ChangeSetOutdatedException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public ChangeSetOutdatedException()
+ {
+ super("Change set is outdated");
+ }
+ }
}

Back to the top