summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-24 11:43:02 (EDT)
committerEike Stepper2007-08-24 11:43:02 (EDT)
commit42283eb1344017e50ccac42aec4e27f1a5866ec6 (patch)
tree4cfeedfe4f73962659ebd57a674654dd568a65f9
parent41b4e66e94d36f6bda3b73247ebba4a437cc15dd (diff)
downloadcdo-42283eb1344017e50ccac42aec4e27f1a5866ec6.zip
cdo-42283eb1344017e50ccac42aec4e27f1a5866ec6.tar.gz
cdo-42283eb1344017e50ccac42aec4e27f1a5866ec6.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
index 1aa6a9d..5693ffb 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
@@ -13,11 +13,17 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.server.db.IMapping;
+import org.eclipse.net4j.util.ImplementationError;
+
/**
* @author Eike Stepper
*/
public final class ClassServerInfo extends ServerInfo
{
+ public static final int CDO_OBJECT_CLASS_DBID = -1;
+
+ public static final int CDO_RESOURCE_CLASS_DBID = -2;
+
private IMapping mapping;
private ClassServerInfo(int id)
@@ -34,11 +40,36 @@ public final class ClassServerInfo extends ServerInfo
public static IMapping getMapping(CDOClass cdoClass)
{
- return ((ClassServerInfo)cdoClass.getServerInfo()).mapping;
+ ClassServerInfo serverInfo = getServerInfo(cdoClass);
+ return serverInfo == null ? null : serverInfo.mapping;
}
public static void setMapping(CDOClass cdoClass, IMapping mapping)
{
- ((ClassServerInfo)cdoClass.getServerInfo()).mapping = mapping;
+ ClassServerInfo serverInfo = getServerInfo(cdoClass);
+ if (serverInfo == null)
+ {
+ throw new ImplementationError("No serverInfo for class " + cdoClass);
+ }
+
+ serverInfo.mapping = mapping;
+ }
+
+ protected static ClassServerInfo getServerInfo(CDOClass cdoClass)
+ {
+ ClassServerInfo serverInfo = (ClassServerInfo)cdoClass.getServerInfo();
+ if (serverInfo == null)
+ {
+ if (cdoClass.isRoot())
+ {
+ serverInfo = setDBID(cdoClass, CDO_OBJECT_CLASS_DBID);
+ }
+ else if (cdoClass.isResource())
+ {
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_CLASS_DBID);
+ }
+ }
+
+ return serverInfo;
}
}