Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-30 03:44:05 -0400
committerEike Stepper2008-10-30 03:44:05 -0400
commit811c655c3f222376c0fa92c7a995a2ba9fcf1c35 (patch)
treea5f3a0e81cf3df0467b364f3efa052e3ee4d68e6
parent71eff24bb817f62556c4b09b49981bc359f9d970 (diff)
downloadcdo-811c655c3f222376c0fa92c7a995a2ba9fcf1c35.tar.gz
cdo-811c655c3f222376c0fa92c7a995a2ba9fcf1c35.tar.xz
cdo-811c655c3f222376c0fa92c7a995a2ba9fcf1c35.zip
[251307] [Hibernate] Implement resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251307
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/CDO AllTests (Hibernate).launch19
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java7
23 files changed, 167 insertions, 138 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
index 32bb5cc429..948edf9dc6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
@@ -45,6 +45,14 @@ public final class CDOIDUtil
{
}
+ /**
+ * @since 2.0
+ */
+ public static boolean isNull(CDOID id)
+ {
+ return id == null || id.isNull();
+ }
+
public static long getLong(CDOID id)
{
if (id == null)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
index 397e0559d1..ee3ecd087d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.common.CDODataInput;
import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOClassRef;
import org.eclipse.emf.cdo.common.model.CDOFeature;
@@ -78,7 +79,7 @@ public class CDORevisionImpl implements InternalCDORevision
throw new IllegalArgumentException("CDOClass is abstract: " + cdoClass);
}
- if (id == null || id.isNull())
+ if (CDOIDUtil.isNull(id))
{
throw new IllegalArgumentException("CDIID is null");
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
index 567a885c23..7b4010ae55 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
@@ -106,11 +106,6 @@ public interface IMappingStrategy
/**
* @since 2.0
*/
- public CDOID readResourceID(IDBStoreAccessor accessor, CDOID folderID, String name, long timeStamp);
-
- /**
- * @since 2.0
- */
public void queryResources(IDBStoreAccessor accessor, IStoreAccessor.QueryResourcesContext context);
/**
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 ba6d4d9ad8..699050f5ca 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
@@ -327,12 +327,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
return revision;
}
- public CDOID readResourceID(CDOID folderID, String name, long timeStamp)
- {
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- return mappingStrategy.readResourceID(this, folderID, name, timeStamp);
- }
-
/**
* @since 2.0
*/
@@ -489,7 +483,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
String name = feature.getName();
int featureID = feature.getFeatureID();
int type = feature.getType().getTypeID();
- CDOClassProxy reference = (feature).getReferenceTypeProxy();
+ CDOClassProxy reference = feature.getReferenceTypeProxy();
String packageURI = reference == null ? null : reference.getPackageURI();
int classifierID = reference == null ? 0 : reference.getClassifierID();
boolean many = feature.isMany();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
index ee399334a5..f31b86275e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalClassMapping.java
@@ -16,8 +16,8 @@ import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.IPackageManager;
+import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.IMappingStrategy;
/**
* @author Eike Stepper
@@ -50,18 +50,17 @@ public class HorizontalClassMapping extends ClassMapping
@Override
protected void checkDuplicateResources(IDBStoreAccessor accessor, CDORevision revision) throws IllegalStateException
{
- // If auditing is not supported this is checked by a table index (see constructor)
- IMappingStrategy mappingStrategy = getMappingStrategy();
- if (mappingStrategy.getStore().getRepository().isSupportingAudits())
+ IRepository repository = getMappingStrategy().getStore().getRepository();
+ if (repository.isSupportingAudits())
{
- IPackageManager packageManager = mappingStrategy.getStore().getRepository().getPackageManager();
+ IPackageManager packageManager = repository.getPackageManager();
CDOResourceNodeClass resourceNodeClass = packageManager.getCDOResourcePackage().getCDOResourceNodeClass();
CDOFeature resourceNameFeature = resourceNodeClass.getCDONameFeature();
CDOID folderID = (CDOID)revision.getData().getContainerID();
String name = (String)revision.getData().get(resourceNameFeature, 0);
- if (mappingStrategy.readResourceID(accessor, folderID, name, revision.getCreated()) != null)
+ if (accessor.readResourceID(folderID, name, revision.getCreated()) != null)
{
throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder " + folderID);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index ab45cc4dc4..3fd4193b88 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -22,8 +22,6 @@ import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass;
import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass;
import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.emf.cdo.server.IStoreAccessor.QueryResourcesContext;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStore;
@@ -310,14 +308,6 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
};
}
- public CDOID readResourceID(IDBStoreAccessor accessor, CDOID folderID, String name, long timeStamp)
- {
- IStoreAccessor.QueryResourcesContext.ExactMatch context = StoreUtil.createExactMatchContext(folderID, name,
- timeStamp);
- queryResources(accessor, context);
- return context.getResourceID();
- }
-
public void queryResources(IDBStoreAccessor accessor, QueryResourcesContext context)
{
CDOID folderID = context.getFolderID();
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index fe6b0c33f8..959e077ec1 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server.internal.hibernate;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.id.CDOID.Type;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClassRef;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackage;
@@ -27,13 +27,11 @@ import org.eclipse.emf.cdo.server.IQueryContext;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.emf.cdo.server.hibernate.IHibernateStoreAccessor;
import org.eclipse.emf.cdo.server.hibernate.id.CDOIDHibernate;
import org.eclipse.emf.cdo.server.hibernate.internal.id.CDOIDHibernateFactoryImpl;
import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
import org.eclipse.emf.cdo.server.internal.hibernate.tuplizer.PersistableListHolder;
-import org.eclipse.emf.cdo.spi.common.AbstractCDOIDLong;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.util.ObjectUtil;
@@ -218,43 +216,6 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
return getStore().getPackageHandler().getCDOPackageInfos();
}
- public CDOID readResourceID(CDOID folderID, String name, long timeStamp)
- {
- IStoreAccessor.QueryResourcesContext.ExactMatch context = StoreUtil.createExactMatchContext(folderID, name,
- timeStamp);
- queryResources(context);
- return context.getResourceID();
-
- // if (timeStamp != CDOProtocolView.UNSPECIFIED_DATE)
- // {
- // throw new UnsupportedOperationException();
- // }
- //
- // if (TRACER.isEnabled())
- // {
- // TRACER.trace("Finding resourceid using path " + path);
- // }
- //
- // Session session = getHibernateSession();
- // Criteria criteria = session.createCriteria(CDOResourceClass.NAME);
- // criteria.add(Expression.eq("path", path));
- // List<?> result = criteria.list();
- // if (result.size() == 0)
- // {
- // if (TRACER.isEnabled())
- // {
- // TRACER.trace("Resource not found");
- // }
- //
- // // TODO: throw exception?
- // return null;
- // }
- //
- // // TODO: throw exception if list.size() > 1?
- // CDORevision cdoRevision = (CDORevision)result.get(0);
- // return cdoRevision.getID();
- }
-
public CDORevision readRevision(CDOID id, int referenceChunk)
{
return HibernateUtil.getInstance().getCDORevision(id);
@@ -286,35 +247,21 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
*/
public void queryResources(QueryResourcesContext context)
{
- // logic description
- CDOID folderID = context.getFolderID();
+ CDOIDHibernate folderID = getHibernateID(context.getFolderID());
String name = context.getName();
boolean exactMatch = context.exactMatch();
- CDOIDHibernate cdoID = null;
- if (folderID.getType().equals(Type.NULL))
- {
- cdoID = null;
- }
- else if (folderID instanceof CDOIDHibernate)
- {
- cdoID = (CDOIDHibernate)folderID;
- }
- else if (folderID != null)
- {
- final long l = ((AbstractCDOIDLong)folderID).getLongValue();
- cdoID = CDOIDHibernateFactoryImpl.getInstance().createCDOID(l, CDOResourceNodeClass.NAME);
- }
final Session session = getHibernateSession();
final Criteria criteria = session.createCriteria(CDOResourceNodeClass.NAME);
- if (cdoID == null)
+ if (folderID == null)
{
criteria.add(Expression.isNull("containerID"));
}
else
{
- criteria.add(Expression.eq("containerID", cdoID));
+ criteria.add(Expression.eq("containerID", folderID));
}
+
List<?> result = criteria.list();
for (Object o : result)
{
@@ -329,14 +276,25 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
break;
}
}
- //
- // final Criteria c2 = session.createCriteria(CDOResourceNodeClass.NAME);
- // for (Object o : c2.list())
- // {
- // final CDORevision cr = (CDORevision)o;
- // System.err.println(cr.getData().get(getResourceNameFeature(), 0));
- // System.err.println(cr.getData().getContainerID());
- // }
+ }
+
+ private CDOIDHibernate getHibernateID(CDOID id)
+ {
+ CDOIDHibernate folderID = null;
+ if (!CDOIDUtil.isNull(id))
+ {
+ if (id instanceof CDOIDHibernate)
+ {
+ folderID = (CDOIDHibernate)id;
+ }
+ else
+ {
+ // TODO Can this happen? When?
+ final long longID = CDOIDUtil.getLong(id);
+ folderID = CDOIDHibernateFactoryImpl.getInstance().createCDOID(longID, CDOResourceNodeClass.NAME);
+ }
+ }
+ return folderID;
}
private CDOFeature getResourceNameFeature()
@@ -395,7 +353,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
if (cdoRevision instanceof InternalCDORevision)
{
final CDOID containerID = (CDOID)((InternalCDORevision)cdoRevision).getContainerID();
- if (!containerID.isNull() && containerID instanceof CDOIDTemp)
+ if (containerID instanceof CDOIDTemp && !containerID.isNull())
{
repairContainerIDs.add((InternalCDORevision)cdoRevision);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index e3f3604c35..8b7c25b5c4 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.server.internal.hibernate;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
@@ -182,7 +183,7 @@ public class HibernateUtil
*/
public CDORevision getCDORevision(CDOID id)
{
- if (id.isNull())
+ if (CDOIDUtil.isNull(id))
{
return null;
}
@@ -224,7 +225,7 @@ public class HibernateUtil
public CDORevision getCDORevisionNullable(CDOID id)
{
- if (id.isNull())
+ if (CDOIDUtil.isNull(id))
{
return null;
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
index 28990fd66d..6774727e7f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
@@ -22,7 +22,7 @@ import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.StoreUtil;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.net4j.util.ObjectUtil;
@@ -179,8 +179,10 @@ public class MEMStore extends LongIDStore implements IMEMStore
{
CDOID revisionFolder = (CDOID)revision.getData().getContainerID();
String revisionName = (String)revision.getData().get(getResourceNameFeature(), 0);
- CDOID resourceID = getResourceID(revisionFolder, revisionName, revision.getCreated());
- if (resourceID != null)
+
+ IStoreAccessor accessor = StoreThreadLocal.getAccessor();
+ CDOID resourceID = accessor.readResourceID(revisionFolder, revisionName, revision.getCreated());
+ if (!CDOIDUtil.isNull(resourceID))
{
throw new IllegalStateException("Duplicate resource: " + revisionName + " (folderID=" + revisionFolder + ")");
}
@@ -244,17 +246,6 @@ public class MEMStore extends LongIDStore implements IMEMStore
/**
* @since 2.0
*/
- public CDOID getResourceID(CDOID folderID, String name, long timeStamp)
- {
- IStoreAccessor.QueryResourcesContext.ExactMatch context = StoreUtil.createExactMatchContext(folderID, name,
- timeStamp);
- queryResources(context);
- return context.getResourceID();
- }
-
- /**
- * @since 2.0
- */
public synchronized void queryResources(IStoreAccessor.QueryResourcesContext context)
{
CDOID folderID = context.getFolderID();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index 9f99f1ee37..cd6989e269 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -223,14 +223,6 @@ public class MEMStoreAccessor extends StoreAccessor
/**
* @since 2.0
*/
- public CDOID readResourceID(CDOID folderID, String name, long timeStamp)
- {
- return getStore().getResourceID(folderID, name, timeStamp);
- }
-
- /**
- * @since 2.0
- */
public void queryResources(QueryResourcesContext context)
{
getStore().queryResources(context);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index 5e0f7cd600..411a6904e9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -17,6 +17,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor;
@@ -306,7 +307,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
if (value instanceof CDOID)
{
CDOID id = (CDOID)value;
- if (!id.isNull() && !revisions.contains(id))
+ if (!CDOIDUtil.isNull(id) && !revisions.contains(id))
{
InternalCDORevision containedRevision = revisionManager.getRevision(id, referenceChunk);
revisions.add(id);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
index 7ddfe966c5..51725a143f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOClassProxy;
import org.eclipse.emf.cdo.common.model.CDOFeature;
@@ -24,6 +25,7 @@ import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.emf.cdo.spi.common.InternalCDOClass;
import org.eclipse.emf.cdo.spi.common.InternalCDOFeature;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
@@ -103,6 +105,18 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
return null;
}
+ /**
+ * @since 2.0
+ */
+ public CDOID readResourceID(CDOID folderID, String name, long timeStamp)
+ {
+ IStoreAccessor.QueryResourcesContext.ExactMatch context = //
+ StoreUtil.createExactMatchContext(folderID, name, timeStamp);
+
+ queryResources(context);
+ return context.getResourceID();
+ }
+
public InternalCDORevision verifyRevision(CDORevision revision)
{
return (InternalCDORevision)revision;
@@ -175,7 +189,7 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
{
CDOIDTemp oldID = (CDOIDTemp)revision.getID();
CDOID newID = longIDStore.getNextCDOID();
- if (newID == null || newID.isNull() || newID.isTemporary())
+ if (CDOIDUtil.isNull(newID) || newID.isTemporary())
{
throw new IllegalStateException("newID=" + newID);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
index af6533cc2b..ee5cfa7126 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageManager;
import org.eclipse.emf.cdo.common.model.core.CDOCorePackage;
@@ -142,7 +143,7 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
public void addIDMapping(CDOIDTemp oldID, CDOID newID)
{
- if (newID == null || newID.isNull() || newID.isTemporary())
+ if (CDOIDUtil.isNull(newID) || newID.isTemporary())
{
throw new IllegalStateException("newID=" + newID);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
index 2a60e0b2e2..d7c7777974 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.analyzer.CDOFetchRule;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -128,7 +129,7 @@ public class LoadRevisionIndication extends CDOReadIndication
// Need to fetch the rule first.
Set<CDOFetchRule> visitedFetchRules = new HashSet<CDOFetchRule>();
- if (!contextID.isNull() && fetchRules.size() > 0)
+ if (!CDOIDUtil.isNull(contextID) && fetchRules.size() > 0)
{
if (PROTOCOL_TRACER.isEnabled())
{
@@ -201,7 +202,7 @@ public class LoadRevisionIndication extends CDOReadIndication
if (value instanceof CDOID)
{
CDOID id = (CDOID)value;
- if (!id.isNull() && !revisions.contains(id))
+ if (!CDOIDUtil.isNull(id) && !revisions.contains(id))
{
InternalCDORevision containedRevision = revisionManager.getRevision(id, referenceChunk);
revisions.add(containedRevision.getID());
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/CDO AllTests (Hibernate).launch b/plugins/org.eclipse.emf.cdo.tests.hibernate/CDO AllTests (Hibernate).launch
new file mode 100644
index 0000000000..ee48d75489
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/CDO AllTests (Hibernate).launch
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.hibernate.AllTestsHibernate"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.hibernate"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
index eeae5292c8..365f92e691 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
@@ -54,4 +54,4 @@ public class HibernateConfig extends RepositoryConfig
IHibernateMappingProvider mappingProvider = TeneoUtil.createMappingProvider();
return CDOHibernateUtil.createStore(mappingProvider);
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java
index f29e6938ed..defed61311 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ConfigTest.java
@@ -29,14 +29,19 @@ import org.eclipse.emf.cdo.tests.model4interfaces.model4interfacesPackage;
import org.eclipse.net4j.acceptor.IAcceptor;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.tests.AbstractOMTest;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.emf.ecore.EPackage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
/**
* @author Eike Stepper
@@ -48,9 +53,54 @@ public abstract class ConfigTest extends AbstractOMTest implements ConfigConstan
{
}
+ private Properties homeProperties;
+
// /////////////////////////////////////////////////////////////////////////
// //////////////////////// Container //////////////////////////////////////
+ public synchronized Properties getHomeProperties()
+ {
+ if (homeProperties == null)
+ {
+ homeProperties = new Properties();
+ String home = System.getProperty("user.home");
+ if (home != null)
+ {
+ File file = new File(home, ".cdo_config_test.properties");
+ if (file.exists())
+ {
+ FileInputStream stream = IOUtil.openInputStream(file);
+
+ try
+ {
+ homeProperties.load(stream);
+ }
+ catch (IOException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ finally
+ {
+ IOUtil.close(stream);
+ }
+ }
+ }
+ }
+
+ return homeProperties;
+ }
+
+ public ContainerConfig getLastContainerConfig()
+ {
+ String name = getHomeProperties().getProperty("org.eclipse.emf.cdo.tests.config.ContainerConfig");
+ return ContainerConfig.getInstance(name);
+ }
+
+ public synchronized void setHomeProperties(Properties homeProperties)
+ {
+ this.homeProperties = homeProperties;
+ }
+
/**
*@category Container
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java
index ad26c6ac4b..b6faff912d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ContainerConfig.java
@@ -25,6 +25,19 @@ public abstract class ContainerConfig extends Config implements ContainerProvide
{
public static final ContainerConfig[] CONFIGS = { Combined.INSTANCE, Separated.INSTANCE };
+ public static ContainerConfig getInstance(String name)
+ {
+ for (ContainerConfig config : CONFIGS)
+ {
+ if (config.equals(name))
+ {
+ return config;
+ }
+ }
+
+ return null;
+ }
+
public ContainerConfig(String name)
{
super(name);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index ddae623472..af481e8527 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -506,8 +506,7 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
}
CDOID cdoID = CDOIDUtil.read(uriFragment, cdoView().getSession().getPackageManager().getCDOIDObjectFactory());
-
- if (cdoID.isNull() || cdoID.isTemporary() && !cdoView().isObjectRegistered(cdoID))
+ if (CDOIDUtil.isNull(cdoID) || cdoID.isTemporary() && !cdoView().isObjectRegistered(cdoID))
{
return null;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 1a36056014..9da1fdef14 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -201,7 +201,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
try
{
CDOID id = getResourceID(path);
- if (id != null && !id.isNull())
+ if (!CDOIDUtil.isNull(id))
{
return (CDOResource)getObject(id);
}
@@ -406,7 +406,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
public InternalCDOObject getObject(CDOID id, boolean loadOnDemand)
{
checkOpen();
- if (id == null || id.isNull())
+ if (CDOIDUtil.isNull(id))
{
return null;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index cf0596d880..4fc545f3ec 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -585,7 +585,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
public CDOResourceImpl getResource(CDOID resourceID)
{
- if (resourceID == null || resourceID.isNull())
+ if (CDOIDUtil.isNull(resourceID))
{
throw new IllegalArgumentException("resourceID: " + resourceID);
}
@@ -628,7 +628,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
public InternalCDOObject getObject(CDOID id, boolean loadOnDemand)
{
checkOpen();
- if (id == null || id.isNull())
+ if (CDOIDUtil.isNull(id))
{
return null;
}
@@ -703,7 +703,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
{
checkOpen();
- if (id == null || id.isNull())
+ if (CDOIDUtil.isNull(id))
{
return false;
}
@@ -791,7 +791,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
CDOID folderID = (CDOID)revision.getData().getContainerID();
String name = (String)revision.getData().get(nameFeature, 0);
- if (folderID == null || folderID.isNull())
+ if (CDOIDUtil.isNull(folderID))
{
if (name == null)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 5212308298..3e5107bf7a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
@@ -200,7 +201,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
for (;;)
{
CDOIDTemp oldID = (CDOIDTemp)in.readCDOID();
- if (oldID.isNull())
+ if (CDOIDUtil.isNull(oldID))
{
break;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java
index d23c769921..cdaa2f1cf5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo.query;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.common.util.EList;
@@ -39,14 +40,14 @@ public class CDOEList<T> implements EList<T>
}
@SuppressWarnings("unchecked")
- protected T adapt(CDOID object)
+ protected T adapt(CDOID id)
{
- if (object.isNull())
+ if (CDOIDUtil.isNull(id))
{
return null;
}
- return (T)view.getObject(object, true);
+ return (T)view.getObject(id, true);
}
public boolean add(T o)

Back to the top