Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-21 10:51:27 +0000
committerEike Stepper2013-09-21 10:51:27 +0000
commitbef560dd45871de21fd9505f95cbd18c4f190f9d (patch)
tree71db659b0517784da4d6eee877b2b10aa06b4c71
parent584b567ad3d4d41df1a4ef58430394a7b5fc6901 (diff)
downloadcdo-bef560dd45871de21fd9505f95cbd18c4f190f9d.tar.gz
cdo-bef560dd45871de21fd9505f95cbd18c4f190f9d.tar.xz
cdo-bef560dd45871de21fd9505f95cbd18c4f190f9d.zip
[417746] Provide cdoRevision(boolean loadOnDemand) and cdoPermission()
methods in CDOObject https://bugs.eclipse.org/bugs/show_bug.cgi?id=417746
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java22
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java15
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java5
7 files changed, 83 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java
index 24cb5780b5..5b90312a39 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java
@@ -16,7 +16,9 @@ import org.eclipse.emf.cdo.common.id.CDOWithID;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.ecore.EObject;
@@ -96,6 +98,22 @@ public interface CDOObject extends EObject, CDOWithID
public CDORevision cdoRevision();
/**
+ * Returns the {@link CDORevision revision} of this object, or <code>null</code> if this object does currently not
+ * have a revision and loadOnDemand is <code>false</code>. The revision is used to store all modeled data of this object,
+ * together with some technical data required by the framework.
+ *
+ * @since 4.3
+ */
+ public CDORevision cdoRevision(boolean loadOnDemand);
+
+ /**
+ * Returns the permission of the current {@link CDOSession session}'s user for this object.
+ *
+ * @since 4.3
+ */
+ public CDOPermission cdoPermission();
+
+ /**
* Returns the {@link CDOResource resource} of this object, no matter where this object is located in the containment
* tree of that resource, or <code>null</code> if this object is not contained in a CDO resource.
* <p>
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 8c0bce6f6e..35ec7510cc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -477,6 +477,11 @@ public final class CDOUtil
*/
public static CDOObject getCDOObject(EObject object)
{
+ if (object == null)
+ {
+ return null;
+ }
+
if (object instanceof CDOObject)
{
return (CDOObject)object;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 3991de0369..18fd7c1073 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo.PersistenceFilter;
@@ -161,6 +162,27 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return revision.getProperRevision();
}
+ /**
+ * @since 4.3
+ */
+ public final InternalCDORevision cdoRevision(boolean loadOnDemand)
+ {
+ if (loadOnDemand)
+ {
+ CDOStateMachine.INSTANCE.read(this);
+ }
+
+ return cdoRevision();
+ }
+
+ /**
+ * @since 4.3
+ */
+ public final CDOPermission cdoPermission()
+ {
+ return cdoRevision(true).getPermission();
+ }
+
public final CDOResource cdoResource()
{
Resource resource = eResource();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java
index fe24bebd2b..9238db6a5f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.ecore.InternalEObject;
@@ -62,6 +63,16 @@ public class CDOExternalObject extends CDOObjectWrapperBase
return null;
}
+ public CDORevision cdoRevision(boolean loadOnDemand)
+ {
+ return null;
+ }
+
+ public CDOPermission cdoPermission()
+ {
+ return null;
+ }
+
public CDOLock cdoReadLock()
{
return null;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 1805087e1a..369e556133 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -190,6 +190,21 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
return null;
}
+ public InternalCDORevision cdoRevision(boolean loadOnDemand)
+ {
+ if (loadOnDemand)
+ {
+ CDOStateMachine.INSTANCE.read(this);
+ }
+
+ return cdoRevision();
+ }
+
+ public CDOPermission cdoPermission()
+ {
+ return cdoRevision(true).getPermission();
+ }
+
@Override
public CDOResourceImpl cdoResource()
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index a58a571f29..7f265d9dd0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -35,6 +35,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.CDOBinaryResource;
@@ -334,8 +335,12 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
public synchronized boolean isEmpty()
{
CDOResource rootResource = getRootResource();
- boolean empty = rootResource.getContents().isEmpty();
+ if (rootResource.cdoPermission() == CDOPermission.NONE)
+ {
+ return true;
+ }
+ boolean empty = rootResource.getContents().isEmpty();
ensureContainerAdapter(rootResource);
return empty;
}
@@ -343,7 +348,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
public synchronized CDOResourceNode[] getElements()
{
CDOResource rootResource = getRootResource();
- EList<EObject> contents = CDOUtil.filterReadables(rootResource.getContents());
+ EList<EObject> contents = rootResource.getContents();
List<CDOResourceNode> elements = new ArrayList<CDOResourceNode>(contents.size());
for (EObject object : contents)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
index d025792d30..69a7fd22fa 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
@@ -42,6 +42,11 @@ public interface InternalCDOObject extends CDOObject, InternalEObject, InternalC
public InternalCDORevision cdoRevision();
+ /**
+ * @since 4.3
+ */
+ public InternalCDORevision cdoRevision(boolean loadOnDemand);
+
public void cdoInternalPostAttach();
public void cdoInternalPostDetach(boolean remote);

Back to the top