summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-01-03 21:54:58 (EST)
committerCaspar De Groot2011-01-03 21:54:58 (EST)
commit6e84f4c752848dd5c579896677ebe6f4f437e067 (patch)
tree853cf6760d9b5b02feceec184537d54fb2d104de
parent2b5d9e2fe0bc667d6e4df8c625a04c1d65e0d868 (diff)
downloadcdo-6e84f4c752848dd5c579896677ebe6f4f437e067.zip
cdo-6e84f4c752848dd5c579896677ebe6f4f437e067.tar.gz
cdo-6e84f4c752848dd5c579896677ebe6f4f437e067.tar.bz2
[333326] Repo import into DBStore - various problems
https://bugs.eclipse.org/bugs/show_bug.cgi?id=333326 [333294] Repo not writeable after import https://bugs.eclipse.org/bugs/show_bug.cgi?id=333294
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/LongIDStore.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java26
7 files changed, 77 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
index 2887a84..84133da 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
@@ -95,13 +95,15 @@ public interface IClassMapping
* the accessor to use.
* @param revision
* the revision to write.
- * @param newRevision
+ * @param mapType
* <code>true</code> if the type of the object is supposed to be mapped, <code>false</code> otherwise.
+ * @param revise
+ * <code>true</code> if the previous revision is supposed to be revised, <code>false</code> otherwise.
* @param monitor
* the monitor to indicate progress.
* @since 4.0
*/
- public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean newRevision,
+ public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean mapType, boolean revise,
OMMonitor monitor);
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index cd8ddbe..d29c317 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -541,7 +541,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
monitor.begin(revisions.length);
for (InternalCDORevision revision : revisions)
{
- writeRevision(revision, newObjects.contains(revision.getID()), monitor.fork());
+ writeRevision(revision, newObjects.contains(revision.getID()), true, monitor.fork());
}
}
finally
@@ -551,7 +551,7 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
}
}
- protected void writeRevision(InternalCDORevision revision, boolean newRevision, OMMonitor monitor)
+ protected void writeRevision(InternalCDORevision revision, boolean mapType, boolean revise, OMMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -559,8 +559,9 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
}
EClass eClass = revision.getEClass();
+
IClassMapping mapping = getStore().getMappingStrategy().getClassMapping(eClass);
- mapping.writeRevision(this, revision, newRevision, monitor);
+ mapping.writeRevision(this, revision, mapType, revise, monitor);
}
/*
@@ -1175,7 +1176,25 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
public void rawStore(InternalCDORevision revision, OMMonitor monitor)
{
- writeRevision(revision, true, monitor);
+ CDOID id = revision.getID();
+
+ CDOClassifierRef classifierRef = getStore().getMappingStrategy().readObjectType(this, id);
+ boolean isFirstRevision = classifierRef == null;
+
+ if (!isFirstRevision)
+ {
+ EClass eClass = revision.getEClass();
+ boolean namesMatch = classifierRef.getClassifierName().equals(eClass.getName());
+ boolean packagesMatch = classifierRef.getPackageURI().equals(eClass.getEPackage().getNsURI());
+ if (!namesMatch || !packagesMatch)
+ {
+ throw new IllegalStateException();
+ }
+ }
+
+ writeRevision(revision, isFirstRevision, false, monitor);
+
+ getStore().ensureLastObjectID(id);
}
public void rawStore(byte[] id, long size, InputStream inputStream) throws IOException
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index 5076661..74e58d2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -464,7 +464,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
}
}
- public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean newRevision,
+ public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean mapType, boolean revise,
OMMonitor monitor)
{
Async async = null;
@@ -476,12 +476,12 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
{
async = monitor.forkAsync();
CDOID id = revision.getID();
- if (newRevision)
+ if (mapType)
{
long timeStamp = revision.getTimeStamp();
mappingStrategy.putObjectType(accessor, timeStamp, id, eClass);
}
- else
+ else if (revise)
{
long revised = revision.getTimeStamp() - 1;
reviseOldRevision(accessor, id, revision.getBranch(), revised);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
index 506072f..603902d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
@@ -742,7 +742,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
@Override
- public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean newRevision,
+ public void writeRevision(IDBStoreAccessor accessor, InternalCDORevision revision, boolean mapType, boolean revise,
OMMonitor monitor)
{
Async async = null;
@@ -754,14 +754,14 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
{
async = monitor.forkAsync();
CDOID id = revision.getID();
- if (newRevision)
+ if (mapType)
{
// put new objects into objectTypeMapper
long timeStamp = revision.getTimeStamp();
AbstractHorizontalMappingStrategy mappingStrategy = (AbstractHorizontalMappingStrategy)getMappingStrategy();
mappingStrategy.putObjectType(accessor, timeStamp, id, getEClass());
}
- else if (revision.getVersion() > CDOBranchVersion.FIRST_VERSION)
+ else if (revise && revision.getVersion() > CDOBranchVersion.FIRST_VERSION)
{
// if revision is not the first one, revise the old revision
long revised = revision.getTimeStamp() - 1;
@@ -1107,7 +1107,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
newRevision.adjustForCommit(accessor.getTransaction().getBranch(), created);
delta.apply(newRevision);
monitor.worked();
- writeRevision(accessor, newRevision, false, monitor.fork());
+ writeRevision(accessor, newRevision, false, true, monitor.fork());
}
finally
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
index 2681aa9..015f829 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
@@ -427,6 +427,11 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader
}
addRevision(list, revision, raw);
+
+ if (raw)
+ {
+ ensureLastObjectID(revision.getID());
+ }
}
public synchronized void addCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/LongIDStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/LongIDStore.java
index 430f341..908e5ba 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/LongIDStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/LongIDStore.java
@@ -105,4 +105,16 @@ public abstract class LongIDStore extends Store
long value = CDOIDUtil.getLong(id);
return value > nextLocalObjectID.get();
}
+
+ /**
+ * @since 4.0
+ */
+ public void ensureLastObjectID(CDOID id)
+ {
+ long addedID = CDOIDUtil.getLong(id);
+ if (addedID > getLastObjectID())
+ {
+ setLastObjectID(addedID);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
index 5742a57..807e292 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
@@ -28,9 +28,13 @@ import org.eclipse.emf.cdo.tests.model3.Polygon;
import org.eclipse.emf.cdo.tests.model5.Doctor;
import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -221,6 +225,28 @@ public class BackupTest extends AbstractCDOTest
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
CDOServerImporter.XML importer = new CDOServerImporter.XML(repo2);
importer.importRepository(bais);
+
+ useAfterImport("repo2");
+ }
+
+ private void useAfterImport(String repoName) throws CommitException
+ {
+ CDOSession session2 = openSession(repoName);
+ CDOTransaction transaction2 = session2.openTransaction();
+
+ // Read all repo contents
+ TreeIterator<EObject> iter = transaction2.getRootResource().getAllContents();
+ while (iter.hasNext())
+ {
+ iter.next();
+ }
+
+ // Add content from a new package
+ CDOResource resource = transaction2.createResource("/r1");
+ resource.getContents().add(getModel3Factory().createPolygon());
+ transaction2.commit();
+
+ session2.close();
}
public void testImportDate() throws Exception