diff options
author | Eike Stepper | 2013-09-19 08:10:00 +0000 |
---|---|---|
committer | Eike Stepper | 2013-09-19 08:10:00 +0000 |
commit | f6a700fe7abc8ff07acb9b0c425bc9ac86570bdf (patch) | |
tree | 99e0902c1a1d1b24e0563be0ad576aeeb6a2bd9a /plugins/org.eclipse.emf.cdo | |
parent | c1574d75a9bf1ff76a2a6a56edcda2e1dcad8d72 (diff) | |
download | cdo-f6a700fe7abc8ff07acb9b0c425bc9ac86570bdf.tar.gz cdo-f6a700fe7abc8ff07acb9b0c425bc9ac86570bdf.tar.xz cdo-f6a700fe7abc8ff07acb9b0c425bc9ac86570bdf.zip |
[417566] [Security] Make user ID available in PermissionImpl and
PermissionFilterImpl
https://bugs.eclipse.org/bugs/show_bug.cgi?id=417566
Diffstat (limited to 'plugins/org.eclipse.emf.cdo')
5 files changed, 104 insertions, 19 deletions
diff --git a/plugins/org.eclipse.emf.cdo/model/eresource.genmodel b/plugins/org.eclipse.emf.cdo/model/eresource.genmodel index da0b59666e..0f794159d9 100644 --- a/plugins/org.eclipse.emf.cdo/model/eresource.genmodel +++ b/plugins/org.eclipse.emf.cdo/model/eresource.genmodel @@ -1,9 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" - xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" - modelDirectory="/org.eclipse.emf.cdo/src" editDirectory="/org.eclipse.emf.cdo.edit/src" - editorDirectory="" modelPluginID="org.eclipse.emf.cdo" modelName="Eresource" editPluginClass="org.eclipse.emf.cdo.edit.CDOEditPlugin" +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.cdo/src" creationIcons="false" + editDirectory="/org.eclipse.emf.cdo.edit/src" editorDirectory="" modelPluginID="org.eclipse.emf.cdo" + modelName="Eresource" editPluginClass="org.eclipse.emf.cdo.edit.CDOEditPlugin" editorPluginClass="" updateClasspath="false" nonNLSMarkers="true" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" reflectiveDelegation="true" codeFormatting="true" testsDirectory="" importerID="org.eclipse.emf.importer.ecore" @@ -29,6 +28,12 @@ <genOperations ecoreOperation="eresource.ecore#//CDOResourceFolder/addResource"> <genParameters ecoreParameter="eresource.ecore#//CDOResourceFolder/addResource/name"/> </genOperations> + <genOperations ecoreOperation="eresource.ecore#//CDOResourceFolder/addTextResource"> + <genParameters ecoreParameter="eresource.ecore#//CDOResourceFolder/addTextResource/name"/> + </genOperations> + <genOperations ecoreOperation="eresource.ecore#//CDOResourceFolder/addBinaryResource"> + <genParameters ecoreParameter="eresource.ecore#//CDOResourceFolder/addBinaryResource/name"/> + </genOperations> </genClasses> <genClasses ecoreClass="eresource.ecore#//CDOResource"> <genFeatures property="None" createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOResource/resourceSet"/> @@ -50,6 +55,7 @@ </genClasses> <genClasses ecoreClass="eresource.ecore#//CDOTextResource"> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOTextResource/contents"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute eresource.ecore#//CDOTextResource/encoding"/> </genClasses> </genPackages> </genmodel:GenModel> diff --git a/plugins/org.eclipse.emf.cdo/model/etypes.genmodel b/plugins/org.eclipse.emf.cdo/model/etypes.genmodel index 280693777b..f3057eb729 100644 --- a/plugins/org.eclipse.emf.cdo/model/etypes.genmodel +++ b/plugins/org.eclipse.emf.cdo/model/etypes.genmodel @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<genmodel:GenModel xmi:version="2.0" - xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" - xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.cdo/src" +<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.cdo/src" creationIcons="false" editDirectory="/org.eclipse.emf.cdo.edit/src" editorDirectory="" modelPluginID="org.eclipse.emf.cdo" modelName="Etypes" editPluginClass="org.eclipse.emf.cdo.edit.CDOEditPlugin" editorPluginClass="" updateClasspath="false" nonNLSMarkers="true" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" @@ -16,6 +15,7 @@ extensibleProviderFactory="true" childCreationExtenders="true" ecorePackage="etypes.ecore#/"> <genDataTypes ecoreDataType="etypes.ecore#//Blob"/> <genDataTypes ecoreDataType="etypes.ecore#//Clob"/> + <genDataTypes ecoreDataType="etypes.ecore#//Lob"/> <genClasses image="false" ecoreClass="etypes.ecore#//ModelElement"> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference etypes.ecore#//ModelElement/annotations"/> <genOperations ecoreOperation="etypes.ecore#//ModelElement/getAnnotation"> diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java index 17ca11c8da..cdc3b8a5aa 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.util.CDOException; import org.eclipse.emf.cdo.eresource.CDOResourceFolder; import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.internal.cdo.CDOObjectImpl; @@ -264,7 +265,7 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe { case EresourcePackage.CDO_RESOURCE_NODE__PATH: return getPath(); - + default: return super.eGet(featureID, resolve, coreType); } @@ -278,9 +279,23 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe case EresourcePackage.CDO_RESOURCE_NODE__PATH: setPath((String)newValue); break; - + default: super.eSet(featureID, newValue); } } + + @Override + public String toString() + { + String string = super.toString(); + + InternalCDORevision revision = cdoRevision(); + if (revision != null) + { + string += "(\"" + revision.getResourceNodeName() + "\")"; + } + + return string; + } } // CDOResourceNodeImpl 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 8405c00a42..8c0bce6f6e 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 @@ -21,7 +21,10 @@ import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.eresource.CDOResourceFactory; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.etypes.Annotation; +import org.eclipse.emf.cdo.etypes.EtypesFactory; import org.eclipse.emf.cdo.etypes.EtypesPackage; +import org.eclipse.emf.cdo.etypes.ModelElement; import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl; import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy; import org.eclipse.emf.cdo.session.CDORepositoryInfo; @@ -84,6 +87,16 @@ import java.util.Map; */ public final class CDOUtil { + /** + * @since 4.3 + */ + public static final String CDO_ANNOTATION_URI = "http://www.eclipse.org/CDO"; + + /** + * @since 4.3 + */ + public static final String DOCUMENTATION_KEY = "documentation"; + static { CDOPackageRegistryImpl.SYSTEM_ELEMENTS[0] = EcorePackage.eINSTANCE; @@ -631,4 +644,57 @@ public final class CDOUtil String resource = data.toString(); IPluginContainer.INSTANCE.putElement("org.eclipse.net4j.util.credentialsProviders", "password", resource, provider); } + + /** + * @since 4.3 + */ + public static String getAnnotation(ModelElement modelElement, String sourceURI, String key) + { + Annotation annotation = modelElement.getAnnotation(sourceURI); + return annotation == null ? null : (String)annotation.getDetails().get(key); + } + + /** + * @since 4.3 + */ + public static Annotation setAnnotation(ModelElement modelElement, String sourceURI, String key, String value) + { + Annotation annotation = modelElement.getAnnotation(sourceURI); + if (value == null) + { + if (annotation != null) + { + annotation.getDetails().removeKey(key); + } + } + else + { + if (annotation == null) + { + annotation = EtypesFactory.eINSTANCE.createAnnotation(); + annotation.setSource(sourceURI); + modelElement.getAnnotations().add(annotation); + } + + annotation.getDetails().put(key, value); + } + + return annotation; + } + + /** + * @since 4.3 + */ + public static String getDocumentation(ModelElement modelElement) + { + return getAnnotation(modelElement, CDO_ANNOTATION_URI, DOCUMENTATION_KEY); + } + + /** + * @since 4.3 + */ + public static Annotation setDocumentation(ModelElement modelElement, String value) + { + return setAnnotation(modelElement, CDO_ANNOTATION_URI, DOCUMENTATION_KEY, value); + } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java index f99fd07ef2..9faa309394 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java @@ -902,13 +902,13 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object featureDelta) { - InternalCDOTransaction transaction = object.cdoView().toTransaction(); InternalCDORevision cleanRevision = object.cdoRevision(); if (!cleanRevision.isWritable()) { - throw new NoPermissionException(cleanRevision, transaction); + throw new NoPermissionException(cleanRevision); } + InternalCDOTransaction transaction = object.cdoView().toTransaction(); transaction.getCleanRevisions().put(object, cleanRevision); // Copy revision @@ -927,14 +927,13 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object featureDelta) { - InternalCDOTransaction transaction = object.cdoView().toTransaction(); - InternalCDORevision revision = object.cdoRevision(); if (!revision.isWritable()) { - throw new NoPermissionException(revision, transaction); + throw new NoPermissionException(revision); } + InternalCDOTransaction transaction = object.cdoView().toTransaction(); transaction.registerFeatureDelta(object, (CDOFeatureDelta)featureDelta); } } @@ -946,14 +945,13 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object featureDelta) { - InternalCDOTransaction transaction = object.cdoView().toTransaction(); - InternalCDORevision revision = object.cdoRevision(); if (!revision.isWritable()) { - throw new NoPermissionException(revision, transaction); + throw new NoPermissionException(revision); } + InternalCDOTransaction transaction = object.cdoView().toTransaction(); transaction.registerFeatureDelta(object, (CDOFeatureDelta)featureDelta); } } @@ -1116,7 +1114,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent if (forWrite && !revision.isWritable()) { - throw new NoPermissionException(revision, view); + throw new NoPermissionException(revision); } object.cdoInternalSetRevision(revision); |