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 | |
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
64 files changed, 522 insertions, 200 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/NoPermissionException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/NoPermissionException.java index a6e074d4a6..6a84531e4f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/NoPermissionException.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/security/NoPermissionException.java @@ -10,10 +10,6 @@ */ package org.eclipse.emf.cdo.common.security; -import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; -import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; - /** * A {@link SecurityException security exception} indicating the lack of permission required to do something. * @@ -26,17 +22,9 @@ public class NoPermissionException extends SecurityException private Object protectableObject; - /** - * @since 4.3 - */ - public NoPermissionException(Object protectableObject, CDORevisionProvider revisionProvider) - { - this(protectableObject, "No permission to access " + format(protectableObject, revisionProvider)); - } - public NoPermissionException(Object protectableObject) { - this(protectableObject, (CDORevisionProvider)null); + this(protectableObject, "No permission to access " + protectableObject); } public NoPermissionException(Object protectableObject, String message) @@ -49,27 +37,4 @@ public class NoPermissionException extends SecurityException { return protectableObject; } - - private static String format(Object object, CDORevisionProvider revisionProvider) - { - String result = object.toString(); - - if (object instanceof InternalCDORevision) - { - InternalCDORevision revision = (InternalCDORevision)object; - if (revision.isResourceNode()) - { - if (revisionProvider != null) - { - result += "(" + CDORevisionUtil.getResourceNodePath(revision, revisionProvider) + ")"; - } - else - { - result += "(" + revision.getResourceNodeName() + ")"; - } - } - } - - return result; - } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java index d9114efdb5..06d28e3476 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java @@ -256,13 +256,28 @@ public abstract class AbstractCDORevision implements InternalCDORevision EClass eClass = getEClass(); String name = eClass == null ? "Revision" : eClass.getName(); + String string = name + "@" + getID(); + CDOBranch branch = getBranch(); - if (branch == null) + if (branch != null) + { + string += ":" + branch.getID(); + } + + string += "v" + getVersion(); + + if (isResourceNode()) { - return name + "@" + getID() + "v" + getVersion(); + String resourceNodeName = getResourceNodeName(); + if (resourceNodeName == null) + { + resourceNodeName = "/"; + } + + string += "(\"" + resourceNodeName + "\")"; } - return name + "@" + getID() + ":" + branch.getID() + "v" + getVersion(); + return string; } /** diff --git a/plugins/org.eclipse.emf.cdo.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.edit/META-INF/MANIFEST.MF index 3489cb122c..bdc95101bd 100644 --- a/plugins/org.eclipse.emf.cdo.edit/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.edit/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.edit; singleton:=true -Bundle-Version: 4.2.0.qualifier +Bundle-Version: 4.2.100.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.emf.edit;bundle-version="[2.5.0,3.0.0)";visibility:= org.eclipse.emf.ecore;bundle-version="[2.5.0,3.0.0)";visibility:=reexport, org.eclipse.emf.ecore.edit;bundle-version="[2.5.0,3.0.0)";visibility:=reexport, org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)";visibility:=reexport -Export-Package: org.eclipse.emf.cdo.edit;version="4.2.0", - org.eclipse.emf.cdo.eresource.provider;version="4.1.100", - org.eclipse.emf.cdo.etypes.provider;version="4.1.100", - org.eclipse.emf.cdo.internal.edit.messages;version="4.2.0";x-internal:=true +Export-Package: org.eclipse.emf.cdo.edit;version="4.2.100", + org.eclipse.emf.cdo.eresource.provider;version="4.2.100", + org.eclipse.emf.cdo.etypes.provider;version="4.2.100", + org.eclipse.emf.cdo.internal.edit.messages;version="4.2.100";x-internal:=true diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_contents_EObject.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_contents_EObject.gif Binary files differdeleted file mode 100644 index b2556694e4..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_contents_EObject.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_details_EStringToStringMapEntry.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_details_EStringToStringMapEntry.gif Binary files differdeleted file mode 100644 index ecb89fffc7..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateAnnotation_details_EStringToStringMapEntry.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif Binary files differdeleted file mode 100644 index 9d64092d8d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif Binary files differdeleted file mode 100644 index 2c76ed1e2d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOBinaryResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOBinaryResource.gif Binary files differdeleted file mode 100644 index 1dbde94c82..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOBinaryResource.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOFileResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOFileResource.gif Binary files differdeleted file mode 100644 index 305fa05b3c..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOFileResource.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif Binary files differdeleted file mode 100644 index 9d64092d8d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif Binary files differdeleted file mode 100644 index 2c76ed1e2d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceLeaf.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceLeaf.gif Binary files differdeleted file mode 100644 index 9a441d452d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceLeaf.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResource.gif Binary files differdeleted file mode 100644 index d2845b4816..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResource.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResouurce.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResouurce.gif Binary files differdeleted file mode 100644 index 305fa05b3c..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOTextResouurce.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAnnotation.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAnnotation.gif Binary files differdeleted file mode 100644 index accf314bb3..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAnnotation.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAttribute.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAttribute.gif Binary files differdeleted file mode 100644 index c5e047b325..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EAttribute.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EClass.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EClass.gif Binary files differdeleted file mode 100644 index 4c29533ccf..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EClass.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EDataType.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EDataType.gif Binary files differdeleted file mode 100644 index d523a96589..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EDataType.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnum.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnum.gif Binary files differdeleted file mode 100644 index 6d944d72a8..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnum.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnumLiteral.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnumLiteral.gif Binary files differdeleted file mode 100644 index 3052dce139..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EEnumLiteral.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EFactory.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EFactory.gif Binary files differdeleted file mode 100644 index b5ff106252..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EFactory.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EGenericType.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EGenericType.gif Binary files differdeleted file mode 100644 index 1cd7fa09f3..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EGenericType.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EObject.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EObject.gif Binary files differdeleted file mode 100644 index 1623e88e3d..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EObject.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EOperation.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EOperation.gif Binary files differdeleted file mode 100644 index 6844bf8a90..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EOperation.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EPackage.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EPackage.gif Binary files differdeleted file mode 100644 index 6d944d72a8..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EPackage.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EParameter.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EParameter.gif Binary files differdeleted file mode 100644 index 4ae0144c11..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EParameter.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EReference.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EReference.gif Binary files differdeleted file mode 100644 index 19b38abf6c..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_EReference.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_ETypeParameter.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_ETypeParameter.gif Binary files differdeleted file mode 100644 index b5ff106252..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResource_contents_ETypeParameter.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateModelElement_annotations_Annotation.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateModelElement_annotations_Annotation.gif Binary files differdeleted file mode 100644 index 588cca4118..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateModelElement_annotations_Annotation.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceLeaf.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceLeaf.gif Binary files differdeleted file mode 100644 index 338fb8d9a7..0000000000 --- a/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceLeaf.gif +++ /dev/null diff --git a/plugins/org.eclipse.emf.cdo.edit/plugin.xml b/plugins/org.eclipse.emf.cdo.edit/plugin.xml index 0a2b5cd039..12965fab28 100644 --- a/plugins/org.eclipse.emf.cdo.edit/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.edit/plugin.xml @@ -23,6 +23,15 @@ org.eclipse.emf.edit.provider.ITreeItemContentProvider org.eclipse.emf.edit.provider.IItemLabelProvider org.eclipse.emf.edit.provider.IItemPropertySource" /> + <factory + uri = "http://www.eclipse.org/emf/CDO/Etypes/4.0.0" + class = "org.eclipse.emf.cdo.etypes.provider.EtypesItemProviderAdapterFactory" + supportedTypes = + "org.eclipse.emf.edit.provider.IEditingDomainItemProvider + org.eclipse.emf.edit.provider.IStructuredItemContentProvider + org.eclipse.emf.edit.provider.ITreeItemContentProvider + org.eclipse.emf.edit.provider.IItemLabelProvider + org.eclipse.emf.edit.provider.IItemPropertySource" /> </extension> </plugin> diff --git a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/etypes/provider/AnnotationItemProvider.java b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/etypes/provider/AnnotationItemProvider.java index 8c9916c027..5c2192faff 100644 --- a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/etypes/provider/AnnotationItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/etypes/provider/AnnotationItemProvider.java @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.etypes.EtypesPackage; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.EcorePackage; @@ -151,15 +152,28 @@ public class AnnotationItemProvider extends ModelElementItemProvider implements /** * This returns the label text for the adapted class. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * @generated + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT */ @Override public String getText(Object object) { - String label = ((Annotation)object).getSource(); - return label == null || label.length() == 0 ? getString("_UI_Annotation_type") : //$NON-NLS-1$ - getString("_UI_Annotation_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + Annotation annotation = (Annotation)object; + StringBuffer result = new StringBuffer(); + if (annotation.getSource() != null) + { + int index = getParent(annotation) instanceof EAnnotation ? -1 : annotation.getSource().lastIndexOf("/"); + if (index == -1) + { + result.append(annotation.getSource()); + } + else + { + result.append(annotation.getSource().substring(index + 1)); + } + } + return result.toString(); } /** diff --git a/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF index b6f245c59e..481b77cacf 100644 --- a/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.emf.cdo.internal.security;version="4.3.0";x-friends:="org.eclipse.emf.cdo.security.edit,org.eclipse.emf.cdo.security.editor,org.eclipse.emf.cdo.server.security", + org.eclipse.emf.cdo.internal.security.bundle;version="4.3.0";x-internal:=true, org.eclipse.emf.cdo.security;version="4.3.0", org.eclipse.emf.cdo.security.impl;version="4.3.0", org.eclipse.emf.cdo.security.util;version="4.3.0" diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/ViewUtil.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/PermissionUtil.java index 7998b643c8..245a6ee209 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/ViewUtil.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/PermissionUtil.java @@ -19,14 +19,33 @@ import java.util.Map; /** * @author Eike Stepper */ -public final class ViewUtil +public final class PermissionUtil { + private static final ThreadLocal<String> USER = new ThreadLocal<String>(); + private static final ThreadLocal<ViewCreator> VIEW_CREATOR = new ThreadLocal<ViewCreator>(); private static final ThreadLocal<Map<CDORevisionProvider, CDOView>> VIEWS = new ThreadLocal<Map<CDORevisionProvider, CDOView>>(); - private ViewUtil() + private PermissionUtil() + { + } + + public static String getUser() { + return USER.get(); + } + + public static void setUser(String user) + { + if (user == null) + { + USER.remove(); + } + else + { + USER.set(user); + } } private static Map<CDORevisionProvider, CDOView> getViews() diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/bundle/OM.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/bundle/OM.java new file mode 100644 index 0000000000..5b43e74813 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/internal/security/bundle/OM.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2008-2012 Eike Stepper (Berlin, Germany) and others. + * 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.internal.security.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.security"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PermissionFilter.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PermissionFilter.java index deb3b1ef29..955c134262 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PermissionFilter.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PermissionFilter.java @@ -21,7 +21,8 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; */ public interface PermissionFilter extends CDOObject { - boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext); + boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception; String format(); diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/AndFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/AndFilterImpl.java index 8501f3cafd..cb5fb9ef6c 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/AndFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/AndFilterImpl.java @@ -44,11 +44,14 @@ public class AndFilterImpl extends CombinedFilterImpl implements AndFilter return SecurityPackage.Literals.AND_FILTER; } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { + ++level; for (PermissionFilter operand : getOperands()) { - if (!operand.isApplicable(revision, revisionProvider, securityContext)) + if (!operand.isApplicable(revision, revisionProvider, securityContext, level)) { return false; } diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ClassFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ClassFilterImpl.java index 1eda26d57c..9c817d33f2 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ClassFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ClassFilterImpl.java @@ -88,7 +88,9 @@ public class ClassFilterImpl extends PermissionFilterImpl implements ClassFilter eSet(SecurityPackage.Literals.CLASS_FILTER__SUB_TYPES, newSubTypes); } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { EClass actualClass = revision.getEClass(); EClass applicableClass = getApplicableClass(); @@ -117,7 +119,7 @@ public class ClassFilterImpl extends PermissionFilterImpl implements ClassFilter private String formatOperator() { - return isSubTypes() ? ">=" : "=="; + return isSubTypes() ? " >= " : " == "; } } // ClassFilterImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ExpressionFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ExpressionFilterImpl.java index 5acaddf595..5e56978ac6 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ExpressionFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ExpressionFilterImpl.java @@ -70,7 +70,7 @@ public class ExpressionFilterImpl extends ObjectFilterImpl implements Expression } @Override - protected boolean isApplicable(CDOObject object, CDOBranchPoint securityContext) + protected boolean filter(CDOObject object, CDOBranchPoint securityContext) { EvaluationContext evaluationContext = new EvaluationContextImpl(object); diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/FilterPermissionImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/FilterPermissionImpl.java index 4441cb1011..1b970e1100 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/FilterPermissionImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/FilterPermissionImpl.java @@ -5,10 +5,13 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; +import org.eclipse.emf.cdo.internal.security.bundle.OM; import org.eclipse.emf.cdo.security.FilterPermission; import org.eclipse.emf.cdo.security.PermissionFilter; import org.eclipse.emf.cdo.security.SecurityPackage; +import org.eclipse.net4j.util.om.trace.ContextTracer; + import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; @@ -28,6 +31,8 @@ import org.eclipse.emf.ecore.EClass; */ public class FilterPermissionImpl extends PermissionImpl implements FilterPermission { + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, FilterPermissionImpl.class); + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -62,10 +67,27 @@ public class FilterPermissionImpl extends PermissionImpl implements FilterPermis public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) { + if (TRACER.isEnabled()) + { + TRACER.format("Checking {0} permission for {1}", getAccess(), revision); //$NON-NLS-1$ + } + for (PermissionFilter filter : getFilters()) { - if (!filter.isApplicable(revision, revisionProvider, securityContext)) + try + { + if (!filter.isApplicable(revision, revisionProvider, securityContext, 1)) + { + return false; + } + } + catch (Exception ex) { + if (TRACER.isEnabled()) + { + TRACER.trace(ex); + } + return false; } } diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/LinkedFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/LinkedFilterImpl.java index 86791bcba9..bf6f8c7d0a 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/LinkedFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/LinkedFilterImpl.java @@ -68,9 +68,11 @@ public class LinkedFilterImpl extends PermissionFilterImpl implements LinkedFilt eSet(SecurityPackage.Literals.LINKED_FILTER__FILTER, newFilter); } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { - return getFilter().isApplicable(revision, revisionProvider, securityContext); + return getFilter().isApplicable(revision, revisionProvider, securityContext, level + 1); } public String format() diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/NotFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/NotFilterImpl.java index 53fb35d64e..f05e3413bd 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/NotFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/NotFilterImpl.java @@ -44,10 +44,12 @@ public class NotFilterImpl extends CombinedFilterImpl implements NotFilter return SecurityPackage.Literals.NOT_FILTER; } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { PermissionFilter operand = getOperands().get(0); - return !operand.isApplicable(revision, revisionProvider, securityContext); + return !operand.isApplicable(revision, revisionProvider, securityContext, level + 1); } @Override diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectFilterImpl.java index 6a0cf6db15..4b9a3176be 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectFilterImpl.java @@ -7,7 +7,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; -import org.eclipse.emf.cdo.internal.security.ViewUtil; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; import org.eclipse.emf.cdo.security.ObjectFilter; import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.cdo.view.CDOView; @@ -49,21 +49,20 @@ public abstract class ObjectFilterImpl extends PermissionFilterImpl implements O protected CDOView getView(CDORevisionProvider revisionProvider) { - return ViewUtil.getView(revisionProvider); + return PermissionUtil.getView(revisionProvider); } - /** - * @ADDED - */ - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, int level) + throws Exception { CDOView view = getView(revisionProvider); CDOID id = revision.getID(); CDOObject object = view.getObject(id); - return isApplicable(object, securityContext); + return filter(object, securityContext); } - protected abstract boolean isApplicable(CDOObject object, CDOBranchPoint securityContext); + protected abstract boolean filter(CDOObject object, CDOBranchPoint securityContext); } // ObjectFilterImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectPermissionImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectPermissionImpl.java index 277b2325c2..125b36abeb 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectPermissionImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ObjectPermissionImpl.java @@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; -import org.eclipse.emf.cdo.internal.security.ViewUtil; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; import org.eclipse.emf.cdo.security.ObjectPermission; import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.cdo.view.CDOView; @@ -58,7 +58,7 @@ public abstract class ObjectPermissionImpl extends PermissionImpl implements Obj protected CDOView getView(CDORevisionProvider revisionProvider) { - return ViewUtil.getView(revisionProvider); + return PermissionUtil.getView(revisionProvider); } /** diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/OrFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/OrFilterImpl.java index 34aca9e061..bb174e6c83 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/OrFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/OrFilterImpl.java @@ -44,11 +44,14 @@ public class OrFilterImpl extends CombinedFilterImpl implements OrFilter return SecurityPackage.Literals.OR_FILTER; } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { + ++level; for (PermissionFilter operand : getOperands()) { - if (operand.isApplicable(revision, revisionProvider, securityContext)) + if (operand.isApplicable(revision, revisionProvider, securityContext, level)) { return true; } diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PackageFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PackageFilterImpl.java index f187946057..6764a18aed 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PackageFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PackageFilterImpl.java @@ -68,7 +68,9 @@ public class PackageFilterImpl extends PermissionFilterImpl implements PackageFi eSet(SecurityPackage.Literals.PACKAGE_FILTER__APPLICABLE_PACKAGE, newApplicablePackage); } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { EPackage actualPackage = revision.getEClass().getEPackage(); EPackage applicablePackage = getApplicablePackage(); @@ -85,7 +87,7 @@ public class PackageFilterImpl extends PermissionFilterImpl implements PackageFi label = applicablePackage.getName(); } - return "package==" + label; + return "package == " + label; } } // PackageFilterImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionFilterImpl.java index e9e7afda91..373f66ba90 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionFilterImpl.java @@ -2,11 +2,19 @@ */ package org.eclipse.emf.cdo.security.impl; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; +import org.eclipse.emf.cdo.internal.security.bundle.OM; import org.eclipse.emf.cdo.security.PermissionFilter; import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.internal.cdo.CDOObjectImpl; +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.om.trace.ContextTracer; + import org.eclipse.emf.ecore.EClass; /** @@ -21,6 +29,8 @@ import org.eclipse.emf.ecore.EClass; */ public abstract class PermissionFilterImpl extends CDOObjectImpl implements PermissionFilter { + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, PermissionFilterImpl.class); + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -53,4 +63,50 @@ public abstract class PermissionFilterImpl extends CDOObjectImpl implements Perm return 0; } + public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, + CDOBranchPoint securityContext, int level) throws Exception + { + String msg = StringUtil.NL; + boolean tracing = TRACER.isEnabled(); + if (tracing) + { + msg = StringUtil.create(' ', level << 1) + getClass().getSimpleName() + ": " + format(); + TRACER.trace(msg); + } + + boolean result = false; + + try + { + result = filter(revision, revisionProvider, securityContext, level); + } + catch (Exception ex) + { + if (tracing) + { + TRACER.trace(ex); + } + } + finally + { + if (tracing) + { + TRACER.trace(msg + " --> " + result); + } + } + + return result; + } + + protected abstract boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, + CDOBranchPoint securityContext, int level) throws Exception; + + /** + * @since 4.3 + */ + protected final String getUser() + { + return PermissionUtil.getUser(); + } + } // PermissionFilterImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java index f08d5406dc..79fe38fb1e 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.security.impl; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Role; @@ -107,4 +108,11 @@ public abstract class PermissionImpl extends CDOObjectImpl implements Permission eSet(SecurityPackage.Literals.PERMISSION__ACCESS, newAccess); } + /** + * @since 4.3 + */ + protected final String getUser() + { + return PermissionUtil.getUser(); + } } // PermissionImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ResourceFilterImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ResourceFilterImpl.java index 14822b3e95..6f994f23b5 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ResourceFilterImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/ResourceFilterImpl.java @@ -33,6 +33,8 @@ import java.util.regex.PatternSyntaxException; */ public class ResourceFilterImpl extends PermissionFilterImpl implements ResourceFilter { + private static final String USER_TOKEN = "${user}"; + private static final Pattern OMNI_PATTERN = Pattern.compile(".*"); private Pattern pattern; @@ -98,7 +100,9 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource eSet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUSION, newInclusion); } - public boolean isApplicable(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { if (revisionProvider == null) { @@ -133,7 +137,7 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource } String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getPath(); + String path = getSubstitutedPath(); return revisionPath.equals(path); } @@ -146,7 +150,7 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource } String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getPath(); + String path = getSubstitutedPath(); int length = revisionPath.length(); if (length > path.length()) @@ -161,7 +165,7 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource private boolean includesExactAndDown(CDORevision revision, CDORevisionProvider revisionProvider) { String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getPath(); + String path = getSubstitutedPath(); int length = path.length(); if (length > revisionPath.length()) @@ -177,7 +181,7 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource { if (pattern == null) { - String path = getPath(); + String path = getSubstitutedPath(); pattern = compilePattern(path); if (pattern == null) @@ -197,6 +201,24 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource return matcher.matches(); } + private String getSubstitutedPath() + { + String path = getPath(); + int pos = path.indexOf(USER_TOKEN); + if (pos != -1) + { + String user = getUser(); + if (user == null || user.length() == 0) + { + throw new IllegalStateException("User required for evaluation of path " + path); + } + + path = path.substring(0, pos) + user + path.substring(pos + USER_TOKEN.length()); + } + + return path; + } + private Pattern compilePattern(String value) { if (value == null) @@ -226,9 +248,9 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource String path = getPath(); if (path != null) { - if (path.startsWith("/")) + if (!path.startsWith("/")) { - path = path.substring(1); + path = "/" + path; } label = path; @@ -244,16 +266,16 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource switch (inclusion) { case EXACT: - return "=="; + return " == "; case EXACT_AND_UP: - return "<="; + return " <= "; case EXACT_AND_DOWN: - return ">="; + return " >= "; case REGEX: - return "~>"; + return " >~ "; default: throw new IllegalStateException("Unhandled inclusion value: " + inclusion); diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java index 39854b30a4..ea055ddbb3 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java @@ -17,14 +17,15 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; import org.eclipse.emf.cdo.internal.security.ViewCreator; -import org.eclipse.emf.cdo.internal.security.ViewUtil; import org.eclipse.emf.cdo.net4j.CDONet4jSession; import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration; import org.eclipse.emf.cdo.net4j.CDONet4jUtil; import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; +import org.eclipse.emf.cdo.security.Inclusion; import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.Role; @@ -78,6 +79,8 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage { private static final Map<IRepository, InternalSecurityManager> SECURITY_MANAGERS = new HashMap<IRepository, InternalSecurityManager>(); + private static final String DEFAULT_HOME_FOLDER = "/home"; + private final IListener repositoryListener = new LifecycleEventAdapter() { @Override @@ -444,9 +447,12 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage boolean firstTime = !transaction.hasResource(realmPath); if (firstTime) { - CDOResource resource = transaction.createResource(realmPath); + transaction.createResourceFolder(DEFAULT_HOME_FOLDER); realm = createRealm(); + + CDOResource resource = transaction.createResource(realmPath); resource.getContents().add(realm); + OM.LOG.info("Security realm created in " + realmPath); } else @@ -508,21 +514,32 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage treeWriterRole.getPermissions().add( factory.createFilterPermission(Access.WRITE, factory.createPackageFilter(EresourcePackage.eINSTANCE))); + Role homeFolderOwnerRole = realm.addRole("Home Folder Owner"); + homeFolderOwnerRole.getPermissions().add( + factory.createFilterPermission(Access.WRITE, + factory.createResourceFilter(DEFAULT_HOME_FOLDER + "/${user}", Inclusion.EXACT_AND_DOWN))); + homeFolderOwnerRole.getPermissions().add( + factory.createFilterPermission(Access.READ, + factory.createResourceFilter(DEFAULT_HOME_FOLDER, Inclusion.EXACT_AND_UP))); + Role adminRole = realm.addRole("Administration"); adminRole.getPermissions().add( - factory.createFilterPermission( - Access.WRITE, - factory.createAndFilter(factory.createResourceFilter(realmPath), - factory.createNotFilter(factory.createClassFilter(SecurityPackage.Literals.USER_PASSWORD))))); + factory.createFilterPermission(Access.WRITE, + factory.createResourceFilter(DEFAULT_HOME_FOLDER, Inclusion.EXACT_AND_UP))); + adminRole.getPermissions() + .add( + factory.createFilterPermission(Access.WRITE, + factory.createResourceFilter(realmPath, Inclusion.EXACT_AND_DOWN))); + adminRole.getPermissions().add( + factory.createFilterPermission(Access.READ, factory.createResourceFilter(realmPath, Inclusion.EXACT_AND_UP))); // Create groups Group adminsGroup = realm.addGroup("Administrators"); - adminsGroup.getRoles().add(treeReaderRole); adminsGroup.getRoles().add(adminRole); Group usersGroup = realm.addGroup("Users"); - usersGroup.getRoles().add(treeReaderRole); + usersGroup.getRoles().add(homeFolderOwnerRole); // Create users @@ -559,33 +576,42 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage protected CDOPermission getPermission(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, ISession session, User user) { - CDOPermission result = convertPermission(user.getDefaultAccess()); - if (result == CDOPermission.WRITE) - { - return result; - } + PermissionUtil.setUser(user.getId()); - EList<Permission> allPermissions = user.getAllPermissions(); - for (Permission permission : allPermissions) + try { - CDOPermission p = convertPermission(permission.getAccess()); - if (p.ordinal() <= result.ordinal()) + CDOPermission result = convertPermission(user.getDefaultAccess()); + if (result == CDOPermission.WRITE) { - // Avoid expensive calls to Permission.isApplicable() if the permission wouldn't increase - continue; + return result; } - if (permission.isApplicable(revision, revisionProvider, securityContext)) + EList<Permission> allPermissions = user.getAllPermissions(); + for (Permission permission : allPermissions) { - result = p; - if (result == CDOPermission.WRITE) + CDOPermission p = convertPermission(permission.getAccess()); + if (p.ordinal() <= result.ordinal()) { - return result; + // Avoid expensive calls to Permission.isApplicable() if the permission wouldn't increase + continue; + } + + if (permission.isApplicable(revision, revisionProvider, securityContext)) + { + result = p; + if (result == CDOPermission.WRITE) + { + return result; + } } } - } - return result; + return result; + } + finally + { + PermissionUtil.setUser(null); + } } @Override @@ -650,7 +676,6 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage String userID = session.getUserID(); if (SYSTEM_USER_ID.equals(userID)) { - // TODO Should we also check for access to the /security resource (the realm)? return CDOPermission.WRITE; } @@ -662,7 +687,6 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage { if (SYSTEM_USER_ID.equals(userID)) { - // TODO Should we also check for access to the /security resource (the realm)? return CDOPermission.WRITE; } @@ -672,12 +696,17 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage private CDOPermission doGetPermission(CDORevision revision, final CDOBranchPoint securityContext, final ISession session, String userID) { + if (revision.getEClass() == SecurityPackage.Literals.USER_PASSWORD) + { + return CDOPermission.NONE; + } + User user = getUser(userID); InternalCDORevisionManager revisionManager = repository.getRevisionManager(); CDORevisionProvider revisionProvider = new ManagedRevisionProvider(revisionManager, securityContext); - ViewUtil.initViewCreation(new ViewCreator() + PermissionUtil.initViewCreation(new ViewCreator() { public CDOView createView(CDORevisionProvider revisionProvider) { @@ -691,7 +720,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage } finally { - ViewUtil.doneViewCreation(); + PermissionUtil.doneViewCreation(); } } } @@ -715,7 +744,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage handleCommit(commitContext, user); - ViewUtil.initViewCreation(new ViewCreator() + PermissionUtil.initViewCreation(new ViewCreator() { public CDOView createView(CDORevisionProvider revisionProvider) { @@ -725,12 +754,12 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage try { - permissionRevisionsBeforeCommitting(commitContext, securityContext, user, commitContext.getNewObjects()); + // permissionRevisionsBeforeCommitting(commitContext, securityContext, user, commitContext.getNewObjects()); permissionRevisionsBeforeCommitting(commitContext, securityContext, user, commitContext.getDirtyObjects()); } finally { - ViewUtil.doneViewCreation(); + PermissionUtil.doneViewCreation(); } } diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java index b209c09829..efac9096a8 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java @@ -1055,7 +1055,7 @@ public class TransactionCommitContext implements InternalCommitContext if (!dirtyObjects[i].isWritable()) { - throw new NoPermissionException(dirtyObjects[i], this); + throw new NoPermissionException(dirtyObjects[i]); } monitor.worked(); diff --git a/plugins/org.eclipse.emf.cdo.ui.shared/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui.shared/META-INF/MANIFEST.MF index 6a911dc7e6..e7b78b8534 100644 --- a/plugins/org.eclipse.emf.cdo.ui.shared/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.ui.shared/META-INF/MANIFEST.MF @@ -2,15 +2,15 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo.ui.shared;singleton:=true -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.2.0.qualifier Bundle-Activator: org.eclipse.emf.cdo.ui.internal.shared.bundle.OM$Activator Bundle-Vendor: %providerName Bundle-ClassPath: . Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.emf.cdo.ui.shared;version="4.1.0", - org.eclipse.emf.cdo.ui.internal.shared.bundle;version="4.1.0";x-internal:=true +Export-Package: org.eclipse.emf.cdo.ui.shared;version="4.2.0", + org.eclipse.emf.cdo.ui.internal.shared.bundle;version="4.2.0";x-internal:=true Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.net4j.util;bundle-version="[3.1.0,4.0.0)" diff --git a/plugins/org.eclipse.emf.cdo.ui.shared/icons/full/wizban/OpenSession.gif b/plugins/org.eclipse.emf.cdo.ui.shared/icons/full/wizban/OpenSession.gif Binary files differnew file mode 100644 index 0000000000..22a34edea9 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.ui.shared/icons/full/wizban/OpenSession.gif diff --git a/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/shared/SharedIcons.java b/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/shared/SharedIcons.java index d726cfe15d..3bba771b18 100644 --- a/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/shared/SharedIcons.java +++ b/plugins/org.eclipse.emf.cdo.ui.shared/src/org/eclipse/emf/cdo/ui/shared/SharedIcons.java @@ -172,6 +172,11 @@ public class SharedIcons private static final String WIZBAN = "wizban/"; //$NON-NLS-1$ + /** + * @since 4.2 + */ + public static final String WIZBAN_OPEN_SESSION = WIZBAN + "OpenSession" + IMAGE_FORMAT_GIF; //$NON-NLS-1$ + public static final String WIZBAN_PACKAGE_MANAGER = WIZBAN + "PackageManager" + IMAGE_FORMAT_GIF; //$NON-NLS-1$ public static final String WIZBAN_PROTOCOL_PROBLEM = WIZBAN + "ProtocolProblem" + IMAGE_FORMAT_GIF; //$NON-NLS-1$ diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java index ec02e140de..82cb320870 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java @@ -61,7 +61,9 @@ public class OpenSessionDialog extends TitleAreaDialog protected Control createDialogArea(Composite parent) { setTitle(TITLE); - setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_PACKAGE_MANAGER)); + setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_OPEN_SESSION)); + setMessage(Messages.getString("OpenSessionDialog.1")); + sessionComposite = new SessionComposite(parent, SWT.NONE); return sessionComposite; } diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties index 2edc45cddb..ae5d54c223 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties @@ -14,6 +14,8 @@ # This properties file contains all strings subject to be shown in the UI. # ============================================================================== + + AbstractLockObjectsAction.0=Error AbstractLockObjectsAction.1=Cannot obtain locks AsyncContentProvider_0=Pending... @@ -27,9 +29,9 @@ BulkAddDialog.3=Instances: BulkAddDialog.4=Select a feature BulkAddDialog.5=Enter a valid number of instances (>0) CDOActionBarContributor_0=Lock -CDOEditor.1=Open Target Time Slider CDOEditor.17=Transaction error CDOEditor.18=A commit error occured. See error log for details. +CDOEditor.1=Open Target Time Slider CDOEditor.23=New Root CDOEditor.26=Bulk Add CDOEditor.27=Calculating... @@ -64,21 +66,21 @@ CDOUIPreferencePage.0=Label decoration: CDOUIPreferencePage.1=Enable CDOEditor Auto-Reload CDOUIPreferencePage.2=Available tags: CDOWatchListView.0=Object -CDOWatchListView.1=Resource CDOWatchListView.10=Reset All Changes CDOWatchListView.11=Reset all change notifications of the subscriptions in the view CDOWatchListView.12=CREATE -CDOWatchListView.2=Time +CDOWatchListView.1=Resource CDOWatchListView.25=SET CDOWatchListView.26=UNSET CDOWatchListView.27=ADD CDOWatchListView.28=REMOVE CDOWatchListView.29=ADD MANY -CDOWatchListView.3=Changes +CDOWatchListView.2=Time CDOWatchListView.30=REMOVE MANY CDOWatchListView.31=MOVE CDOWatchListView.32=REMOVING ADAPTER CDOWatchListView.33=RESOLVE +CDOWatchListView.3=Changes CDOWatchListView.4=Remove CDOWatchListView.5=Remove selected subscriptions CDOWatchListView.6=Remove All @@ -86,8 +88,6 @@ CDOWatchListView.7=Remove all subscriptions CDOWatchListView.8=Reset Changes CDOWatchListView.9=Reset all change notifications from the selected subscriptions ChangePassiveUpdateAction.1=Passive Updates -SwitchTargetAction.0=Switch Target -SwitchTargetAction.1=Switch the target branch point CloseSessionAction.0=Close CloseSessionAction.1=Close the CDO session CloseSessionAction.2=You have uncommitted changes. Do you want to discard them? @@ -96,30 +96,27 @@ CloseViewAction.1=Close the CDO view CloseViewAction.2=You have uncommitted changes. Do you want to discard them? CommitTransactionAction.0=Commit CommitTransactionAction.1=Commit this transaction - -Title.Folder=New Folder -Tooltip.Folder=Create a new resource folder -Title.Model=New Model Resource -Tooltip.Model=Create a new model resource -Title.Text=New Text Resource -Tooltip.Text=Create a new text resource -Title.Binary=New Binary Resource -Tooltip.Binary=Create a new binary resource - -NewResourceNodeAction.2=Name must not contain path separators -NewResourceNodeAction.3=Folder name cannot be empty -NewResourceNodeAction.4=Resource name cannot be empty -NewResourceNodeAction.5=There exists a folder with name -NewResourceNodeAction.6=There exists a resource with name -NewResourceNodeAction.8=Please enter the name: +CreateBranchAction.0=Create Branch +CreateBranchAction.1=Create a new branch +DisableViewDurabilityAction.0=Make Not Durable +DisableViewDurabilityAction.1=Make this view not durable +EnableViewDurabilityAction.0=Make Durable +EnableViewDurabilityAction.1=Make this view durable ExportResourceAction.1=Export Resource ExportResourceAction.2=Export a CDO resource ExportResourceAction.3=A single URI must be entered\! +ExportResourceActionDelegate.0=Couldn't Export CDOResource ExportResourceDialog.1=Source path: +ExportSelectedResourceAction_0=Export Resource +ExportSelectedResourceAction_1=Export CDOResource +ExportSelectedResourceAction_2=No URI has been introduced ImportResourceAction.1=Import Resource ImportResourceAction.2=Import a CDO resource ImportResourceAction.3=A single URI must be entered\! +ImportResourceActionDelegate.0=Couldn't Import CDOResource ImportResourceDialog.1=Target path: +ImportResourceToFolderAction_0=Import Resource +ImportResourceToFolderAction_1=No URI has been introduced ImportRootsAction.1=Import Roots LoadResourceAction.0=Load Resource LoadResourceAction.1=Load a CDO resource @@ -128,8 +125,17 @@ LoadResourceAction.3=The specified resource {0} does not exist LoadResourceAction.4=Enter resource path: ManagePackagesAction.0=Package Registry ManagePackagesAction.1=Browse and register model packages -CreateBranchAction.0=Create Branch -CreateBranchAction.1=Create a new branch +NewBinaryResourceAction_0=Creating CDO binary resource +NewResourceAction_0=Creating CDO resource +NewResourceFolderAction_0=Creating CDO folder +NewResourceNodeAction.2=Name must not contain path separators +NewResourceNodeAction.3=Folder name cannot be empty +NewResourceNodeAction.4=Resource name cannot be empty +NewResourceNodeAction.5=There exists a folder with name +NewResourceNodeAction.6=There exists a resource with name +NewResourceNodeAction.8=Please enter the name: +NewResourceNodeAction_0=Enter the name +NewTextResourceAction_0=Creating CDO text resource OpenAuditAction.0=Open Audit View... OpenAuditAction.1=Open a new audit view OpenAuditDialog.0=Open Audit View @@ -138,9 +144,14 @@ OpenDurableViewAction.0=Open Durable View OpenDurableViewAction.1=Open an existing durable view OpenDurableViewDialog.0=Open Durable View OpenDurableViewDialog.1=Area ID: +OpenFileEditorAction.0=Open File Editor +OpenFileEditorAction.1=Open a file editor for this resource +OpenResourceEditorAction.0=Open Editor +OpenResourceEditorAction.1=Open a model editor for this resource OpenSessionAction.0=Open a new session OpenSessionAction.3=Unable to open a session on the specified repository.\n\n OpenSessionDialog.0=Open Session +OpenSessionDialog.1=Enter the server description and repository name. OpenTransactionAction.0=Open Transaction OpenTransactionAction.1=Open a new read-write view OpenViewAction.0=Open Read-Only View @@ -171,10 +182,11 @@ RegisterPackagesAction.0=Failed to register package {0} RegisterPackagesAction.1=\ {0} package has not been registered due to errors.\nSee the log for details. RegisterPackagesAction.2=\ {0} packages have not been registered due to errors.\nSee the log for details. RegisterSinglePackageAction.0=Register the package -EnableViewDurabilityAction.0=Make Durable -EnableViewDurabilityAction.1=Make this view durable -DisableViewDurabilityAction.0=Make Not Durable -DisableViewDurabilityAction.1=Make this view not durable +RemoveResourceAction_1=Delete Resource +RemoveResourceAction_2=Are you sure you want to delete the selected {0} item(s)? +RemoveResourceAction_3=Deleting CDOResource(s) +RemoveResourceAction_4={0}: Cannot perform commit +RenameResourceActionDelegate.0=Rename RollbackTransactionAction.0=Rollback RollbackTransactionAction.1=Rollback this transaction RollbackTransactionDialog.0=This transaction contains: @@ -189,27 +201,16 @@ SessionComposite.0=Server Description: SessionComposite.1=for example 'tcp://dev.eclipse.org:2036' SessionComposite.2=Repository Name: SessionComposite.3=Automatic Package Registry -WriteLockObjectsAction.1=Write Lock -ExportSelectedResourceAction_0=Export Resource -ImportResourceActionDelegate.0=Couldn't Import CDOResource -ImportResourceToFolderAction_0=Import Resource -ImportResourceToFolderAction_1=No URI has been introduced -NewResourceAction_0=Creating CDO resource -NewResourceFolderAction_0=Creating CDO folder -NewTextResourceAction_0=Creating CDO text resource -NewBinaryResourceAction_0=Creating CDO binary resource -NewResourceNodeAction_0=Enter the name -RemoveResourceAction_1=Delete Resource -RemoveResourceAction_2=Are you sure you want to delete the selected {0} item(s)? -RemoveResourceAction_3=Deleting CDOResource(s) -RemoveResourceAction_4={0}: Cannot perform commit -RenameResourceActionDelegate.0=Rename +SwitchTargetAction.0=Switch Target +SwitchTargetAction.1=Switch the target branch point +Title.Binary=New Binary Resource +Title.Folder=New Folder +Title.Model=New Model Resource +Title.Text=New Text Resource +Tooltip.Binary=Create a new binary resource +Tooltip.Folder=Create a new resource folder +Tooltip.Model=Create a new model resource +Tooltip.Text=Create a new text resource TransactionalBackgroundAction_0=Object is not transactional: {0} TransactionalBackgroundAction_1=Commit Transaction -ExportResourceActionDelegate.0=Couldn't Export CDOResource -ExportSelectedResourceAction_1=Export CDOResource -ExportSelectedResourceAction_2=No URI has been introduced -OpenFileEditorAction.0=Open File Editor -OpenFileEditorAction.1=Open a file editor for this resource -OpenResourceEditorAction.0=Open Editor -OpenResourceEditorAction.1=Open a model editor for this resource +WriteLockObjectsAction.1=Write Lock diff --git a/plugins/org.eclipse.emf.cdo.workspace.efs/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.workspace.efs/META-INF/MANIFEST.MF index 79815b26fc..ddb37bfde2 100644 --- a/plugins/org.eclipse.emf.cdo.workspace.efs/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.workspace.efs/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.workspace.efs;singleton:=true -Bundle-Version: 4.0.100.qualifier +Bundle-Version: 4.0.200.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -16,6 +16,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.emf.cdo.workspace;bundle-version="[4.0.0,5.0.0)";visibility:=reexport Import-Package: org.h2;version="[1.0.0,2.0.0)", org.h2.jdbcx;version="[1.0.0,2.0.0)" -Export-Package: org.eclipse.emf.cdo.workspace.efs;version="4.0.100", - org.eclipse.emf.cdo.workspace.internal.efs;version="4.0.100";x-friends:="org.eclipse.emf.cdo.ui.workspace", - org.eclipse.emf.cdo.workspace.internal.efs.bundle;version="4.0.100";x-internal:=true +Export-Package: org.eclipse.emf.cdo.workspace.efs;version="4.0.200", + org.eclipse.emf.cdo.workspace.internal.efs;version="4.0.200";x-friends:="org.eclipse.emf.cdo.ui.workspace", + org.eclipse.emf.cdo.workspace.internal.efs.bundle;version="4.0.200";x-internal:=true diff --git a/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java b/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java index b7f650ff20..b14f6331e8 100644 --- a/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java +++ b/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java @@ -62,7 +62,7 @@ public final class CDOFS public static CDOWorkspace open(String projectName, File projectFolder) throws Exception { - IDBStore local = creatLocalStore(projectFolder); + IDBStore local = createLocalStore(projectFolder); CDOWorkspaceBase base = createWorkspaceBase(new File(projectFolder, "base")); IRepositoryLocation remote = readRepositoryLocation(projectFolder); @@ -101,7 +101,7 @@ public final class CDOFS private static URI checkout(ICheckoutSource checkoutSource, String projectName, File projectFolder) throws Exception { - IDBStore local = creatLocalStore(projectFolder); + IDBStore local = createLocalStore(projectFolder); CDOWorkspaceBase base = createWorkspaceBase(new File(projectFolder, "base")); IRepositoryLocation remote = checkoutSource.getRepositoryLocation(); @@ -127,7 +127,7 @@ public final class CDOFS return (CDOWorkspaceFileSystem)EFS.getFileSystem(CDOWorkspaceFileSystem.SCHEME); } - private static IDBStore creatLocalStore(File projectFolder) + private static IDBStore createLocalStore(File projectFolder) { IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false); IDBAdapter dbAdapter = createLocalAdapter(); 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); diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java index c75be7150c..90202d5de6 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/StringUtil.java @@ -14,6 +14,7 @@ import org.eclipse.net4j.util.om.OMPlatform; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.Arrays; /** * Various static helper methods for dealing with strings. @@ -31,6 +32,16 @@ public final class StringUtil } /** + * @since 3.4 + */ + public static String create(char c, int length) + { + char[] chars = new char[length]; + Arrays.fill(chars, c); + return new String(chars); + } + + /** * @since 2.0 */ public static String formatException(Throwable t) |