Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-03-09 07:40:08 +0000
committerEike Stepper2008-03-09 07:40:08 +0000
commit042bfe74588b9352ce5f4c5176b036ba630e23f7 (patch)
tree3a15dbae62150ce0635df1b80c3505778d521a71
parent4abd6d4e7f771bcd36b89034f28592fafd397c2d (diff)
downloadcdo-042bfe74588b9352ce5f4c5176b036ba630e23f7.tar.gz
cdo-042bfe74588b9352ce5f4c5176b036ba630e23f7.tar.xz
cdo-042bfe74588b9352ce5f4c5176b036ba630e23f7.zip
[217117] Develop a HibernateStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=217117
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java74
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java16
8 files changed, 124 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml b/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
index 1793ff4b87..9a8fc9a550 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
@@ -24,9 +24,5 @@
genModel = "model/model1.genmodel"/>
</extension>
- <extension point="org.eclipse.emf.cdo.persistent_package">
- <package
- uri = "http://www.eclipse.org/emf/CDO/tests/model1/1.0.0"/>
- </extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index 476b2fdd11..cf8ee60400 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -38,6 +38,7 @@ public class AllTests
suite.addTestSuite(PackageRegistryTest.class);
suite.addTestSuite(RevisionDeltaTest.class);
suite.addTestSuite(IndexReconstructionTest.class);
+ suite.addTestSuite(NoLegacyTest.class);
// TODO suite.addTestSuite(GeneratedEcoreTest.class);
// $JUnit-END$
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java
new file mode 100644
index 0000000000..07f9cb2804
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
+
+import org.eclipse.emf.ecore.xml.type.ProcessingInstruction;
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+/**
+ * @author Eike Stepper
+ */
+public class NoLegacyTest extends AbstractCDOTest
+{
+ public void testOpenLegacySession() throws Exception
+ {
+ CDOSession session = null;
+
+ try
+ {
+ session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, false);
+ fail("LegacySystemNotAvailableException expected");
+ }
+ catch (LegacySystemNotAvailableException ex)
+ {
+ }
+ finally
+ {
+ if (session != null)
+ {
+ session.close();
+ }
+ }
+ }
+
+ public void testAttachLegacyObject() throws Exception
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
+ session.getPackageRegistry().putEPackage(XMLTypePackage.eINSTANCE);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+
+ ProcessingInstruction pi = XMLTypeFactory.eINSTANCE.createProcessingInstruction();
+ pi.setData("data");
+ pi.setTarget("target");
+
+ try
+ {
+ resource.getContents().add(pi);
+ fail("LegacySystemNotAvailableException expected");
+ }
+ catch (LegacySystemNotAvailableException ex)
+ {
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java
new file mode 100644
index 0000000000..c9583104d1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.util;
+
+/**
+ * @author Eike Stepper
+ */
+public class LegacySystemNotAvailableException extends RuntimeException
+{
+ public static final String LEGACY_SYSTEM_NOT_AVAILABLE = "Legacy system not available";
+
+ private static final long serialVersionUID = 1L;
+
+ public LegacySystemNotAvailableException()
+ {
+ super(LEGACY_SYSTEM_NOT_AVAILABLE);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 7a8b9cdb3f..6e3c2c6758 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -28,6 +28,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
@@ -171,7 +172,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
checkInactive();
if (!disableLegacyObjects && !FSMUtil.isLegacySystemAvailable())
{
- throw new IllegalArgumentException(FSMUtil.LEGACY_SYSTEM_NOT_AVAILABLE);
+ throw new LegacySystemNotAvailableException();
}
this.disableLegacyObjects = disableLegacyObjects;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index d8d3351f45..d9d870b623 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -11,6 +11,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDORevisionManager;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
@@ -18,6 +19,7 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.protocol.revision.delta.CDOFeatureDelta;
@@ -345,7 +347,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, ResourceAndView data)
{
CDOTransactionImpl transaction = data.view.toTransaction();
- CDORevisionManagerImpl revisionManager = transaction.getSession().getRevisionManager();
+ CDORevisionManager revisionManager = transaction.getSession().getRevisionManager();
// Prepare object
CDOID id = transaction.getNextTemporaryID();
@@ -355,8 +357,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
changeState(object, CDOState.PREPARED);
// Create new revision
- InternalCDORevision revision = (InternalCDORevision)CDORevisionUtil
- .create(revisionManager, object.cdoClass(), id);
+ CDOClass cdoClass = object.cdoClass();
+ InternalCDORevision revision = (InternalCDORevision)CDORevisionUtil.create(revisionManager, cdoClass, id);
revision.setVersion(-1);
revision.setResourceID(data.resource.cdoID());
object.cdoInternalSetRevision(revision);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index 039f9bdad4..7f283d0763 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -551,8 +551,10 @@ public final class CDOStore implements EStore
private void handleContainmentAdd(InternalCDOObject container, Object value)
{
- InternalCDOObject contained = getCDOObject(value);
CDOViewImpl containerView = (CDOViewImpl)container.cdoView();
+ InternalCDOObject contained = getCDOObject(value);
+ FSMUtil.checkLegacySystemAvailability(containerView.getSession(), contained);
+
CDOViewImpl containedView = (CDOViewImpl)contained.cdoView();
if (containedView != containerView)
{
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 48315f396d..e3f5d2ec08 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
@@ -11,11 +11,14 @@
package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
+import org.eclipse.emf.internal.cdo.CDOLegacyImpl;
import org.eclipse.emf.internal.cdo.CDOMetaImpl;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -37,8 +40,6 @@ import java.util.Iterator;
*/
public final class FSMUtil
{
- public static final String LEGACY_SYSTEM_NOT_AVAILABLE = "Legacy system not available";
-
private static Method adaptLegacyMethod = initAdaptLegacyMethod();
private FSMUtil()
@@ -64,7 +65,7 @@ public final class FSMUtil
{
}
- OM.LOG.info(LEGACY_SYSTEM_NOT_AVAILABLE);
+ OM.LOG.info(LegacySystemNotAvailableException.LEGACY_SYSTEM_NOT_AVAILABLE);
return null;
}
@@ -73,6 +74,15 @@ public final class FSMUtil
return adaptLegacyMethod != null;
}
+ public static void checkLegacySystemAvailability(CDOSession session, CDOObject object)
+ throws LegacySystemNotAvailableException
+ {
+ if (session.isDisableLegacyObjects() && object instanceof CDOLegacyImpl)
+ {
+ throw new LegacySystemNotAvailableException();
+ }
+ }
+
public static boolean isTransient(CDOObject object)
{
CDOState state = object.cdoState();

Back to the top