Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2019-11-05 18:18:14 +0000
committerEike Stepper2019-11-05 18:18:14 +0000
commit808fd8e4ef743959c8b66c062c9a4b9491f5cf55 (patch)
treef921fe8ba8bb770599db99d50cdc89346994fe00 /plugins/org.eclipse.emf.cdo.common/src
parent9ca6a5b419a5212e3d2b06f414c6aff27fa032ba (diff)
downloadcdo-808fd8e4ef743959c8b66c062c9a4b9491f5cf55.tar.gz
cdo-808fd8e4ef743959c8b66c062c9a4b9491f5cf55.tar.xz
cdo-808fd8e4ef743959c8b66c062c9a4b9491f5cf55.zip
[547640] Support server-side commit conflict resolution
https://bugs.eclipse.org/bugs/show_bug.cgi?id=547640
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java158
1 files changed, 158 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java
index d02a783b43..e15277ba59 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java
@@ -15,8 +15,11 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import java.io.IOException;
import java.util.Map;
@@ -69,6 +72,8 @@ public interface CDOProtocol extends CDOProtocolConstants
private boolean clearResourcePathCache;
+ private boolean modifiedByServer;
+
private CDOLockChangeInfo lockChangeInfo;
public CommitNotificationInfo()
@@ -80,6 +85,7 @@ public interface CDOProtocol extends CDOProtocolConstants
senderID = in.readXInt();
commitInfo = in.readCDOCommitInfo();
clearResourcePathCache = in.readBoolean();
+ modifiedByServer = in.readBoolean();
securityImpact = in.readByte();
int size = in.readXInt();
@@ -107,6 +113,7 @@ public interface CDOProtocol extends CDOProtocolConstants
out.writeXInt(senderID);
out.writeCDOCommitInfo(commitInfo);
out.writeBoolean(clearResourcePathCache);
+ out.writeBoolean(modifiedByServer);
out.writeByte(securityImpact); // Must come after writeCDOCommitInfo()
// Must come after writeCDOCommitInfo()
@@ -217,6 +224,22 @@ public interface CDOProtocol extends CDOProtocolConstants
}
/**
+ * @since 4.8
+ */
+ public boolean isModifiedByServer()
+ {
+ return modifiedByServer;
+ }
+
+ /**
+ * @since 4.8
+ */
+ public void setModifiedByServer(boolean modifiedByServer)
+ {
+ this.modifiedByServer = modifiedByServer;
+ }
+
+ /**
* @since 4.6
*/
public CDOLockChangeInfo getLockChangeInfo()
@@ -232,4 +255,139 @@ public interface CDOProtocol extends CDOProtocolConstants
this.lockChangeInfo = lockChangeInfo;
}
}
+
+ /**
+ * @author Eike Stepper
+ * @since 4.8
+ */
+ public static final class CommitData
+ {
+ private final InternalCDORevision[] newObjects;
+
+ private final InternalCDORevisionDelta[] dirtyObjectDeltas;
+
+ private final CDOID[] detachedObjects;
+
+ public CommitData(InternalCDORevision[] newObjects, InternalCDORevisionDelta[] dirtyObjectDeltas, CDOID[] detachedObjects)
+ {
+ this.newObjects = newObjects;
+ this.dirtyObjectDeltas = dirtyObjectDeltas;
+ this.detachedObjects = detachedObjects;
+ }
+
+ public CommitData(CDODataInput in) throws IOException
+ {
+ newObjects = readNewObjects(in);
+ dirtyObjectDeltas = readDirtyObjectDeltas(in);
+ detachedObjects = readDetachedObjects(in);
+ }
+
+ private InternalCDORevision[] readNewObjects(CDODataInput in) throws IOException
+ {
+ InternalCDORevision[] result = null;
+
+ int n = in.readXInt();
+ if (n > 0)
+ {
+ result = new InternalCDORevision[n];
+ for (int i = 0; i < n; i++)
+ {
+ result[i] = (InternalCDORevision)in.readCDORevision();
+ }
+ }
+
+ return result;
+ }
+
+ private InternalCDORevisionDelta[] readDirtyObjectDeltas(CDODataInput in) throws IOException
+ {
+ InternalCDORevisionDelta[] result = null;
+
+ int n = in.readXInt();
+ if (n > 0)
+ {
+ result = new InternalCDORevisionDelta[n];
+ for (int i = 0; i < n; i++)
+ {
+ result[i] = (InternalCDORevisionDelta)in.readCDORevisionDelta();
+ }
+ }
+
+ return result;
+ }
+
+ private CDOID[] readDetachedObjects(CDODataInput in) throws IOException
+ {
+ CDOID[] result = null;
+
+ int n = in.readXInt();
+ if (n > 0)
+ {
+ result = new CDOID[n];
+ for (int i = 0; i < n; i++)
+ {
+ result[i] = in.readCDOID();
+ }
+ }
+
+ return result;
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ if (newObjects != null)
+ {
+ out.writeXInt(newObjects.length);
+ for (int i = 0; i < newObjects.length; i++)
+ {
+ out.writeCDORevision(newObjects[i], CDORevision.UNCHUNKED);
+ }
+ }
+ else
+ {
+ out.writeXInt(0);
+ }
+
+ if (dirtyObjectDeltas != null)
+ {
+ out.writeXInt(dirtyObjectDeltas.length);
+ for (int i = 0; i < dirtyObjectDeltas.length; i++)
+ {
+ out.writeCDORevisionDelta(dirtyObjectDeltas[i]);
+ }
+ }
+ else
+ {
+ out.writeXInt(0);
+ }
+
+ if (detachedObjects != null)
+ {
+ out.writeXInt(detachedObjects.length);
+ for (int i = 0; i < detachedObjects.length; i++)
+ {
+ out.writeCDOID(detachedObjects[i]);
+ }
+ }
+ else
+ {
+ out.writeXInt(0);
+ }
+ }
+
+ public InternalCDORevision[] getNewObjects()
+ {
+ return newObjects;
+ }
+
+ public InternalCDORevisionDelta[] getDirtyObjectDeltas()
+ {
+ return dirtyObjectDeltas;
+ }
+
+ public CDOID[] getDetachedObjects()
+ {
+ return detachedObjects;
+ }
+ }
}

Back to the top