diff options
55 files changed, 2982 insertions, 1164 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java index 2475856f85..05ce1f2a81 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java @@ -39,26 +39,35 @@ public class CDORevisionImpl extends BaseCDORevision protected CDORevisionImpl(CDORevisionImpl source) { super(source); - EStructuralFeature[] features = clearValues(); - int length = features.length; - for (int i = 0; i < length; i++) + try { - EStructuralFeature feature = features[i]; - if (feature.isMany()) + bypassPermissionChecks(true); + EStructuralFeature[] features = clearValues(); + + int length = features.length; + for (int i = 0; i < length; i++) { - InternalCDOList sourceList = (InternalCDOList)source.values[i]; - if (sourceList != null) + EStructuralFeature feature = features[i]; + if (feature.isMany()) { - EClassifier classifier = feature.getEType(); - setValue(i, sourceList.clone(classifier)); + InternalCDOList sourceList = (InternalCDOList)source.values[i]; + if (sourceList != null) + { + EClassifier classifier = feature.getEType(); + setValue(i, sourceList.clone(classifier)); + } + } + else + { + CDOType type = CDOModelUtil.getType(feature); + setValue(i, type.copyValue(source.values[i])); } } - else - { - CDOType type = CDOModelUtil.getType(feature); - setValue(i, type.copyValue(source.values[i])); - } + } + finally + { + bypassPermissionChecks(false); } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java index d9404f405a..c3500d8569 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java @@ -81,16 +81,17 @@ public abstract class BaseCDORevision extends AbstractCDORevision private static final byte SET_NOT_NULL_OPCODE = 2; - /** - * private static final byte READ_PERMISSION_FLAG = 0x01; - * - * private static final byte WRITE_PERMISSION_FLAG = 0x02; - */ - private static final byte FROZEN_FLAG = 0x04; + private static final byte READ_PERMISSION_FLAG = 1 << 0; // 1 + + private static final byte WRITE_PERMISSION_FLAG = 1 << 1; // 2 + + private static final byte FROZEN_FLAG = 1 << 2; // 4 - private static final byte UNCHUNKED_FLAG = 0x08; + private static final byte UNCHUNKED_FLAG = 1 << 3; // 8 - private static final byte PERMISSION_MASK = 0x03; + private static final byte BYPASS_PERMISSION_CHECKS_FLAG = 1 << 4; // 16 + + private static final byte PERMISSION_MASK = READ_PERMISSION_FLAG | WRITE_PERMISSION_FLAG; // 3 private CDOID id; @@ -155,10 +156,11 @@ public abstract class BaseCDORevision extends AbstractCDORevision readSystemValues(in); - byte flagBits = in.readByte(); // Don't set permissions into this.falgs before readValues() - flagBits |= UNCHUNKED_FLAG; // First assume all lists are unchunked; may be revised below + flags = in.readByte(); // Don't set permissions into this.falgs before readValues() + flags |= UNCHUNKED_FLAG; // First assume all lists are unchunked; may be revised below + flags |= BYPASS_PERMISSION_CHECKS_FLAG; // Temporarily disable permission checking to be able to set the read values - if ((flagBits & PERMISSION_MASK) == CDOPermission.NONE.ordinal()) + if ((flags & PERMISSION_MASK) == CDOPermission.NONE.ordinal()) { if (getClassInfo().isResourceNode()) { @@ -172,11 +174,12 @@ public abstract class BaseCDORevision extends AbstractCDORevision { if (!readValues(in)) { - flagBits &= ~UNCHUNKED_FLAG; + flags &= ~UNCHUNKED_FLAG; } } - flags = flagBits; + // Enable permission checking + flags &= ~BYPASS_PERMISSION_CHECKS_FLAG; if (READING.isEnabled()) { @@ -783,6 +786,25 @@ public abstract class BaseCDORevision extends AbstractCDORevision } /** + * @since 4.3 + */ + public boolean bypassPermissionChecks(boolean on) + { + boolean old = (flags & BYPASS_PERMISSION_CHECKS_FLAG) != 0; + + if (on) + { + flags |= BYPASS_PERMISSION_CHECKS_FLAG; + } + else + { + flags &= ~BYPASS_PERMISSION_CHECKS_FLAG; + } + + return old; + } + + /** * @since 4.1 */ public void freeze() @@ -889,12 +911,17 @@ public abstract class BaseCDORevision extends AbstractCDORevision private void checkReadable(EStructuralFeature feature) { + if ((flags & BYPASS_PERMISSION_CHECKS_FLAG) != 0) + { + return; + } + if (CDOModelUtil.isResourcePathFeature(feature)) { return; } - if (!isReadable()) + if ((flags & READ_PERMISSION_FLAG) == 0) { throw new NoPermissionException(this); } @@ -902,7 +929,12 @@ public abstract class BaseCDORevision extends AbstractCDORevision private void checkWritable() { - if (!isWritable()) + if ((flags & BYPASS_PERMISSION_CHECKS_FLAG) != 0) + { + return; + } + + if ((flags & WRITE_PERMISSION_FLAG) == 0) { throw new NoPermissionException(this); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java index 39ffd031db..bf93c5d84c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java @@ -416,6 +416,14 @@ public abstract class DelegatingCDORevision implements InternalCDORevision } /** + * @since 4.3 + */ + public boolean bypassPermissionChecks(boolean on) + { + return getDelegate().bypassPermissionChecks(on); + } + + /** * @since 4.0 */ public void freeze() diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java index 727bcde0f0..26ec0f652e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java @@ -156,6 +156,17 @@ public interface InternalCDORevision extends CDORevision, CDORevisionData, CDORe public void setPermission(CDOPermission permission); /** + * Enables or disables permission checking for this revision. + * <p> + * This method is used on the client side if the framework changes the revision on another + * user's behalf, e.g., during invalidation or general revision copying. It's safe to offer this method + * on the client side because the server is always the permission checking authority (during load or commit). + * + * @since 4.3 + */ + public boolean bypassPermissionChecks(boolean on); + + /** * @since 4.0 */ public void freeze(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java index 0d41c93f39..dd9b7994ac 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java @@ -310,6 +310,14 @@ public class StubCDORevision extends AbstractCDORevision } /** + * @since 4.3 + */ + public boolean bypassPermissionChecks(boolean on) + { + throw new UnsupportedOperationException(getExceptionMessage()); + } + + /** * @since 4.0 */ public void freeze() diff --git a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml index bf9c41223c..be3dd9b6fc 100644 --- a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml @@ -23,7 +23,9 @@ <property name="serializeCommits" value="false"/> <property name="optimisticLockingTimeout" value="10000"/> - <securityManager type="default" description="/security:annotation:home(/home)"/> + <!-- Example http://wiki.eclipse.org/CDO/Security_Manager + <securityManager type="default" description="/security:annotation:home(/home)"/> + --> <!-- Example http://bugs.eclipse.org/302775 <authenticator type="file" description="_database/repo1.users"/> diff --git a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml index bf9c41223c..be3dd9b6fc 100644 --- a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml @@ -23,7 +23,9 @@ <property name="serializeCommits" value="false"/> <property name="optimisticLockingTimeout" value="10000"/> - <securityManager type="default" description="/security:annotation:home(/home)"/> + <!-- Example http://wiki.eclipse.org/CDO/Security_Manager + <securityManager type="default" description="/security:annotation:home(/home)"/> + --> <!-- Example http://bugs.eclipse.org/302775 <authenticator type="file" description="_database/repo1.users"/> diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java index 17d9cb6ddd..362928185c 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java @@ -12,12 +12,15 @@ package org.eclipse.emf.cdo.internal.net4j.protocol; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.protocol.CDODataInput; import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; import org.eclipse.emf.spi.cdo.InternalCDOSession; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; /** * @author Eike Stepper @@ -36,6 +39,17 @@ public class CommitNotificationIndication extends CDOClientIndication CDOCommitInfo commitInfo = in.readCDOCommitInfo(); boolean clearResourcePathCache = in.readBoolean(); - session.handleCommitNotification(commitInfo, clearResourcePathCache); + Set<CDOID> readOnly = null; + int size = in.readInt(); + if (size != 0) + { + readOnly = new HashSet<CDOID>(); + for (int i = 0; i < size; i++) + { + readOnly.add(in.readCDOID()); + } + } + + session.handleCommitNotification(commitInfo, clearResourcePathCache, readOnly); } } diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java index d983875b3b..b2d5eaa12b 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java @@ -36,6 +36,7 @@ import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.internal.net4j.bundle.OM; import org.eclipse.emf.cdo.session.CDORepositoryInfo; import org.eclipse.emf.cdo.transaction.CDOTransaction; @@ -296,6 +297,7 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com result = confirmingResult(in); confirmingMappingNewObjects(in, result); confirmingNewLockStates(in, result); + confirmingNewPermissions(in, result); return result; } @@ -371,4 +373,19 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com result.setNewLockStates(newLockStates); } + + protected void confirmingNewPermissions(CDODataInput in, CommitTransactionResult result) throws IOException + { + if (in.readBoolean()) + { + int n = in.readInt(); + for (int i = 0; i < n; i++) + { + CDOID id = in.readCDOID(); + CDOPermission permission = in.readEnum(CDOPermission.class); + + result.addNewPermission(id, permission); + } + } + } } diff --git a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties index 2335720fa2..1415251b8e 100644 --- a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties @@ -133,3 +133,23 @@ _UI_Inclusion_Exact_literal = Exact _UI_Inclusion_ExactAndUp_literal = ExactAndUp _UI_Inclusion_ExactAndDown_literal = ExactAndDown _UI_Inclusion_Regex_literal = Regex +_UI_ResourceFilter_style_feature = Style +_UI_ResourceFilter_folders_feature = Folders +_UI_ResourceFilter_parentFolders_feature = Parent Folders +_UI_ResourceFilter_rootResource_feature = Root Resource +_UI_ResourceFilter_modelResources_feature = Model Resources +_UI_ResourceFilter_modelObjects_feature = Model Objects +_UI_ResourceFilter_textResources_feature = Text Resources +_UI_ResourceFilter_binaryResources_feature = Binary Resources +_UI_Style_EXACT_literal = EXACT +_UI_Style_ANT_literal = ANT +_UI_Style_REGEX_literal = REGEX +_UI_ResourceFilter_patternStyle_feature = Pattern Style +_UI_PatternStyle_NONE_literal = NONE +_UI_PatternStyle_ANT_literal = ANT +_UI_PatternStyle_REGEX_literal = REGEX +_UI_ResourceFilter_childNodes_feature = Child Nodes +_UI_ResourceFilter_includeParents_feature = Include Parents +_UI_ResourceFilter_includeRoot_feature = Include Root +_UI_PatternStyle_EXACT_literal = EXACT +_UI_PatternStyle_TREE_literal = TREE diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourceFilterItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourceFilterItemProvider.java index 575ca92929..361c112a93 100644 --- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourceFilterItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourceFilterItemProvider.java @@ -70,7 +70,14 @@ public class ResourceFilterItemProvider extends PermissionFilterItemProvider imp super.getPropertyDescriptors(object); addPathPropertyDescriptor(object); - addInclusionPropertyDescriptor(object); + addPatternStylePropertyDescriptor(object); + addFoldersPropertyDescriptor(object); + addTextResourcesPropertyDescriptor(object); + addBinaryResourcesPropertyDescriptor(object); + addModelResourcesPropertyDescriptor(object); + addModelObjectsPropertyDescriptor(object); + addIncludeParentsPropertyDescriptor(object); + addIncludeRootPropertyDescriptor(object); } return itemPropertyDescriptors; } @@ -93,21 +100,154 @@ public class ResourceFilterItemProvider extends PermissionFilterItemProvider imp } /** - * This adds a property descriptor for the Inclusion feature. + * This adds a property descriptor for the Pattern Style feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - protected void addInclusionPropertyDescriptor(Object object) + protected void addPatternStylePropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_patternStyle_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_patternStyle_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__PATTERN_STYLE, true, false, false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Folders feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addFoldersPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_folders_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_folders_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__FOLDERS, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Model Resources feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addModelResourcesPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_modelResources_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_modelResources_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__MODEL_RESOURCES, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Model Objects feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addModelObjectsPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_modelObjects_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_modelObjects_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__MODEL_OBJECTS, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Include Parents feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addIncludeParentsPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_includeParents_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_includeParents_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_PARENTS, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Include Root feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addIncludeRootPropertyDescriptor(Object object) { itemPropertyDescriptors.add(createItemPropertyDescriptor( ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), - getString("_UI_ResourceFilter_inclusion_feature"), //$NON-NLS-1$ + getString("_UI_ResourceFilter_includeRoot_feature"), //$NON-NLS-1$ getString( - "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_inclusion_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - SecurityPackage.Literals.RESOURCE_FILTER__INCLUSION, true, false, false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_includeRoot_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_ROOT, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Text Resources feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addTextResourcesPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_textResources_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_textResources_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__TEXT_RESOURCES, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Binary Resources feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void addBinaryResourcesPropertyDescriptor(Object object) + { + itemPropertyDescriptors + .add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ResourceFilter_binaryResources_feature"), //$NON-NLS-1$ + getString( + "_UI_PropertyDescriptor_description", "_UI_ResourceFilter_binaryResources_feature", "_UI_ResourceFilter_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.RESOURCE_FILTER__BINARY_RESOURCES, true, false, false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); } /** @@ -160,7 +300,14 @@ public class ResourceFilterItemProvider extends PermissionFilterItemProvider imp switch (notification.getFeatureID(ResourceFilter.class)) { case SecurityPackage.RESOURCE_FILTER__PATH: - case SecurityPackage.RESOURCE_FILTER__INCLUSION: + case SecurityPackage.RESOURCE_FILTER__PATTERN_STYLE: + case SecurityPackage.RESOURCE_FILTER__FOLDERS: + case SecurityPackage.RESOURCE_FILTER__TEXT_RESOURCES: + case SecurityPackage.RESOURCE_FILTER__BINARY_RESOURCES: + case SecurityPackage.RESOURCE_FILTER__MODEL_RESOURCES: + case SecurityPackage.RESOURCE_FILTER__MODEL_OBJECTS: + case SecurityPackage.RESOURCE_FILTER__INCLUDE_PARENTS: + case SecurityPackage.RESOURCE_FILTER__INCLUDE_ROOT: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } diff --git a/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters index e8bc0cd60a..aff44b4694 100644 --- a/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters +++ b/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters @@ -164,6 +164,12 @@ <filter id="403767336"> <message_arguments> <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="PATTERN_STYLE"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> <message_argument value="PERMISSION_FILTER"/> </message_arguments> </filter> @@ -188,12 +194,54 @@ <filter id="403767336"> <message_arguments> <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__BINARY_RESOURCES"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__FOLDERS"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__INCLUDE_PARENTS"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__INCLUDE_ROOT"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> <message_argument value="RESOURCE_FILTER__INCLUSION"/> </message_arguments> </filter> <filter id="403767336"> <message_arguments> <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__MODEL_OBJECTS"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__MODEL_RESOURCES"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__PARENT_FOLDERS"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> <message_argument value="RESOURCE_FILTER__PATH"/> </message_arguments> </filter> @@ -203,6 +251,36 @@ <message_argument value="RESOURCE_FILTER__PATTERN"/> </message_arguments> </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__PATTERN_STYLE"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__ROOT_RESOURCE"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__STYLE"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="RESOURCE_FILTER__TEXT_RESOURCES"/> + </message_arguments> + </filter> + <filter id="403767336"> + <message_arguments> + <message_argument value="org.eclipse.emf.cdo.security.SecurityPackage.Literals"/> + <message_argument value="STYLE"/> + </message_arguments> + </filter> </resource> <resource path="src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java" type="org.eclipse.emf.cdo.security.impl.SecurityFactoryImpl"> <filter id="1143996420"> 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 481b77cacf..37063813dd 100644 --- a/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF @@ -7,7 +7,16 @@ Bundle-ClassPath: . 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", +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.tests, + org.eclipse.emf.cdo.tests.db, + org.eclipse.emf.cdo.tests.db4o, + org.eclipse.emf.cdo.tests.hibernate, + org.eclipse.emf.cdo.tests.mongodb, + org.eclipse.emf.cdo.tests.objectivity", 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", diff --git a/plugins/org.eclipse.emf.cdo.security/model/security.ecore b/plugins/org.eclipse.emf.cdo.security/model/security.ecore index 8e0a263002..8e442a1d2f 100644 --- a/plugins/org.eclipse.emf.cdo.security/model/security.ecore +++ b/plugins/org.eclipse.emf.cdo.security/model/security.ecore @@ -123,8 +123,22 @@ </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="ResourceFilter" eSuperTypes="#//PermissionFilter"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="path" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="inclusion" eType="#//Inclusion" - defaultValueLiteral="Regex"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="patternStyle" eType="#//PatternStyle" + defaultValueLiteral="TREE"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="folders" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="textResources" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="binaryResources" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="modelResources" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="modelObjects" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="includeParents" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="includeRoot" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean" + defaultValueLiteral="true"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="ObjectFilter" abstract="true" eSuperTypes="#//PermissionFilter"/> <eClassifiers xsi:type="ecore:EClass" name="ExpressionFilter" eSuperTypes="#//ObjectFilter"> @@ -139,11 +153,11 @@ <eClassifiers xsi:type="ecore:EClass" name="NotFilter" eSuperTypes="#//CombinedFilter"/> <eClassifiers xsi:type="ecore:EClass" name="AndFilter" eSuperTypes="#//CombinedFilter"/> <eClassifiers xsi:type="ecore:EClass" name="OrFilter" eSuperTypes="#//CombinedFilter"/> - <eClassifiers xsi:type="ecore:EEnum" name="Inclusion"> - <eLiterals name="Exact"/> - <eLiterals name="ExactAndUp" value="1"/> - <eLiterals name="ExactAndDown" value="2"/> - <eLiterals name="Regex" value="3"/> + <eClassifiers xsi:type="ecore:EEnum" name="PatternStyle"> + <eLiterals name="EXACT"/> + <eLiterals name="TREE" value="1"/> + <eLiterals name="ANT" value="2" literal="ANT"/> + <eLiterals name="REGEX" value="3"/> </eClassifiers> <eClassifiers xsi:type="ecore:EEnum" name="Access"> <eLiterals name="READ"/> diff --git a/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag b/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag index 152ba22b3d..5ab3713da6 100644 --- a/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag +++ b/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag @@ -150,7 +150,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_PWGq0bIPEeGyraMqKGwiUw" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="security.ecore#//Permission"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_PWGq0rIPEeGyraMqKGwiUw" x="480" y="383" width="183"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_PWGq0rIPEeGyraMqKGwiUw" x="509" y="381" width="128"/> </children> <children xmi:type="notation:Node" xmi:id="_Fl308LIREeGyraMqKGwiUw" type="1005"> <children xmi:type="notation:Node" xmi:id="_Fl64QLIREeGyraMqKGwiUw" type="4010"/> @@ -169,7 +169,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_Fl4cALIREeGyraMqKGwiUw" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EEnum" href="security.ecore#//Access"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Fl4cAbIREeGyraMqKGwiUw" x="733" y="372" width="132"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_Fl4cAbIREeGyraMqKGwiUw" x="770" y="359" width="132"/> </children> <children xmi:type="notation:Node" xmi:id="_x3ZpwLIREeGyraMqKGwiUw" type="1001"> <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_x4HbcLIREeGyraMqKGwiUw" source="Shortcut"> @@ -281,7 +281,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_d7yd8R7pEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="platform:/resource/org.eclipse.emf.cdo.expressions/model/expressions.ecore#//Expression"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_d7yd8h7pEeOJ3sK94Szb0A" x="505" y="859" width="133"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_d7yd8h7pEeOJ3sK94Szb0A" x="505" y="895" width="133"/> </children> <children xmi:type="notation:Node" xmi:id="_maNXIB9qEeOJ3sK94Szb0A" type="1001"> <children xmi:type="notation:Node" xmi:id="_maN-MB9qEeOJ3sK94Szb0A" type="4001"/> @@ -359,9 +359,37 @@ <layoutConstraint xmi:type="notation:Location" xmi:id="_YxhecR9rEeOJ3sK94Szb0A"/> </children> <children xmi:type="notation:Node" xmi:id="_OEBegB-uEeOVLL3OCGcAvw" type="2001"> - <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/inclusion"/> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/patternStyle"/> <layoutConstraint xmi:type="notation:Location" xmi:id="_OEBegR-uEeOVLL3OCGcAvw"/> </children> + <children xmi:type="notation:Node" xmi:id="_h3qDwCNhEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/folders"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_h3qDwSNhEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_wPym8CNhEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/textResources"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_wPym8SNhEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_zmYIQCNhEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/binaryResources"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_zmYIQSNhEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_u0d4cCNhEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/modelResources"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_u0d4cSNhEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_0_aXwCNhEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/modelObjects"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_0_aXwSNhEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_WVBRkCNiEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/includeParents"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_WVBRkSNiEeONRetYxqOCDg"/> + </children> + <children xmi:type="notation:Node" xmi:id="_8HbG0CNiEeONRetYxqOCDg" type="2001"> + <element xmi:type="ecore:EAttribute" href="security.ecore#//ResourceFilter/includeRoot"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_8HbG0SNiEeONRetYxqOCDg"/> + </children> <styles xmi:type="notation:DrawerStyle" xmi:id="_6Lg-cR9qEeOJ3sK94Szb0A"/> <styles xmi:type="notation:SortingStyle" xmi:id="_6Lg-ch9qEeOJ3sK94Szb0A"/> <styles xmi:type="notation:FilteringStyle" xmi:id="_6Lg-cx9qEeOJ3sK94Szb0A"/> @@ -405,7 +433,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_HmsxMR9rEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="security.ecore#//AndFilter"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_HmsxMh9rEeOJ3sK94Szb0A" x="836" y="785"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_HmsxMh9rEeOJ3sK94Szb0A" x="815" y="896"/> </children> <children xmi:type="notation:Node" xmi:id="_JtuvIB9rEeOJ3sK94Szb0A" type="1001"> <children xmi:type="notation:Node" xmi:id="_JtwkUB9rEeOJ3sK94Szb0A" type="4001"/> @@ -421,7 +449,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_JtuvIR9rEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="security.ecore#//NotFilter"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JtuvIh9rEeOJ3sK94Szb0A" x="721" y="785"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_JtuvIh9rEeOJ3sK94Szb0A" x="700" y="896"/> </children> <children xmi:type="notation:Node" xmi:id="_KyDS4B9rEeOJ3sK94Szb0A" type="1001"> <children xmi:type="notation:Node" xmi:id="_KyEhAB9rEeOJ3sK94Szb0A" type="4001"/> @@ -437,7 +465,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_KyDS4R9rEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="security.ecore#//OrFilter"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_KyDS4h9rEeOJ3sK94Szb0A" x="956" y="785"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_KyDS4h9rEeOJ3sK94Szb0A" x="935" y="896"/> </children> <children xmi:type="notation:Node" xmi:id="_LwMWIB9rEeOJ3sK94Szb0A" type="1001"> <children xmi:type="notation:Node" xmi:id="_LwNkQB9rEeOJ3sK94Szb0A" type="4001"/> @@ -453,7 +481,7 @@ </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_LwMWIR9rEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> <element xmi:type="ecore:EClass" href="security.ecore#//CombinedFilter"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LwMWIh9rEeOJ3sK94Szb0A" x="820" y="665" width="124"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LwMWIh9rEeOJ3sK94Szb0A" x="870" y="665" width="124"/> </children> <children xmi:type="notation:Node" xmi:id="_lCpCEB98EeOJ3sK94Szb0A" type="1001"> <children xmi:type="notation:Node" xmi:id="_lCppIB98EeOJ3sK94Szb0A" type="4001"/> @@ -475,19 +503,19 @@ <children xmi:type="notation:Node" xmi:id="_0XPsYB-vEeOVLL3OCGcAvw" type="4010"/> <children xmi:type="notation:Node" xmi:id="_0XQ6gB-vEeOVLL3OCGcAvw" type="5008"> <children xmi:type="notation:Node" xmi:id="_9DwwkB-vEeOVLL3OCGcAvw" type="2006"> - <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//Inclusion/Exact"/> + <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//PatternStyle/EXACT"/> <layoutConstraint xmi:type="notation:Location" xmi:id="_9DwwkR-vEeOVLL3OCGcAvw"/> </children> + <children xmi:type="notation:Node" xmi:id="_eG9OICO1EeONRetYxqOCDg" type="2006"> + <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//PatternStyle/TREE"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_eG9OISO1EeONRetYxqOCDg"/> + </children> <children xmi:type="notation:Node" xmi:id="_46LFAB-vEeOVLL3OCGcAvw" type="2006"> - <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//Inclusion/ExactAndUp"/> + <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//PatternStyle/ANT"/> <layoutConstraint xmi:type="notation:Location" xmi:id="_46LFAR-vEeOVLL3OCGcAvw"/> </children> - <children xmi:type="notation:Node" xmi:id="_7nx6wB-vEeOVLL3OCGcAvw" type="2006"> - <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//Inclusion/ExactAndDown"/> - <layoutConstraint xmi:type="notation:Location" xmi:id="_7nx6wR-vEeOVLL3OCGcAvw"/> - </children> <children xmi:type="notation:Node" xmi:id="_NKZVkB-zEeOVLL3OCGcAvw" type="2006"> - <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//Inclusion/Regex"/> + <element xmi:type="ecore:EEnumLiteral" href="security.ecore#//PatternStyle/REGEX"/> <layoutConstraint xmi:type="notation:Location" xmi:id="_NKZVkR-zEeOVLL3OCGcAvw"/> </children> <styles xmi:type="notation:DrawerStyle" xmi:id="_0XQ6gR-vEeOVLL3OCGcAvw"/> @@ -495,8 +523,8 @@ <styles xmi:type="notation:FilteringStyle" xmi:id="_0XQ6gx-vEeOVLL3OCGcAvw"/> </children> <styles xmi:type="notation:ShapeStyle" xmi:id="_0XMCAR-vEeOVLL3OCGcAvw" fontColor="4210752" fontName="Segoe UI" fontHeight="10" fillColor="13761016" lineColor="8421504"/> - <element xmi:type="ecore:EEnum" href="security.ecore#//Inclusion"/> - <layoutConstraint xmi:type="notation:Bounds" xmi:id="_0XMCAh-vEeOVLL3OCGcAvw" x="740" y="460" width="118"/> + <element xmi:type="ecore:EEnum" href="security.ecore#//PatternStyle"/> + <layoutConstraint xmi:type="notation:Bounds" xmi:id="_0XMCAh-vEeOVLL3OCGcAvw" x="770" y="455" width="132"/> </children> <styles xmi:type="notation:DiagramStyle" xmi:id="_BlsqIawpEeGqBf0LMO47dg"/> <element xmi:type="ecore:EPackage" href="security.ecore#/"/> @@ -548,7 +576,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_Bl6skawpEeGqBf0LMO47dg" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_Bl6skqwpEeGqBf0LMO47dg" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Bl6sk6wpEeGqBf0LMO47dg" points="[-4, 0, 282, 97]$[-4, -31, 282, 66]$[-287, -31, -1, 66]$[-287, -97, -1, 0]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_Bl6sk6wpEeGqBf0LMO47dg" points="[3, 0, 289, 97]$[3, -31, 289, 66]$[-287, -31, -1, 66]$[-287, -97, -1, 0]"/> <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Bm8nUKwpEeGqBf0LMO47dg" id="(0.5,0.0)"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Bm8nUawpEeGqBf0LMO47dg" id="(0.5,1.0)"/> </edges> @@ -620,9 +648,9 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_pKXTEbIPEeGyraMqKGwiUw" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_pKXTErIPEeGyraMqKGwiUw" fontColor="4210752" fontName="Segoe UI" fontHeight="10"/> <element xmi:type="ecore:EReference" href="security.ecore#//Role/permissions"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pKXTE7IPEeGyraMqKGwiUw" points="[38, 39, 0, -102]$[38, 117, 0, -24]"/> - <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_2LxvoB-wEeOVLL3OCGcAvw" id="(0.10784313725490197,0.21568627450980393)"/> - <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_2LyWsB-wEeOVLL3OCGcAvw" id="(0.5,0.5)"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_pKXTE7IPEeGyraMqKGwiUw" points="[43, 39, 3, -100]$[43, 115, 3, -24]"/> + <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_gI80UCNjEeONRetYxqOCDg" id="(0.10784313725490197,0.21568627450980393)"/> + <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_gI80USNjEeONRetYxqOCDg" id="(0.5,0.5)"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_s4d8gLIPEeGyraMqKGwiUw" type="3002" source="_PWGq0LIPEeGyraMqKGwiUw" target="_BlzX26wpEeGqBf0LMO47dg"> <children xmi:type="notation:Node" xmi:id="_s4fxsLIPEeGyraMqKGwiUw" type="4011"> @@ -634,7 +662,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_s4d8gbIPEeGyraMqKGwiUw" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_s4ejkLIPEeGyraMqKGwiUw" fontColor="4210752" fontName="Segoe UI" fontHeight="10"/> <element xmi:type="ecore:EReference" href="security.ecore#//Permission/role"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_s4ejkbIPEeGyraMqKGwiUw" points="[0, -24, 38, 117]$[0, -102, 38, 39]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_s4ejkbIPEeGyraMqKGwiUw" points="[3, -24, 43, 115]$[3, -100, 43, 39]"/> <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_KDoVVLRkEeG4L6jPmHyTfg" id="(0.5,0.5)"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_KDo8YLRkEeG4L6jPmHyTfg" id="(0.10784313725490197,0.21568627450980393)"/> </edges> @@ -654,7 +682,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_7hNGgbSLEeGXB8zr6LLorg" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_7hNGgrSLEeGXB8zr6LLorg" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_7hNGg7SLEeGXB8zr6LLorg" points="[5, -20, 87, 80]$[5, -44, 87, 56]$[-83, -44, -1, 56]$[-83, -75, -1, 25]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_7hNGg7SLEeGXB8zr6LLorg" points="[-11, -33, 119, 80]$[-11, -57, 119, 56]$[-131, -57, -1, 56]$[-131, -88, -1, 25]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_8vTRULSLEeGXB8zr6LLorg" type="3002" source="_8vHrILSLEeGXB8zr6LLorg" target="_Bl1NAqwpEeGqBf0LMO47dg"> <children xmi:type="notation:Node" xmi:id="_8vTRVLSLEeGXB8zr6LLorg" type="4011"> @@ -712,7 +740,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_5Ak58R7pEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_5Ak58h7pEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10"/> <element xmi:type="ecore:EReference" href="security.ecore#//ExpressionFilter/expression"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_5Ak58x7pEeOJ3sK94Szb0A" points="[7, 21, 2, -49]$[7, 64, 2, -6]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_5Ak58x7pEeOJ3sK94Szb0A" points="[-1, 19, -5, -83]$[-1, 96, -5, -6]"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_5AnWMB7pEeOJ3sK94Szb0A" id="(0.5413533834586466,0.175)"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_AaaOQB7qEeOJ3sK94Szb0A" type="3003" source="_DR9foB7pEeOJ3sK94Szb0A" target="_7qI4kB9qEeOJ3sK94Szb0A"> @@ -731,7 +759,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_OEFpMR9cEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_OEFpMh9cEeOJ3sK94Szb0A" fontColor="4210752" fontName="Segoe UI" fontHeight="10"/> <element xmi:type="ecore:EReference" href="security.ecore#//CombinedFilter/operands"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_OEGQQB9cEeOJ3sK94Szb0A" points="[58, 16, 326, 101]$[91, 16, 359, 101]$[91, -86, 359, -1]$[-253, -86, 15, -1]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_OEGQQB9cEeOJ3sK94Szb0A" points="[58, 16, 376, 101]$[91, 16, 409, 101]$[91, -86, 409, -1]$[-303, -86, 15, -1]"/> <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_qcz0cB9rEeOJ3sK94Szb0A" id="(0.5283018867924528,0.11627906976744186)"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_OELv0B9cEeOJ3sK94Szb0A" id="(0.8809523809523809,0.525)"/> </edges> @@ -751,13 +779,13 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_QuqbQR9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_QuqbQh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_QuqbQx9rEeOJ3sK94Szb0A" points="[-1, -19, 1, 80]$[-1, -80, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_QuqbQx9rEeOJ3sK94Szb0A" points="[-1, -19, -67, 212]$[-1, -40, -67, 191]$[70, -40, 4, 191]$[70, -212, 4, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_RKYt8B9rEeOJ3sK94Szb0A" type="3003" source="_KyDS4B9rEeOJ3sK94Szb0A" target="_LwMWIB9rEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_RKYt8R9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_RKYt8h9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_RKYt8x9rEeOJ3sK94Szb0A" points="[-3, -19, 122, 101]$[-3, -44, 122, 76]$[-123, -44, 2, 76]$[-123, -101, 2, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_RKYt8x9rEeOJ3sK94Szb0A" points="[-1, -19, 53, 212]$[-1, -40, 53, 191]$[-50, -40, 4, 191]$[-50, -212, 4, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_bRdEkB9rEeOJ3sK94Szb0A" type="3002" source="_4Ce1YB9qEeOJ3sK94Szb0A" target="_2OPHILIREeGyraMqKGwiUw"> <children xmi:type="notation:Node" xmi:id="_bRdroB9rEeOJ3sK94Szb0A" type="4011"> @@ -789,7 +817,7 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_w11zER9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_w11zEh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_w11zEx9rEeOJ3sK94Szb0A" points="[-3, -7, -31, 90]$[-3, -55, -31, 42]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_w11zEx9rEeOJ3sK94Szb0A" points="[2, -7, -18, 92]$[2, -57, -18, 42]"/> <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_w16EgB9rEeOJ3sK94Szb0A" id="(0.5333333333333333,0.20930232558139536)"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_w16EgR9rEeOJ3sK94Szb0A" id="(0.6721311475409836,0.1568627450980392)"/> </edges> @@ -797,45 +825,45 @@ <styles xmi:type="notation:ConnectorStyle" xmi:id="_xeegYR9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_xeegYh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xeegYx9rEeOJ3sK94Szb0A" points="[1, -19, -333, 81]$[1, -49, -333, 51]$[335, -49, 1, 51]$[335, -81, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_xeegYx9rEeOJ3sK94Szb0A" points="[1, -19, -333, 81]$[1, -49, -333, 51]$[336, -49, 2, 51]$[336, -81, 2, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_x2Xb8B9rEeOJ3sK94Szb0A" type="3003" source="_5GR0sB9qEeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_x2Xb8R9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_x2Xb8h9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_x2Xb8x9rEeOJ3sK94Szb0A" points="[-1, -24, -175, 81]$[-1, -54, -175, 51]$[175, -54, 1, 51]$[175, -86, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_x2Xb8x9rEeOJ3sK94Szb0A" points="[-1, -24, -175, 81]$[-1, -54, -175, 51]$[176, -54, 2, 51]$[176, -86, 2, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_yQS-4B9rEeOJ3sK94Szb0A" type="3003" source="_6LfJQB9qEeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_yQS-4R9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_yQS-4h9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_yQS-4x9rEeOJ3sK94Szb0A" points="[24, -14, 158, 81]$[24, -44, 158, 51]$[-133, -44, 1, 51]$[-133, -76, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_yQS-4x9rEeOJ3sK94Szb0A" points="[29, -39, 181, 81]$[29, -69, 181, 51]$[-150, -69, 2, 51]$[-150, -101, 2, 19]"/> <sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_yQUNAB9rEeOJ3sK94Szb0A" id="(0.344,0.21568627450980393)"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_ysCfsB9rEeOJ3sK94Szb0A" type="3003" source="_7qI4kB9qEeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_ysCfsR9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_ysCfsh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_ysCfsx9rEeOJ3sK94Szb0A" points="[1, -19, -32, 90]$[1, -81, -32, 28]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_ysCfsx9rEeOJ3sK94Szb0A" points="[2, -19, -31, 90]$[2, -81, -31, 28]"/> <targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_ysGxIB9rEeOJ3sK94Szb0A" id="(0.7698412698412699,0.27906976744186046)"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_1ApmoB9rEeOJ3sK94Szb0A" type="3003" source="_LwMWIB9rEeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_1ApmoR9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_1Apmoh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_1Apmox9rEeOJ3sK94Szb0A" points="[1, -19, 313, 81]$[1, -49, 313, 51]$[-311, -49, 1, 51]$[-311, -81, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_1Apmox9rEeOJ3sK94Szb0A" points="[4, -19, 366, 81]$[4, -49, 366, 51]$[-360, -49, 2, 51]$[-360, -81, 2, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_2gV3wB9rEeOJ3sK94Szb0A" type="3003" source="_JtuvIB9rEeOJ3sK94Szb0A" target="_LwMWIB9rEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_2gV3wR9rEeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_2gV3wh9rEeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_2gV3wx9rEeOJ3sK94Szb0A" points="[-3, -19, -113, 101]$[-3, -44, -113, 76]$[112, -44, 2, 76]$[112, -101, 2, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_2gV3wx9rEeOJ3sK94Szb0A" points="[0, -19, -181, 212]$[0, -40, -181, 191]$[185, -40, 4, 191]$[185, -212, 4, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_05PuYB98EeOJ3sK94Szb0A" type="3003" source="_lCpCEB98EeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <styles xmi:type="notation:ConnectorStyle" xmi:id="_05PuYR98EeOJ3sK94Szb0A" routing="Rectilinear" lineColor="4210752"/> <styles xmi:type="notation:FontStyle" xmi:id="_05PuYh98EeOJ3sK94Szb0A" fontName="Segoe UI"/> <element xsi:nil="true"/> - <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_05PuYx98EeOJ3sK94Szb0A" points="[3, -19, -464, 81]$[3, -49, -464, 51]$[468, -49, 1, 51]$[468, -81, 1, 19]"/> + <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_05PuYx98EeOJ3sK94Szb0A" points="[3, -19, -464, 81]$[3, -49, -464, 51]$[469, -49, 2, 51]$[469, -81, 2, 19]"/> </edges> <edges xmi:type="notation:Edge" xmi:id="_62wOoB98EeOJ3sK94Szb0A" type="3002" source="_lCpCEB98EeOJ3sK94Szb0A" target="_tMuMwB9qEeOJ3sK94Szb0A"> <children xmi:type="notation:Node" xmi:id="_62w1sB98EeOJ3sK94Szb0A" type="4011"> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Inclusion.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PatternStyle.java index 09727a90ec..18305b6030 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Inclusion.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/PatternStyle.java @@ -18,97 +18,97 @@ import java.util.List; /** * <!-- begin-user-doc --> - * A representation of the literals of the enumeration '<em><b>Inclusion</b></em>', + * A representation of the literals of the enumeration '<em><b>PatternStyle</b></em>', * and utility methods for working with them. * @since 4.3 * <!-- end-user-doc --> - * @see org.eclipse.emf.cdo.security.SecurityPackage#getInclusion() + * @see org.eclipse.emf.cdo.security.SecurityPackage#getPatternStyle() * @model * @generated */ -public enum Inclusion implements Enumerator +public enum PatternStyle implements Enumerator { /** - * The '<em><b>Exact</b></em>' literal object. + * The '<em><b>EXACT</b></em>' literal object. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #EXACT_VALUE * @generated * @ordered */ - EXACT(0, "Exact", "Exact"), /** - * The '<em><b>Exact And Up</b></em>' literal object. + EXACT(0, "EXACT", "EXACT"), /** + * The '<em><b>TREE</b></em>' literal object. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #EXACT_AND_UP_VALUE + * @see #TREE_VALUE * @generated * @ordered */ - EXACT_AND_UP(1, "ExactAndUp", "ExactAndUp"), /** - * The '<em><b>Exact And Down</b></em>' literal object. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #EXACT_AND_DOWN_VALUE - * @generated - * @ordered - */ - EXACT_AND_DOWN(2, "ExactAndDown", "ExactAndDown"), /** - * The '<em><b>Regex</b></em>' literal object. - * <!-- begin-user-doc --> + TREE(1, "TREE", "TREE"), /** + * The '<em><b>ANT</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #ANT_VALUE + * @generated + * @ordered + */ + ANT(2, "ANT", "ANT"), /** + * The '<em><b>REGEX</b></em>' literal object. + * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #REGEX_VALUE - * @generated - * @ordered - */ - REGEX(3, "Regex", "Regex"); //$NON-NLS-1$ //$NON-NLS-2$ + * @see #REGEX_VALUE + * @generated + * @ordered + */ + REGEX(3, "REGEX", "REGEX"); //$NON-NLS-1$ //$NON-NLS-2$ /** - * The '<em><b>Exact</b></em>' literal value. + * The '<em><b>EXACT</b></em>' literal value. * <!-- begin-user-doc --> * <p> - * If the meaning of '<em><b>Exact</b></em>' literal object isn't clear, + * If the meaning of '<em><b>EXACT</b></em>' literal object isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> * @see #EXACT - * @model name="Exact" + * @model * @generated * @ordered */ public static final int EXACT_VALUE = 0; /** - * The '<em><b>Exact And Up</b></em>' literal value. + * The '<em><b>TREE</b></em>' literal value. * <!-- begin-user-doc --> * <p> - * If the meaning of '<em><b>Exact And Up</b></em>' literal object isn't clear, + * If the meaning of '<em><b>TREE</b></em>' literal object isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> - * @see #EXACT_AND_UP - * @model name="ExactAndUp" + * @see #TREE + * @model * @generated * @ordered */ - public static final int EXACT_AND_UP_VALUE = 1; + public static final int TREE_VALUE = 1; /** - * The '<em><b>Exact And Down</b></em>' literal value. + * The '<em><b>ANT</b></em>' literal value. * <!-- begin-user-doc --> * <p> - * If the meaning of '<em><b>Exact And Down</b></em>' literal object isn't clear, + * If the meaning of '<em><b>ANT</b></em>' literal object isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> - * @see #EXACT_AND_DOWN - * @model name="ExactAndDown" + * @see #ANT + * @model * @generated * @ordered */ - public static final int EXACT_AND_DOWN_VALUE = 2; + public static final int ANT_VALUE = 2; /** - * The '<em><b>Regex</b></em>' literal value. + * The '<em><b>REGEX</b></em>' literal value. * <!-- begin-user-doc --> * <p> * If the meaning of '<em><b>Regex</b></em>' literal object isn't clear, @@ -116,39 +116,39 @@ public enum Inclusion implements Enumerator * </p> * <!-- end-user-doc --> * @see #REGEX - * @model name="Regex" + * @model * @generated * @ordered */ public static final int REGEX_VALUE = 3; /** - * An array of all the '<em><b>Inclusion</b></em>' enumerators. + * An array of all the '<em><b>Pattern Style</b></em>' enumerators. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - private static final Inclusion[] VALUES_ARRAY = new Inclusion[] { EXACT, EXACT_AND_UP, EXACT_AND_DOWN, REGEX, }; + private static final PatternStyle[] VALUES_ARRAY = new PatternStyle[] { EXACT, TREE, ANT, REGEX, }; /** - * A public read-only list of all the '<em><b>Inclusion</b></em>' enumerators. + * A public read-only list of all the '<em><b>Pattern Style</b></em>' enumerators. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - public static final List<Inclusion> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + public static final List<PatternStyle> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); /** - * Returns the '<em><b>Inclusion</b></em>' literal with the specified literal value. + * Returns the '<em><b>Pattern Style</b></em>' literal with the specified literal value. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - public static Inclusion get(String literal) + public static PatternStyle get(String literal) { for (int i = 0; i < VALUES_ARRAY.length; ++i) { - Inclusion result = VALUES_ARRAY[i]; + PatternStyle result = VALUES_ARRAY[i]; if (result.toString().equals(literal)) { return result; @@ -158,16 +158,16 @@ public enum Inclusion implements Enumerator } /** - * Returns the '<em><b>Inclusion</b></em>' literal with the specified name. + * Returns the '<em><b>Pattern Style</b></em>' literal with the specified name. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - public static Inclusion getByName(String name) + public static PatternStyle getByName(String name) { for (int i = 0; i < VALUES_ARRAY.length; ++i) { - Inclusion result = VALUES_ARRAY[i]; + PatternStyle result = VALUES_ARRAY[i]; if (result.getName().equals(name)) { return result; @@ -177,21 +177,21 @@ public enum Inclusion implements Enumerator } /** - * Returns the '<em><b>Inclusion</b></em>' literal with the specified integer value. + * Returns the '<em><b>Pattern Style</b></em>' literal with the specified integer value. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - public static Inclusion get(int value) + public static PatternStyle get(int value) { switch (value) { case EXACT_VALUE: return EXACT; - case EXACT_AND_UP_VALUE: - return EXACT_AND_UP; - case EXACT_AND_DOWN_VALUE: - return EXACT_AND_DOWN; + case TREE_VALUE: + return TREE; + case ANT_VALUE: + return ANT; case REGEX_VALUE: return REGEX; } @@ -225,7 +225,7 @@ public enum Inclusion implements Enumerator * <!-- end-user-doc --> * @generated */ - private Inclusion(int value, String name, String literal) + private PatternStyle(int value, String name, String literal) { this.value = value; this.name = name; @@ -274,4 +274,4 @@ public enum Inclusion implements Enumerator return literal; } -} // Inclusion +} // PatternStyle diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/ResourceFilter.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/ResourceFilter.java index 79065ec842..7ff8375b8d 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/ResourceFilter.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/ResourceFilter.java @@ -20,7 +20,14 @@ package org.eclipse.emf.cdo.security; * The following features are supported: * <ul> * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#getPath <em>Path</em>}</li> - * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#getInclusion <em>Inclusion</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#getPatternStyle <em>Pattern Style</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isFolders <em>Folders</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isTextResources <em>Text Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isBinaryResources <em>Binary Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelResources <em>Model Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelObjects <em>Model Objects</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeParents <em>Include Parents</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeRoot <em>Include Root</em>}</li> * </ul> * </p> * @@ -52,38 +59,227 @@ public interface ResourceFilter extends PermissionFilter * <!-- end-user-doc --> * @param value the new value of the '<em>Path</em>' attribute. * @see #getPath() + * @generated NOT + */ + ResourceFilter setPath(String value); + + /** + * Returns the value of the '<em><b>Pattern Style</b></em>' attribute. + * The default value is <code>"TREE"</code>. + * The literals are from the enumeration {@link org.eclipse.emf.cdo.security.PatternStyle}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Pattern Style</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Pattern Style</em>' attribute. + * @see org.eclipse.emf.cdo.security.PatternStyle + * @see #setPatternStyle(PatternStyle) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_PatternStyle() + * @model default="TREE" + * @generated + */ + PatternStyle getPatternStyle(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#getPatternStyle <em>Pattern Style</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Pattern Style</em>' attribute. + * @see org.eclipse.emf.cdo.security.PatternStyle + * @see #getPatternStyle() + * @generated NOT + */ + ResourceFilter setPatternStyle(PatternStyle value); + + /** + * Returns the value of the '<em><b>Folders</b></em>' attribute. + * The default value is <code>"true"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Folders</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Folders</em>' attribute. + * @see #setFolders(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_Folders() + * @model default="true" + * @generated + */ + boolean isFolders(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isFolders <em>Folders</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Folders</em>' attribute. + * @see #isFolders() + * @generated NOT + */ + ResourceFilter setFolders(boolean value); + + /** + * Returns the value of the '<em><b>Model Resources</b></em>' attribute. + * The default value is <code>"true"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Model Resources</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Model Resources</em>' attribute. + * @see #setModelResources(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_ModelResources() + * @model default="true" + * @generated + */ + boolean isModelResources(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelResources <em>Model Resources</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Model Resources</em>' attribute. + * @see #isModelResources() + * @generated NOT + */ + ResourceFilter setModelResources(boolean value); + + /** + * Returns the value of the '<em><b>Model Objects</b></em>' attribute. + * The default value is <code>"true"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Model Objects</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Model Objects</em>' attribute. + * @see #setModelObjects(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_ModelObjects() + * @model default="true" + * @generated + */ + boolean isModelObjects(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelObjects <em>Model Objects</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Model Objects</em>' attribute. + * @see #isModelObjects() + * @generated NOT + */ + ResourceFilter setModelObjects(boolean value); + + /** + * Returns the value of the '<em><b>Include Parents</b></em>' attribute. + * The default value is <code>"true"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Include Parents</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Include Parents</em>' attribute. + * @see #setIncludeParents(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_IncludeParents() + * @model default="true" + * @generated + */ + boolean isIncludeParents(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeParents <em>Include Parents</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Include Parents</em>' attribute. + * @see #isIncludeParents() + * @generated NOT + */ + ResourceFilter setIncludeParents(boolean value); + + /** + * Returns the value of the '<em><b>Include Root</b></em>' attribute. + * The default value is <code>"true"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Include Root</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Include Root</em>' attribute. + * @see #setIncludeRoot(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_IncludeRoot() + * @model default="true" * @generated */ - void setPath(String value); + boolean isIncludeRoot(); /** - * Returns the value of the '<em><b>Inclusion</b></em>' attribute. - * The default value is <code>"Regex"</code>. - * The literals are from the enumeration {@link org.eclipse.emf.cdo.security.Inclusion}. + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeRoot <em>Include Root</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Include Root</em>' attribute. + * @see #isIncludeRoot() + * @generated NOT + */ + ResourceFilter setIncludeRoot(boolean value); + + /** + * Returns the value of the '<em><b>Text Resources</b></em>' attribute. + * The default value is <code>"true"</code>. * <!-- begin-user-doc --> * <p> - * If the meaning of the '<em>Inclusion</em>' attribute isn't clear, + * If the meaning of the '<em>Text Resources</em>' attribute isn't clear, * there really should be more of a description here... * </p> * <!-- end-user-doc --> - * @return the value of the '<em>Inclusion</em>' attribute. - * @see org.eclipse.emf.cdo.security.Inclusion - * @see #setInclusion(Inclusion) - * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_Inclusion() - * @model default="Regex" + * @return the value of the '<em>Text Resources</em>' attribute. + * @see #setTextResources(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_TextResources() + * @model default="true" * @generated */ - Inclusion getInclusion(); + boolean isTextResources(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isTextResources <em>Text Resources</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Text Resources</em>' attribute. + * @see #isTextResources() + * @generated NOT + */ + ResourceFilter setTextResources(boolean value); /** - * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#getInclusion <em>Inclusion</em>}' attribute. + * Returns the value of the '<em><b>Binary Resources</b></em>' attribute. + * The default value is <code>"true"</code>. * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Binary Resources</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> * <!-- end-user-doc --> - * @param value the new value of the '<em>Inclusion</em>' attribute. - * @see org.eclipse.emf.cdo.security.Inclusion - * @see #getInclusion() + * @return the value of the '<em>Binary Resources</em>' attribute. + * @see #setBinaryResources(boolean) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getResourceFilter_BinaryResources() + * @model default="true" * @generated */ - void setInclusion(Inclusion value); + boolean isBinaryResources(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.ResourceFilter#isBinaryResources <em>Binary Resources</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Binary Resources</em>' attribute. + * @see #isBinaryResources() + * @generated NOT + */ + ResourceFilter setBinaryResources(boolean value); } // ResourceFilter diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java index 3a777226e8..58d654f5ea 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java @@ -252,7 +252,12 @@ public interface SecurityFactory extends EFactory /** * @since 4.3 */ - ResourceFilter createResourceFilter(String path, Inclusion inclusion); + ResourceFilter createResourceFilter(String path, PatternStyle PatternStyle); + + /** + * @since 4.3 + */ + ResourceFilter createResourceFilter(String path, PatternStyle PatternStyle, boolean includeParents); /** * Returns a new object of class '<em>Expression Filter</em>'. diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java index 26a492923d..48658c4d30 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java @@ -1099,14 +1099,84 @@ public interface SecurityPackage extends EPackage int RESOURCE_FILTER__PATH = PERMISSION_FILTER_FEATURE_COUNT + 0; /** - * The feature id for the '<em><b>Inclusion</b></em>' attribute. + * The feature id for the '<em><b>Pattern Style</b></em>' attribute. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> * @generated * @ordered */ - int RESOURCE_FILTER__INCLUSION = PERMISSION_FILTER_FEATURE_COUNT + 1; + int RESOURCE_FILTER__PATTERN_STYLE = PERMISSION_FILTER_FEATURE_COUNT + 1; + + /** + * The feature id for the '<em><b>Folders</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__FOLDERS = PERMISSION_FILTER_FEATURE_COUNT + 2; + + /** + * The feature id for the '<em><b>Text Resources</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__TEXT_RESOURCES = PERMISSION_FILTER_FEATURE_COUNT + 3; + + /** + * The feature id for the '<em><b>Binary Resources</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__BINARY_RESOURCES = PERMISSION_FILTER_FEATURE_COUNT + 4; + + /** + * The feature id for the '<em><b>Model Resources</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__MODEL_RESOURCES = PERMISSION_FILTER_FEATURE_COUNT + 5; + + /** + * The feature id for the '<em><b>Model Objects</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__MODEL_OBJECTS = PERMISSION_FILTER_FEATURE_COUNT + 6; + + /** + * The feature id for the '<em><b>Include Parents</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__INCLUDE_PARENTS = PERMISSION_FILTER_FEATURE_COUNT + 7; + + /** + * The feature id for the '<em><b>Include Root</b></em>' attribute. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RESOURCE_FILTER__INCLUDE_ROOT = PERMISSION_FILTER_FEATURE_COUNT + 8; /** * The number of structural features of the '<em>Resource Filter</em>' class. @@ -1116,7 +1186,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int RESOURCE_FILTER_FEATURE_COUNT = PERMISSION_FILTER_FEATURE_COUNT + 2; + int RESOURCE_FILTER_FEATURE_COUNT = PERMISSION_FILTER_FEATURE_COUNT + 9; /** * The meta object id for the '{@link org.eclipse.emf.cdo.security.impl.ObjectFilterImpl <em>Object Filter</em>}' class. @@ -1295,15 +1365,15 @@ public interface SecurityPackage extends EPackage int OR_FILTER_FEATURE_COUNT = COMBINED_FILTER_FEATURE_COUNT + 0; /** - * The meta object id for the '{@link org.eclipse.emf.cdo.security.Inclusion <em>Inclusion</em>}' enum. + * The meta object id for the '{@link org.eclipse.emf.cdo.security.PatternStyle <em>Pattern Style</em>}' enum. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> - * @see org.eclipse.emf.cdo.security.Inclusion - * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getInclusion() + * @see org.eclipse.emf.cdo.security.PatternStyle + * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getPatternStyle() * @generated */ - int INCLUSION = 26; + int PATTERN_STYLE = 26; /** * The meta object id for the '{@link org.eclipse.emf.cdo.security.Access <em>Access</em>}' enum. @@ -2072,16 +2142,100 @@ public interface SecurityPackage extends EPackage EAttribute getResourceFilter_Path(); /** - * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#getInclusion <em>Inclusion</em>}'. + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#getPatternStyle <em>Pattern Style</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Pattern Style</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#getPatternStyle() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_PatternStyle(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isFolders <em>Folders</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Folders</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isFolders() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_Folders(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelResources <em>Model Resources</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Model Resources</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isModelResources() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_ModelResources(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isModelObjects <em>Model Objects</em>}'. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Inclusion</em>'. - * @see org.eclipse.emf.cdo.security.ResourceFilter#getInclusion() + * @return the meta object for the attribute '<em>Model Objects</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isModelObjects() * @see #getResourceFilter() * @generated */ - EAttribute getResourceFilter_Inclusion(); + EAttribute getResourceFilter_ModelObjects(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeParents <em>Include Parents</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Include Parents</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isIncludeParents() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_IncludeParents(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isIncludeRoot <em>Include Root</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Include Root</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isIncludeRoot() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_IncludeRoot(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isTextResources <em>Text Resources</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Text Resources</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isTextResources() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_TextResources(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.ResourceFilter#isBinaryResources <em>Binary Resources</em>}'. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Binary Resources</em>'. + * @see org.eclipse.emf.cdo.security.ResourceFilter#isBinaryResources() + * @see #getResourceFilter() + * @generated + */ + EAttribute getResourceFilter_BinaryResources(); /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.security.ObjectFilter <em>Object Filter</em>}'. @@ -2174,15 +2328,15 @@ public interface SecurityPackage extends EPackage EClass getOrFilter(); /** - * Returns the meta object for enum '{@link org.eclipse.emf.cdo.security.Inclusion <em>Inclusion</em>}'. + * Returns the meta object for enum '{@link org.eclipse.emf.cdo.security.PatternStyle <em>Pattern Style</em>}'. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> - * @return the meta object for enum '<em>Inclusion</em>'. - * @see org.eclipse.emf.cdo.security.Inclusion + * @return the meta object for enum '<em>Pattern Style</em>'. + * @see org.eclipse.emf.cdo.security.PatternStyle * @generated */ - EEnum getInclusion(); + EEnum getPatternStyle(); /** * Returns the meta object for enum '{@link org.eclipse.emf.cdo.security.Access <em>Access</em>}'. @@ -2832,13 +2986,76 @@ public interface SecurityPackage extends EPackage EAttribute RESOURCE_FILTER__PATH = eINSTANCE.getResourceFilter_Path(); /** - * The meta object literal for the '<em><b>Inclusion</b></em>' attribute feature. + * The meta object literal for the '<em><b>Pattern Style</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__PATTERN_STYLE = eINSTANCE.getResourceFilter_PatternStyle(); + + /** + * The meta object literal for the '<em><b>Folders</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__FOLDERS = eINSTANCE.getResourceFilter_Folders(); + + /** + * The meta object literal for the '<em><b>Model Resources</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__MODEL_RESOURCES = eINSTANCE.getResourceFilter_ModelResources(); + + /** + * The meta object literal for the '<em><b>Model Objects</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__MODEL_OBJECTS = eINSTANCE.getResourceFilter_ModelObjects(); + + /** + * The meta object literal for the '<em><b>Include Parents</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__INCLUDE_PARENTS = eINSTANCE.getResourceFilter_IncludeParents(); + + /** + * The meta object literal for the '<em><b>Include Root</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__INCLUDE_ROOT = eINSTANCE.getResourceFilter_IncludeRoot(); + + /** + * The meta object literal for the '<em><b>Text Resources</b></em>' attribute feature. + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + EAttribute RESOURCE_FILTER__TEXT_RESOURCES = eINSTANCE.getResourceFilter_TextResources(); + + /** + * The meta object literal for the '<em><b>Binary Resources</b></em>' attribute feature. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> * @generated */ - EAttribute RESOURCE_FILTER__INCLUSION = eINSTANCE.getResourceFilter_Inclusion(); + EAttribute RESOURCE_FILTER__BINARY_RESOURCES = eINSTANCE.getResourceFilter_BinaryResources(); /** * The meta object literal for the '{@link org.eclipse.emf.cdo.security.impl.ObjectFilterImpl <em>Object Filter</em>}' class. @@ -2925,15 +3142,15 @@ public interface SecurityPackage extends EPackage EClass OR_FILTER = eINSTANCE.getOrFilter(); /** - * The meta object literal for the '{@link org.eclipse.emf.cdo.security.Inclusion <em>Inclusion</em>}' enum. + * The meta object literal for the '{@link org.eclipse.emf.cdo.security.PatternStyle <em>Pattern Style</em>}' enum. * <!-- begin-user-doc --> * @since 4.3 * <!-- end-user-doc --> - * @see org.eclipse.emf.cdo.security.Inclusion - * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getInclusion() + * @see org.eclipse.emf.cdo.security.PatternStyle + * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getPatternStyle() * @generated */ - EEnum INCLUSION = eINSTANCE.getInclusion(); + EEnum PATTERN_STYLE = eINSTANCE.getPatternStyle(); /** * The meta object literal for the '{@link org.eclipse.emf.cdo.security.Access <em>Access</em>}' enum. 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 154d1da17a..d401c68fa9 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 @@ -11,16 +11,23 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; -import org.eclipse.emf.cdo.security.Inclusion; +import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.security.PatternStyle; import org.eclipse.emf.cdo.security.ResourceFilter; import org.eclipse.emf.cdo.security.SecurityPackage; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.WrappedException; + +import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.ecore.EClass; -import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -33,7 +40,14 @@ import java.util.regex.PatternSyntaxException; * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#getPath <em>Path</em>}</li> - * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#getInclusion <em>Inclusion</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#getPatternStyle <em>Pattern Style</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isFolders <em>Folders</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isTextResources <em>Text Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isBinaryResources <em>Binary Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isModelResources <em>Model Resources</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isModelObjects <em>Model Objects</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isIncludeParents <em>Include Parents</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.ResourceFilterImpl#isIncludeRoot <em>Include Root</em>}</li> * </ul> * </p> * @@ -43,9 +57,13 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource { private static final String USER_TOKEN = "${user}"; - private static final Pattern OMNI_PATTERN = Pattern.compile(".*"); + private static final int USER_TOKEN_NONE = -1; + + private static final int USER_TOKEN_UNINITIALIZED = -2; + + private transient int userTokenPos = USER_TOKEN_UNINITIALIZED; - private Pattern pattern; + private transient BasicEList<Matcher> matchers; /** * <!-- begin-user-doc --> @@ -81,11 +99,12 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource /** * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated + * @generated NOT */ - public void setPath(String newPath) + public ResourceFilter setPath(String newPath) { eSet(SecurityPackage.Literals.RESOURCE_FILTER__PATH, newPath); + return this; } /** @@ -93,9 +112,20 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource * <!-- end-user-doc --> * @generated */ - public Inclusion getInclusion() + public PatternStyle getPatternStyle() { - return (Inclusion)eGet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUSION, true); + return (PatternStyle)eGet(SecurityPackage.Literals.RESOURCE_FILTER__PATTERN_STYLE, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setPatternStyle(PatternStyle newPatternStyle) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__PATTERN_STYLE, newPatternStyle); + return this; } /** @@ -103,117 +133,401 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource * <!-- end-user-doc --> * @generated */ - public void setInclusion(Inclusion newInclusion) + public boolean isFolders() { - eSet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUSION, newInclusion); + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__FOLDERS, true); } - @Override - protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, - int level) throws Exception + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setFolders(boolean newFolders) { - if (revisionProvider == null) + eSet(SecurityPackage.Literals.RESOURCE_FILTER__FOLDERS, newFolders); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isModelResources() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__MODEL_RESOURCES, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setModelResources(boolean newModelResources) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__MODEL_RESOURCES, newModelResources); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isModelObjects() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__MODEL_OBJECTS, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setModelObjects(boolean newModelObjects) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__MODEL_OBJECTS, newModelObjects); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isIncludeParents() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_PARENTS, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setIncludeParents(boolean newIncludeParents) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_PARENTS, newIncludeParents); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isIncludeRoot() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_ROOT, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setIncludeRoot(boolean newIncludeRoot) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__INCLUDE_ROOT, newIncludeRoot); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isTextResources() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__TEXT_RESOURCES, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setTextResources(boolean newTextResources) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__TEXT_RESOURCES, newTextResources); + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isBinaryResources() + { + return (Boolean)eGet(SecurityPackage.Literals.RESOURCE_FILTER__BINARY_RESOURCES, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceFilter setBinaryResources(boolean newBinaryResources) + { + eSet(SecurityPackage.Literals.RESOURCE_FILTER__BINARY_RESOURCES, newBinaryResources); + return this; + } + + // private boolean includesExactAndUp(CDORevision revision, CDORevisionProvider revisionProvider) + // { + // if (!revision.isResourceNode()) + // { + // return false; + // } + // + // String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); + // String path = getSubstitutedPath(); + // + // int length = revisionPath.length(); + // if (length > path.length()) + // { + // return false; + // } + // + // path = path.substring(0, length); + // return revisionPath.equals(path); + // } + // + // private boolean includesExactAndDown(CDORevision revision, CDORevisionProvider revisionProvider) + // { + // String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); + // String path = getSubstitutedPath(); + // + // int length = path.length(); + // if (length > revisionPath.length()) + // { + // return false; + // } + // + // revisionPath = revisionPath.substring(0, length); + // return path.equals(revisionPath); + // } + // + // private boolean includesRegex(CDORevision revision, CDORevisionProvider revisionProvider) + // { + // if (pattern == null) + // { + // String path = substituteUserToken(getPath()); + // pattern = compilePattern(path); + // + // if (pattern == null) + // { + // return false; + // } + // } + // + // if (pattern == OMNI_PATTERN) + // { + // return true; + // } + // + // String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); + // + // Matcher matcher = pattern.matcher(revisionPath); + // return matcher.matches(); + // } + // + // private String substituteUserToken(String string) + // { + // int pos = string.indexOf(USER_TOKEN); + // if (pos != -1) + // { + // String user = getUser(); + // if (user == null || user.length() == 0) + // { + // throw new IllegalStateException("User required for evaluation of path " + string); + // } + // + // string = string.substring(0, pos) + user + string.substring(pos + USER_TOKEN.length()); + // } + // + // return string; + // } + // + // private Pattern compilePattern(String value) + // { + // if (value == null) + // { + // return null; + // } + // + // if (OMNI_PATTERN.pattern().equals(value)) + // { + // return OMNI_PATTERN; + // } + // + // try + // { + // return Pattern.compile(value); + // } + // catch (PatternSyntaxException ex) + // { + // return null; + // } + // } + + public String format() + { + String label = "?"; + + String path = getPath(); + if (path != null) { - return false; + if (!path.startsWith("/")) + { + path = "/" + path; + } + + label = path; } - Inclusion inclusion = getInclusion(); - switch (inclusion) + String operator = formatOperator(); + return "resource" + operator + label; + } + + protected String formatOperator() + { + PatternStyle patternStyle = getPatternStyle(); + switch (patternStyle) { case EXACT: - return includesExact(revision, revisionProvider); - - case EXACT_AND_UP: - return includesExactAndUp(revision, revisionProvider); + return " == "; - case EXACT_AND_DOWN: - return includesExactAndDown(revision, revisionProvider); + case TREE: + return " >= "; + case ANT: case REGEX: - return includesRegex(revision, revisionProvider); + return " ~= "; default: - throw new IllegalStateException("Unhandled inclusion value: " + inclusion); + throw new IllegalStateException("Unhandled pattern style: " + patternStyle); } } - private boolean includesExact(CDORevision revision, CDORevisionProvider revisionProvider) + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, CDOBranchPoint securityContext, + int level) throws Exception { - if (!revision.isResourceNode()) + if (!preChecks(revision, revisionProvider)) { return false; } String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getSubstitutedPath(); - return revisionPath.equals(path); + BasicEList<Matcher> list = getMatchers(); + Object[] matchers = list.data(); + + int length = list.size(); + for (int i = 0; i < length; i++) + { + Matcher matcher = (Matcher)matchers[i]; + if (matcher.matches(revisionPath)) + { + return true; + } + } + + return false; } - private boolean includesExactAndUp(CDORevision revision, CDORevisionProvider revisionProvider) + private boolean preChecks(CDORevision revision, CDORevisionProvider revisionProvider) { - if (!revision.isResourceNode()) + if (revisionProvider == null) { return false; } - String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getSubstitutedPath(); + EClass eClass = revision.getEClass(); + boolean resourceNode = false; - int length = revisionPath.length(); - if (length > path.length()) + // Check folders + if (eClass == EresourcePackage.Literals.CDO_RESOURCE_FOLDER) { - return false; + resourceNode = true; + if (!isFolders()) + { + return false; + } } - path = path.substring(0, length); - return revisionPath.equals(path); - } + // Check model resources + if (eClass == EresourcePackage.Literals.CDO_RESOURCE) + { + resourceNode = true; - private boolean includesExactAndDown(CDORevision revision, CDORevisionProvider revisionProvider) - { - String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - String path = getSubstitutedPath(); + boolean rootResource = CDOIDUtil.isNull((CDOID)((InternalCDORevision)revision).getContainerID()); + if (rootResource) + { + if (!isIncludeRoot()) + { + return false; + } + } + else + { + if (!isModelResources()) + { + return false; + } + } + } - int length = path.length(); - if (length > revisionPath.length()) + // Check text resources + if (eClass == EresourcePackage.Literals.CDO_TEXT_RESOURCE) { - return false; + resourceNode = true; + if (!isTextResources()) + { + return false; + } } - revisionPath = revisionPath.substring(0, length); - return path.equals(revisionPath); - } - - private boolean includesRegex(CDORevision revision, CDORevisionProvider revisionProvider) - { - if (pattern == null) + // Check binary resources + if (eClass == EresourcePackage.Literals.CDO_BINARY_RESOURCE) { - String path = getSubstitutedPath(); - pattern = compilePattern(path); - - if (pattern == null) + resourceNode = true; + if (!isBinaryResources()) { return false; } } - if (pattern == OMNI_PATTERN) + // Check model objects + boolean modelObject = !resourceNode; + if (modelObject && !isModelObjects()) { - return true; + return false; } - String revisionPath = CDORevisionUtil.getResourceNodePath(revision, revisionProvider); - - Matcher matcher = pattern.matcher(revisionPath); - return matcher.matches(); + return true; } - private String getSubstitutedPath() + private BasicEList<Matcher> getMatchers() { + if (matchers != null) + { + return matchers; + } + String path = getPath(); - int pos = path.indexOf(USER_TOKEN); - if (pos != -1) + PatternStyle patternStyle = getPatternStyle(); + boolean includeParents = isIncludeParents(); + + if (userTokenPos == USER_TOKEN_UNINITIALIZED) + { + userTokenPos = path.indexOf(USER_TOKEN); + } + + if (userTokenPos != USER_TOKEN_NONE) { String user = getUser(); if (user == null || user.length() == 0) @@ -221,72 +535,191 @@ public class ResourceFilterImpl extends PermissionFilterImpl implements Resource throw new IllegalStateException("User required for evaluation of path " + path); } - path = path.substring(0, pos) + user + path.substring(pos + USER_TOKEN.length()); + path = path.substring(0, userTokenPos) + user + path.substring(userTokenPos + USER_TOKEN.length()); + } + + BasicEList<Matcher> list = new BasicEList<Matcher>(1); + getMatchers(list, path, patternStyle, includeParents); + + if (userTokenPos == USER_TOKEN_NONE) + { + // Cache matchers if no user token is specified + matchers = list; } - return path; + return list; } - private Pattern compilePattern(String value) + private void getMatchers(BasicEList<Matcher> matchers, String path, PatternStyle patternStyle, boolean includeParents) { - if (value == null) + Matcher matcher = createMatcher(path, patternStyle); + matchers.add(matcher); + + if (includeParents) { - return null; + int pos = path.lastIndexOf("/"); + if (pos != -1) + { + path = path.substring(0, pos); + patternStyle = matcher.getParentPatternStyle(); + + getMatchers(matchers, path, patternStyle, includeParents); + } } + } - if (value.equals(OMNI_PATTERN.pattern())) + private Matcher createMatcher(String path, PatternStyle patternStyle) + { + switch (patternStyle) { - return OMNI_PATTERN; + case EXACT: + return new ExactMatcher(path); + + case TREE: + return new TreeMatcher(path); + + case ANT: + return new AntMatcher(path); + + case REGEX: + return new RegexMatcher(path); + + default: + throw new IllegalStateException("Unhandled pattern style: " + patternStyle); } + } + + /** + * @author Eike Stepper + */ + public interface Matcher + { + public boolean matches(String revisionPath); - try + public PatternStyle getParentPatternStyle(); + } + + /** + * @author Eike Stepper + */ + protected static abstract class PathMatcher implements Matcher + { + protected final String path; + + public PathMatcher(String path) { - return Pattern.compile(value); + this.path = path == null || path.length() == 0 ? "/" : path; } - catch (PatternSyntaxException ex) + + @Override + public String toString() { - return null; + return getClass().getSimpleName() + "[" + path + "]"; } } - public String format() + /** + * @author Eike Stepper + */ + protected static class ExactMatcher extends PathMatcher { - String label = "?"; + public ExactMatcher(String path) + { + super(path); + } - String path = getPath(); - if (path != null) + public boolean matches(String revisionPath) { - if (!path.startsWith("/")) + return path.equals(revisionPath); + } + + public PatternStyle getParentPatternStyle() + { + return PatternStyle.EXACT; + } + } + + /** + * @author Eike Stepper + */ + protected static class TreeMatcher extends PathMatcher + { + public TreeMatcher(String path) + { + super(path); + } + + public boolean matches(String revisionPath) + { + if (revisionPath == null) { - path = "/" + path; + return path.length() == 0; } - label = path; + return revisionPath.startsWith(path); } - String operator = formatOperator(); - return "resource" + operator + label; + public PatternStyle getParentPatternStyle() + { + return PatternStyle.EXACT; + } } - private String formatOperator() + /** + * @author Eike Stepper + */ + protected static class AntMatcher extends PathMatcher { - Inclusion inclusion = getInclusion(); - switch (inclusion) + public AntMatcher(String path) { - case EXACT: - return " == "; + super(path); + } - case EXACT_AND_UP: - return " <= "; + public boolean matches(String revisionPath) + { + return StringUtil.glob(path, revisionPath); + } - case EXACT_AND_DOWN: - return " >= "; + public PatternStyle getParentPatternStyle() + { + return PatternStyle.ANT; + } + } - case REGEX: - return " >~ "; + /** + * @author Eike Stepper + */ + protected static class RegexMatcher implements Matcher + { + private final Pattern pattern; - default: - throw new IllegalStateException("Unhandled inclusion value: " + inclusion); + public RegexMatcher(String path) + { + try + { + pattern = Pattern.compile(path); + } + catch (PatternSyntaxException ex) + { + throw WrappedException.wrap(ex); + } + } + + public boolean matches(String revisionPath) + { + return pattern.matcher(revisionPath).matches(); + } + + public PatternStyle getParentPatternStyle() + { + return PatternStyle.REGEX; + } + + @Override + public String toString() + { + return getClass().getSimpleName() + "[" + pattern.pattern() + "]"; } } + } // ResourceFilterImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java index 18cfbd635c..a863973640 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java @@ -20,12 +20,12 @@ import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.ExpressionFilter; import org.eclipse.emf.cdo.security.FilterPermission; import org.eclipse.emf.cdo.security.Group; -import org.eclipse.emf.cdo.security.Inclusion; import org.eclipse.emf.cdo.security.LinkedFilter; import org.eclipse.emf.cdo.security.NotFilter; import org.eclipse.emf.cdo.security.OrFilter; import org.eclipse.emf.cdo.security.PackageFilter; import org.eclipse.emf.cdo.security.PackagePermission; +import org.eclipse.emf.cdo.security.PatternStyle; import org.eclipse.emf.cdo.security.PermissionFilter; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.ResourceFilter; @@ -105,41 +105,41 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory switch (eClass.getClassifierID()) { case SecurityPackage.REALM: - return (EObject)createRealm(); + return createRealm(); case SecurityPackage.DIRECTORY: - return (EObject)createDirectory(); + return createDirectory(); case SecurityPackage.ROLE: - return (EObject)createRole(); + return createRole(); case SecurityPackage.GROUP: - return (EObject)createGroup(); + return createGroup(); case SecurityPackage.USER: - return (EObject)createUser(); + return createUser(); case SecurityPackage.USER_PASSWORD: - return (EObject)createUserPassword(); + return createUserPassword(); case SecurityPackage.CLASS_PERMISSION: - return (EObject)createClassPermission(); + return createClassPermission(); case SecurityPackage.PACKAGE_PERMISSION: - return (EObject)createPackagePermission(); + return createPackagePermission(); case SecurityPackage.RESOURCE_PERMISSION: - return (EObject)createResourcePermission(); + return createResourcePermission(); case SecurityPackage.FILTER_PERMISSION: - return (EObject)createFilterPermission(); + return createFilterPermission(); case SecurityPackage.LINKED_FILTER: - return (EObject)createLinkedFilter(); + return createLinkedFilter(); case SecurityPackage.PACKAGE_FILTER: - return (EObject)createPackageFilter(); + return createPackageFilter(); case SecurityPackage.CLASS_FILTER: - return (EObject)createClassFilter(); + return createClassFilter(); case SecurityPackage.RESOURCE_FILTER: - return (EObject)createResourceFilter(); + return createResourceFilter(); case SecurityPackage.EXPRESSION_FILTER: - return (EObject)createExpressionFilter(); + return createExpressionFilter(); case SecurityPackage.NOT_FILTER: - return (EObject)createNotFilter(); + return createNotFilter(); case SecurityPackage.AND_FILTER: - return (EObject)createAndFilter(); + return createAndFilter(); case SecurityPackage.OR_FILTER: - return (EObject)createOrFilter(); + return createOrFilter(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -155,8 +155,8 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory { switch (eDataType.getClassifierID()) { - case SecurityPackage.INCLUSION: - return createInclusionFromString(eDataType, initialValue); + case SecurityPackage.PATTERN_STYLE: + return createPatternStyleFromString(eDataType, initialValue); case SecurityPackage.ACCESS: return createAccessFromString(eDataType, initialValue); case SecurityPackage.ACCESS_OBJECT: @@ -176,8 +176,8 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory { switch (eDataType.getClassifierID()) { - case SecurityPackage.INCLUSION: - return convertInclusionToString(eDataType, instanceValue); + case SecurityPackage.PATTERN_STYLE: + return convertPatternStyleToString(eDataType, instanceValue); case SecurityPackage.ACCESS: return convertAccessToString(eDataType, instanceValue); case SecurityPackage.ACCESS_OBJECT: @@ -472,10 +472,20 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory /** * @since 4.3 */ - public ResourceFilter createResourceFilter(String path, Inclusion inclusion) + public ResourceFilter createResourceFilter(String path, PatternStyle patternStyle) { ResourceFilter filter = createResourceFilter(path); - filter.setInclusion(inclusion); + filter.setPatternStyle(patternStyle); + return filter; + } + + /** + * @since 4.3 + */ + public ResourceFilter createResourceFilter(String path, PatternStyle patternStyle, boolean includeParents) + { + ResourceFilter filter = createResourceFilter(path, patternStyle); + filter.setIncludeParents(includeParents); return filter; } @@ -563,12 +573,14 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory * <!-- end-user-doc --> * @generated */ - public Inclusion createInclusionFromString(EDataType eDataType, String initialValue) + public PatternStyle createPatternStyleFromString(EDataType eDataType, String initialValue) { - Inclusion result = Inclusion.get(initialValue); + PatternStyle result = PatternStyle.get(initialValue); if (result == null) + { throw new IllegalArgumentException( "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } return result; } @@ -578,7 +590,7 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory * <!-- end-user-doc --> * @generated */ - public String convertInclusionToString(EDataType eDataType, Object instanceValue) + public String convertPatternStyleToString(EDataType eDataType, Object instanceValue) { return instanceValue == null ? null : instanceValue.toString(); } @@ -602,8 +614,10 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory { Access result = Access.get(initialValue); if (result == null) + { throw new IllegalArgumentException( "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } return result; } diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java index ac61669c6e..9f027b1eaa 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java @@ -22,7 +22,6 @@ import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.ExpressionFilter; import org.eclipse.emf.cdo.security.FilterPermission; import org.eclipse.emf.cdo.security.Group; -import org.eclipse.emf.cdo.security.Inclusion; import org.eclipse.emf.cdo.security.LinkedFilter; import org.eclipse.emf.cdo.security.NotFilter; import org.eclipse.emf.cdo.security.ObjectFilter; @@ -30,6 +29,7 @@ import org.eclipse.emf.cdo.security.ObjectPermission; import org.eclipse.emf.cdo.security.OrFilter; import org.eclipse.emf.cdo.security.PackageFilter; import org.eclipse.emf.cdo.security.PackagePermission; +import org.eclipse.emf.cdo.security.PatternStyle; import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.PermissionFilter; import org.eclipse.emf.cdo.security.Realm; @@ -248,7 +248,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage * <!-- end-user-doc --> * @generated */ - private EEnum inclusionEEnum = null; + private EEnum patternStyleEEnum = null; /** * <!-- begin-user-doc --> @@ -306,7 +306,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public static SecurityPackage init() { if (isInited) + { return (SecurityPackage)EPackage.Registry.INSTANCE.getEPackage(SecurityPackage.eNS_URI); + } // Obtain or create and register package SecurityPackageImpl theSecurityPackage = (SecurityPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof SecurityPackageImpl ? EPackage.Registry.INSTANCE @@ -1034,7 +1036,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage * <!-- end-user-doc --> * @generated */ - public EAttribute getResourceFilter_Inclusion() + public EAttribute getResourceFilter_PatternStyle() { return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(1); } @@ -1045,6 +1047,83 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage * <!-- end-user-doc --> * @generated */ + public EAttribute getResourceFilter_Folders() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_ModelResources() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(5); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_ModelObjects() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(6); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_IncludeParents() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(7); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_IncludeRoot() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(8); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_TextResources() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getResourceFilter_BinaryResources() + { + return (EAttribute)resourceFilterEClass.getEStructuralFeatures().get(4); + } + + /** + * <!-- begin-user-doc --> + * @since 4.3 + * <!-- end-user-doc --> + * @generated + */ public EClass getObjectFilter() { return objectFilterEClass; @@ -1133,9 +1212,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage * <!-- end-user-doc --> * @generated */ - public EEnum getInclusion() + public EEnum getPatternStyle() { - return inclusionEEnum; + return patternStyleEEnum; } /** @@ -1185,7 +1264,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void createPackageContents() { if (isCreated) + { return; + } isCreated = true; // Create classes and their features @@ -1276,7 +1357,14 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage resourceFilterEClass = createEClass(RESOURCE_FILTER); createEAttribute(resourceFilterEClass, RESOURCE_FILTER__PATH); - createEAttribute(resourceFilterEClass, RESOURCE_FILTER__INCLUSION); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__PATTERN_STYLE); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__FOLDERS); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__TEXT_RESOURCES); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__BINARY_RESOURCES); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__MODEL_RESOURCES); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__MODEL_OBJECTS); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__INCLUDE_PARENTS); + createEAttribute(resourceFilterEClass, RESOURCE_FILTER__INCLUDE_ROOT); objectFilterEClass = createEClass(OBJECT_FILTER); @@ -1293,7 +1381,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage orFilterEClass = createEClass(OR_FILTER); // Create enums - inclusionEEnum = createEEnum(INCLUSION); + patternStyleEEnum = createEEnum(PATTERN_STYLE); accessEEnum = createEEnum(ACCESS); // Create data types @@ -1317,7 +1405,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void initializePackageContents() { if (isInitialized) + { return; + } isInitialized = true; // Initialize package @@ -1337,34 +1427,34 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage // Add supertypes to classes securityElementEClass.getESuperTypes().add(theEtypesPackage.getModelElement()); - securityItemEClass.getESuperTypes().add(this.getSecurityElement()); - realmEClass.getESuperTypes().add(this.getSecurityElement()); - directoryEClass.getESuperTypes().add(this.getSecurityItem()); - roleEClass.getESuperTypes().add(this.getSecurityItem()); - assigneeEClass.getESuperTypes().add(this.getSecurityItem()); - groupEClass.getESuperTypes().add(this.getAssignee()); - userEClass.getESuperTypes().add(this.getAssignee()); - classPermissionEClass.getESuperTypes().add(this.getPermission()); - packagePermissionEClass.getESuperTypes().add(this.getPermission()); - resourcePermissionEClass.getESuperTypes().add(this.getPermission()); - objectPermissionEClass.getESuperTypes().add(this.getPermission()); - filterPermissionEClass.getESuperTypes().add(this.getPermission()); - linkedFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - packageFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - classFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - resourceFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - objectFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - expressionFilterEClass.getESuperTypes().add(this.getObjectFilter()); - combinedFilterEClass.getESuperTypes().add(this.getPermissionFilter()); - notFilterEClass.getESuperTypes().add(this.getCombinedFilter()); - andFilterEClass.getESuperTypes().add(this.getCombinedFilter()); - orFilterEClass.getESuperTypes().add(this.getCombinedFilter()); + securityItemEClass.getESuperTypes().add(getSecurityElement()); + realmEClass.getESuperTypes().add(getSecurityElement()); + directoryEClass.getESuperTypes().add(getSecurityItem()); + roleEClass.getESuperTypes().add(getSecurityItem()); + assigneeEClass.getESuperTypes().add(getSecurityItem()); + groupEClass.getESuperTypes().add(getAssignee()); + userEClass.getESuperTypes().add(getAssignee()); + classPermissionEClass.getESuperTypes().add(getPermission()); + packagePermissionEClass.getESuperTypes().add(getPermission()); + resourcePermissionEClass.getESuperTypes().add(getPermission()); + objectPermissionEClass.getESuperTypes().add(getPermission()); + filterPermissionEClass.getESuperTypes().add(getPermission()); + linkedFilterEClass.getESuperTypes().add(getPermissionFilter()); + packageFilterEClass.getESuperTypes().add(getPermissionFilter()); + classFilterEClass.getESuperTypes().add(getPermissionFilter()); + resourceFilterEClass.getESuperTypes().add(getPermissionFilter()); + objectFilterEClass.getESuperTypes().add(getPermissionFilter()); + expressionFilterEClass.getESuperTypes().add(getObjectFilter()); + combinedFilterEClass.getESuperTypes().add(getPermissionFilter()); + notFilterEClass.getESuperTypes().add(getCombinedFilter()); + andFilterEClass.getESuperTypes().add(getCombinedFilter()); + orFilterEClass.getESuperTypes().add(getCombinedFilter()); // Initialize classes and features; add operations and parameters initEClass(securityElementEClass, SecurityElement.class, "SecurityElement", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - addEOperation(securityElementEClass, this.getRealm(), "getRealm", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ + addEOperation(securityElementEClass, getRealm(), "getRealm", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ initEClass(securityItemEClass, SecurityItem.class, "SecurityItem", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -1372,27 +1462,27 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(realmEClass, Realm.class, "Realm", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getRealm_Items(), - this.getSecurityItem(), + getSecurityItem(), null, "items", null, 0, -1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_AllUsers(), - this.getUser(), + getUser(), null, "allUsers", null, 0, -1, Realm.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_AllGroups(), - this.getGroup(), + getGroup(), null, "allGroups", null, 0, -1, Realm.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_AllRoles(), - this.getRole(), + getRole(), null, "allRoles", null, 0, -1, Realm.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_AllPermissions(), - this.getPermission(), + getPermission(), null, "allPermissions", null, 0, -1, Realm.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( @@ -1401,28 +1491,28 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "name", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getRealm_DefaultAccess(), - this.getAccessObject(), + getAccessObject(), "defaultAccess", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_DefaultUserDirectory(), - this.getDirectory(), + getDirectory(), null, "defaultUserDirectory", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_DefaultGroupDirectory(), - this.getDirectory(), + getDirectory(), null, "defaultGroupDirectory", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRealm_DefaultRoleDirectory(), - this.getDirectory(), + getDirectory(), null, "defaultRoleDirectory", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEClass(directoryEClass, Directory.class, "Directory", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getDirectory_Items(), - this.getSecurityItem(), + getSecurityItem(), null, "items", null, 0, -1, Directory.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( @@ -1437,13 +1527,13 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "id", null, 0, 1, Role.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRole_Permissions(), - this.getPermission(), - this.getPermission_Role(), + getPermission(), + getPermission_Role(), "permissions", null, 0, -1, Role.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRole_Assignees(), - this.getAssignee(), - this.getAssignee_Roles(), + getAssignee(), + getAssignee_Roles(), "assignees", null, 0, -1, Role.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEClass(assigneeEClass, Assignee.class, "Assignee", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -1453,47 +1543,47 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "id", null, 0, 1, Assignee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getAssignee_Roles(), - this.getRole(), - this.getRole_Assignees(), + getRole(), + getRole_Assignees(), "roles", null, 0, -1, Assignee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEClass(groupEClass, Group.class, "Group", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getGroup_Users(), - this.getUser(), - this.getUser_Groups(), + getUser(), + getUser_Groups(), "users", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_InheritedGroups(), - this.getGroup(), - this.getGroup_InheritingGroups(), + getGroup(), + getGroup_InheritingGroups(), "inheritedGroups", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_InheritingGroups(), - this.getGroup(), - this.getGroup_InheritedGroups(), + getGroup(), + getGroup_InheritedGroups(), "inheritingGroups", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_AllInheritedGroups(), - this.getGroup(), + getGroup(), null, "allInheritedGroups", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_AllInheritingGroups(), - this.getGroup(), + getGroup(), null, "allInheritingGroups", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_AllRoles(), - this.getRole(), + getRole(), null, "allRoles", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEClass(userEClass, User.class, "User", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getUser_Groups(), - this.getGroup(), - this.getGroup_Users(), + getGroup(), + getGroup_Users(), "groups", null, 0, -1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getUser_Label(), @@ -1513,11 +1603,11 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "email", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getUser_DefaultAccessOverride(), - this.getAccessObject(), + getAccessObject(), "defaultAccessOverride", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getUser_DefaultAccess(), - this.getAccessObject(), + getAccessObject(), "defaultAccess", null, 0, 1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getUser_Locked(), @@ -1525,27 +1615,27 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "locked", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_Password(), - this.getUserPassword(), + getUserPassword(), null, "password", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_AllGroups(), - this.getGroup(), + getGroup(), null, "allGroups", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_AllRoles(), - this.getRole(), + getRole(), null, "allRoles", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_AllPermissions(), - this.getPermission(), + getPermission(), null, "allPermissions", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_UnassignedRoles(), - this.getRole(), + getRole(), null, "unassignedRoles", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ @@ -1560,12 +1650,12 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "Permission", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getPermission_Role(), - this.getRole(), - this.getRole_Permissions(), + getRole(), + getRole_Permissions(), "role", null, 1, 1, Permission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getPermission_Access(), - this.getAccess(), + getAccess(), "access", "WRITE", 1, 1, Permission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ initEClass(classPermissionEClass, ClassPermission.class, @@ -1598,7 +1688,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "FilterPermission", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getFilterPermission_Filters(), - this.getPermissionFilter(), + getPermissionFilter(), null, "filters", null, 1, -1, FilterPermission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ @@ -1609,7 +1699,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "LinkedFilter", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getLinkedFilter_Filter(), - this.getPermissionFilter(), + getPermissionFilter(), null, "filter", null, 1, 1, LinkedFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ @@ -1640,9 +1730,37 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage theEcorePackage.getEString(), "path", null, 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( - getResourceFilter_Inclusion(), - this.getInclusion(), - "inclusion", "Regex", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + getResourceFilter_PatternStyle(), + getPatternStyle(), + "patternStyle", "TREE", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_Folders(), + theEcorePackage.getEBoolean(), + "folders", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_TextResources(), + theEcorePackage.getEBoolean(), + "textResources", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_BinaryResources(), + theEcorePackage.getEBoolean(), + "binaryResources", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_ModelResources(), + theEcorePackage.getEBoolean(), + "modelResources", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_ModelObjects(), + theEcorePackage.getEBoolean(), + "modelObjects", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_IncludeParents(), + theEcorePackage.getEBoolean(), + "includeParents", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ + initEAttribute( + getResourceFilter_IncludeRoot(), + theEcorePackage.getEBoolean(), + "includeRoot", "true", 0, 1, ResourceFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ initEClass(objectFilterEClass, ObjectFilter.class, "ObjectFilter", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -1659,7 +1777,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "CombinedFilter", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getCombinedFilter_Operands(), - this.getPermissionFilter(), + getPermissionFilter(), null, "operands", null, 1, -1, CombinedFilter.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ @@ -1670,11 +1788,11 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(orFilterEClass, OrFilter.class, "OrFilter", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ // Initialize enums and add enum literals - initEEnum(inclusionEEnum, Inclusion.class, "Inclusion"); //$NON-NLS-1$ - addEEnumLiteral(inclusionEEnum, Inclusion.EXACT); - addEEnumLiteral(inclusionEEnum, Inclusion.EXACT_AND_UP); - addEEnumLiteral(inclusionEEnum, Inclusion.EXACT_AND_DOWN); - addEEnumLiteral(inclusionEEnum, Inclusion.REGEX); + initEEnum(patternStyleEEnum, PatternStyle.class, "PatternStyle"); //$NON-NLS-1$ + addEEnumLiteral(patternStyleEEnum, PatternStyle.EXACT); + addEEnumLiteral(patternStyleEEnum, PatternStyle.TREE); + addEEnumLiteral(patternStyleEEnum, PatternStyle.ANT); + addEEnumLiteral(patternStyleEEnum, PatternStyle.REGEX); initEEnum(accessEEnum, Access.class, "Access"); //$NON-NLS-1$ addEEnumLiteral(accessEEnum, Access.READ); diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java index 56295c029c..3317903a30 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java @@ -34,6 +34,8 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil; import org.eclipse.net4j.util.security.DiffieHellman.Client.Response; import org.eclipse.net4j.util.security.DiffieHellman.Server.Challenge; +import java.util.Set; + /** * @author Eike Stepper */ @@ -147,11 +149,19 @@ public class CDOServerProtocol extends SignalProtocol<InternalSession> implement sendCommitNotification(commitInfo, true); } + @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception { + sendCommitNotification(commitInfo, true, null); + + } + + public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly) + throws Exception + { if (LifecycleUtil.isActive(getChannel())) { - new CommitNotificationRequest(this, commitInfo, clearResourcePathCache).sendAsync(); + new CommitNotificationRequest(this, commitInfo, clearResourcePathCache, readOnly).sendAsync(); } else { diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java index 32e1d0f762..166c8963ff 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitNotificationRequest.java @@ -13,10 +13,12 @@ package org.eclipse.emf.cdo.server.internal.net4j.protocol; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; import java.io.IOException; +import java.util.Set; /** * @author Eike Stepper @@ -27,18 +29,34 @@ public class CommitNotificationRequest extends CDOServerRequest private boolean clearResourcePathCache; + private Set<CDOID> readOnly; + public CommitNotificationRequest(CDOServerProtocol serverProtocol, CDOCommitInfo commitInfo, - boolean clearResourcePathCache) + boolean clearResourcePathCache, Set<CDOID> readOnly) { super(serverProtocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION); this.commitInfo = commitInfo; this.clearResourcePathCache = clearResourcePathCache; + this.readOnly = readOnly; } @Override protected void requesting(CDODataOutput out) throws IOException { - out.writeCDOCommitInfo(commitInfo); // Exposes revision to client side + out.writeCDOCommitInfo(commitInfo); out.writeBoolean(clearResourcePathCache); + + if (readOnly != null) + { + out.writeInt(readOnly.size()); + for (CDOID id : readOnly) + { + out.writeCDOID(id); + } + } + else + { + out.writeInt(0); + } } } diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java index b54ce5e022..863607b836 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java @@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.server.internal.net4j.protocol; import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDReference; @@ -24,7 +25,9 @@ import org.eclipse.emf.cdo.common.model.EMFUtil; import org.eclipse.emf.cdo.common.protocol.CDODataInput; import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.etypes.EtypesPackage; +import org.eclipse.emf.cdo.server.IPermissionManager; import org.eclipse.emf.cdo.server.IView; import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; @@ -32,6 +35,7 @@ import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta; import org.eclipse.emf.cdo.spi.server.InternalCommitContext; +import org.eclipse.emf.cdo.spi.server.InternalSession; import org.eclipse.emf.cdo.spi.server.InternalTransaction; import org.eclipse.emf.cdo.spi.server.InternalView; @@ -332,6 +336,7 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori respondingResult(out); respondingMappingNewObjects(out); respondingNewLockStates(out); + respondingNewPermissions(out); } } finally @@ -407,6 +412,38 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori } } + protected void respondingNewPermissions(CDODataOutput out) throws Exception + { + InternalSession session = getSession(); + IPermissionManager permissionManager = session.getManager().getPermissionManager(); + if (permissionManager != null) + { + out.writeBoolean(true); + respondingNewPermissions(out, permissionManager, session, commitContext.getNewObjects()); + respondingNewPermissions(out, permissionManager, session, commitContext.getDirtyObjects()); + } + else + { + out.writeBoolean(false); + } + } + + protected void respondingNewPermissions(CDODataOutput out, IPermissionManager permissionManager, + InternalSession session, InternalCDORevision[] revisions) throws Exception + { + CDOBranchPoint securityContext = commitContext.getBranchPoint(); + + out.writeInt(revisions.length); + for (int i = 0; i < revisions.length; i++) + { + InternalCDORevision revision = revisions[i]; + CDOPermission permission = permissionManager.getPermission(revision, securityContext, session); + + out.writeCDOID(revision.getID()); + out.writeEnum(permission); + } + } + protected InternalTransaction getTransaction(int viewID) { InternalView view = getSession().getView(viewID); diff --git a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml index 67fabfa74d..2692ee9a53 100644 --- a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml +++ b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml @@ -23,7 +23,9 @@ <property name="serializeCommits" value="false"/> <property name="optimisticLockingTimeout" value="10000"/> - <securityManager type="default" description="/security:annotation:home(/home)"/> + <!-- Example http://wiki.eclipse.org/CDO/Security_Manager + <securityManager type="default" description="/security:annotation:home(/home)"/> + --> <!-- Example http://bugs.eclipse.org/302775 <authenticator type="file" description="_database/repo1.users"/> 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 97a7a7d1c3..5a2d5715b9 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 @@ -25,7 +25,7 @@ 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.PatternStyle; import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.Role; @@ -79,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 SecurityFactory SF = SecurityFactory.eINSTANCE; + private final IListener repositoryListener = new LifecycleEventAdapter() { @Override @@ -248,7 +250,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage { public void execute(Realm realm) { - UserPassword userPassword = SecurityFactory.eINSTANCE.createUserPassword(); + UserPassword userPassword = SF.createUserPassword(); userPassword.setEncrypted(new String(password)); result[0] = realm.addUser(id); @@ -528,9 +530,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage protected Realm createRealm() { - final SecurityFactory factory = SecurityFactory.eINSTANCE; - - Realm realm = factory.createRealm("Security Realm"); + Realm realm = SF.createRealm("Security Realm"); realm.setDefaultRoleDirectory(addDirectory(realm, "Roles")); realm.setDefaultGroupDirectory(addDirectory(realm, "Groups")); realm.setDefaultUserDirectory(addDirectory(realm, "Users")); @@ -539,27 +539,25 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage Role allReaderRole = realm.addRole("All Objects Reader"); allReaderRole.getPermissions().add( - factory.createFilterPermission(Access.READ, factory.createResourceFilter(".*", Inclusion.REGEX))); + SF.createFilterPermission(Access.READ, SF.createResourceFilter(".*", PatternStyle.REGEX))); Role allWriterRole = realm.addRole("All Objects Writer"); allWriterRole.getPermissions().add( - factory.createFilterPermission(Access.WRITE, factory.createResourceFilter(".*", Inclusion.REGEX))); + SF.createFilterPermission(Access.WRITE, SF.createResourceFilter(".*", PatternStyle.REGEX))); Role treeReaderRole = realm.addRole("Resource Tree Reader"); treeReaderRole.getPermissions().add( - factory.createFilterPermission(Access.READ, factory.createPackageFilter(EresourcePackage.eINSTANCE))); + SF.createFilterPermission(Access.READ, SF.createPackageFilter(EresourcePackage.eINSTANCE))); Role treeWriterRole = realm.addRole("Resource Tree Writer"); treeWriterRole.getPermissions().add( - factory.createFilterPermission(Access.WRITE, factory.createPackageFilter(EresourcePackage.eINSTANCE))); + SF.createFilterPermission(Access.WRITE, SF.createPackageFilter(EresourcePackage.eINSTANCE))); Role adminRole = realm.addRole("Administration"); - 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))); + SF.createFilterPermission(Access.WRITE, SF.createResourceFilter(realmPath, PatternStyle.EXACT, false))); + adminRole.getPermissions().add( + SF.createFilterPermission(Access.READ, SF.createResourceFilter(realmPath, PatternStyle.EXACT, true))); // Create groups @@ -578,7 +576,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage protected Directory addDirectory(Realm realm, String name) { - Directory directory = SecurityFactory.eINSTANCE.createDirectory(name); + Directory directory = SF.createDirectory(name); realm.getItems().add(directory); return directory; } diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java index e16756e9aa..bc25ea01c6 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java @@ -11,7 +11,7 @@ package org.eclipse.emf.cdo.server.spi.security; import org.eclipse.emf.cdo.security.Access; -import org.eclipse.emf.cdo.security.Inclusion; +import org.eclipse.emf.cdo.security.PatternStyle; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.SecurityFactory; @@ -43,6 +43,8 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 { public static final String DEFAULT_HOME_FOLDER = "/home"; + private static final SecurityFactory SF = SecurityFactory.eINSTANCE; + private final String homeFolder; public HomeFolderHandler(String homeFolder) @@ -80,12 +82,11 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 protected void initRole(Role role) { - role.getPermissions().add( - SecurityFactory.eINSTANCE.createFilterPermission(Access.WRITE, - SecurityFactory.eINSTANCE.createResourceFilter(homeFolder + "/${user}", Inclusion.EXACT_AND_DOWN))); - role.getPermissions().add( - SecurityFactory.eINSTANCE.createFilterPermission(Access.READ, - SecurityFactory.eINSTANCE.createResourceFilter(homeFolder, Inclusion.EXACT_AND_UP))); + role.getPermissions().add(SF.createFilterPermission(Access.WRITE, // + SF.createResourceFilter(homeFolder + "/${user}", PatternStyle.TREE, false))); + + role.getPermissions().add(SF.createFilterPermission(Access.READ, // + SF.createResourceFilter(homeFolder, PatternStyle.EXACT, true))); } public void handleCommit(final InternalSecurityManager securityManager, CommitContext commitContext, User user) diff --git a/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters index 032429eaa5..c9af39e940 100644 --- a/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters +++ b/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters @@ -1,21 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <component id="org.eclipse.emf.cdo.server" version="2"> - <resource path="src/org/eclipse/emf/cdo/internal/server/DelegatingRepository.java" type="org.eclipse.emf.cdo.internal.server.DelegatingRepository"> - <filter id="574660632"> - <message_arguments> - <message_argument value="InternalRepository"/> - <message_argument value="CDOCommonRepository"/> - <message_argument value="DelegatingRepository"/> - </message_arguments> - </filter> - <filter id="574668824"> - <message_arguments> - <message_argument value="InternalRepository"/> - <message_argument value="DelegatingRepository"/> - <message_argument value="CDOCommonRepository"/> - </message_arguments> - </filter> - </resource> <resource path="src/org/eclipse/emf/cdo/internal/server/LockingManager.java" type="org.eclipse.emf.cdo.internal.server.LockingManager$DurableView"> <filter id="574619656"> <message_arguments> diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/DelegatingRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/DelegatingRepository.java deleted file mode 100644 index 3fe2aa9f5c..0000000000 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/DelegatingRepository.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Copyright (c) 2009-2013 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.server; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.commit.CDOCommitData; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOID.ObjectType; -import org.eclipse.emf.cdo.common.lob.CDOLobHandler; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; -import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.common.util.CDOQueryInfo; -import org.eclipse.emf.cdo.server.IQueryHandler; -import org.eclipse.emf.cdo.server.IQueryHandlerProvider; -import org.eclipse.emf.cdo.server.IStoreAccessor; -import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext; -import org.eclipse.emf.cdo.server.ITransaction; -import org.eclipse.emf.cdo.spi.common.CDOReplicationContext; -import org.eclipse.emf.cdo.spi.common.CDOReplicationInfo; -import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; -import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo; -import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; -import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; -import org.eclipse.emf.cdo.spi.server.InternalCommitContext; -import org.eclipse.emf.cdo.spi.server.InternalCommitManager; -import org.eclipse.emf.cdo.spi.server.InternalLockManager; -import org.eclipse.emf.cdo.spi.server.InternalQueryManager; -import org.eclipse.emf.cdo.spi.server.InternalRepository; -import org.eclipse.emf.cdo.spi.server.InternalSession; -import org.eclipse.emf.cdo.spi.server.InternalSessionManager; -import org.eclipse.emf.cdo.spi.server.InternalStore; -import org.eclipse.emf.cdo.spi.server.InternalTransaction; -import org.eclipse.emf.cdo.spi.server.InternalView; - -import org.eclipse.net4j.util.collection.Pair; -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.om.monitor.OMMonitor; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult; -import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Semaphore; - -/** - * @author Eike Stepper - */ -public abstract class DelegatingRepository implements InternalRepository -{ - public DelegatingRepository() - { - } - - protected abstract InternalRepository getDelegate(); - - public void addHandler(Handler handler) - { - getDelegate().addHandler(handler); - } - - public void addListener(IListener listener) - { - getDelegate().addListener(listener); - } - - public long[] createCommitTimeStamp(OMMonitor monitor) - { - return getDelegate().createCommitTimeStamp(monitor); - } - - public IStoreAccessor ensureChunk(InternalCDORevision revision, EStructuralFeature feature, int chunkStart, - int chunkEnd) - { - return getDelegate().ensureChunk(revision, feature, chunkStart, chunkEnd); - } - - public InternalCommitManager getCommitManager() - { - return getDelegate().getCommitManager(); - } - - public long getCreationTime() - { - return getDelegate().getCreationTime(); - } - - public Object[] getElements() - { - return getDelegate().getElements(); - } - - public long getLastCommitTimeStamp() - { - return getDelegate().getLastCommitTimeStamp(); - } - - public IListener[] getListeners() - { - return getDelegate().getListeners(); - } - - @Deprecated - public InternalLockManager getLockManager() - { - return getDelegate().getLockingManager(); - } - - public String getName() - { - return getDelegate().getName(); - } - - public InternalCDOPackageRegistry getPackageRegistry() - { - return getDelegate().getPackageRegistry(); - } - - public InternalCDOPackageRegistry getPackageRegistry(boolean considerCommitContext) - { - return getDelegate().getPackageRegistry(considerCommitContext); - } - - public Map<String, String> getProperties() - { - return getDelegate().getProperties(); - } - - public IQueryHandler getQueryHandler(CDOQueryInfo info) - { - return getDelegate().getQueryHandler(info); - } - - public IQueryHandlerProvider getQueryHandlerProvider() - { - return getDelegate().getQueryHandlerProvider(); - } - - public InternalQueryManager getQueryManager() - { - return getDelegate().getQueryManager(); - } - - public InternalCDORevisionManager getRevisionManager() - { - return getDelegate().getRevisionManager(); - } - - public InternalSessionManager getSessionManager() - { - return getDelegate().getSessionManager(); - } - - public InternalStore getStore() - { - return getDelegate().getStore(); - } - - public String getUUID() - { - return getDelegate().getUUID(); - } - - public boolean hasListeners() - { - return getDelegate().hasListeners(); - } - - public boolean isEmpty() - { - return getDelegate().isEmpty(); - } - - public boolean isSupportingAudits() - { - return getDelegate().isSupportingAudits(); - } - - public boolean isSupportingBranches() - { - return getDelegate().isSupportingBranches(); - } - - public EPackage[] loadPackages(CDOPackageUnit packageUnit) - { - return getDelegate().loadPackages(packageUnit); - } - - public InternalCDOBranchManager getBranchManager() - { - return getDelegate().getBranchManager(); - } - - public void setBranchManager(InternalCDOBranchManager branchManager) - { - getDelegate().setBranchManager(branchManager); - } - - public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo) - { - return getDelegate().createBranch(branchID, branchInfo); - } - - public BranchInfo loadBranch(int branchID) - { - return getDelegate().loadBranch(branchID); - } - - public SubBranchInfo[] loadSubBranches(int branchID) - { - return getDelegate().loadSubBranches(branchID); - } - - public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint, - int referenceChunk, int prefetchDepth) - { - return getDelegate().loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth); - } - - public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk) - { - return getDelegate().loadRevisionByVersion(id, branchVersion, referenceChunk); - } - - public void notifyReadAccessHandlers(InternalSession session, CDORevision[] revisions, - List<CDORevision> additionalRevisions) - { - getDelegate().notifyReadAccessHandlers(session, revisions, additionalRevisions); - } - - public void notifyWriteAccessHandlers(ITransaction transaction, CommitContext commitContext, boolean beforeCommit, - OMMonitor monitor) - { - getDelegate().notifyWriteAccessHandlers(transaction, commitContext, beforeCommit, monitor); - } - - public void removeHandler(Handler handler) - { - getDelegate().removeHandler(handler); - } - - public void removeListener(IListener listener) - { - getDelegate().removeListener(listener); - } - - public void setName(String name) - { - getDelegate().setName(name); - } - - public void setProperties(Map<String, String> properties) - { - getDelegate().setProperties(properties); - } - - public void setQueryHandlerProvider(IQueryHandlerProvider queryHandlerProvider) - { - getDelegate().setQueryHandlerProvider(queryHandlerProvider); - } - - public void setRevisionManager(InternalCDORevisionManager revisionManager) - { - getDelegate().setRevisionManager(revisionManager); - } - - public void setSessionManager(InternalSessionManager sessionManager) - { - getDelegate().setSessionManager(sessionManager); - } - - public void setStore(InternalStore store) - { - getDelegate().setStore(store); - } - - public long getTimeStamp() - { - return getDelegate().getTimeStamp(); - } - - public void validateTimeStamp(long timeStamp) throws IllegalArgumentException - { - getDelegate().validateTimeStamp(timeStamp); - } - - public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler) - { - getDelegate().loadCommitInfos(branch, startTime, endTime, handler); - } - - public CDOCommitData loadCommitData(long timeStamp) - { - return getDelegate().loadCommitData(timeStamp); - } - - public Type getType() - { - return getDelegate().getType(); - } - - public State getState() - { - return getDelegate().getState(); - } - - public String getStoreType() - { - return getDelegate().getStoreType(); - } - - public Set<ObjectType> getObjectIDTypes() - { - return getDelegate().getObjectIDTypes(); - } - - public IDGenerationLocation getIDGenerationLocation() - { - return getDelegate().getIDGenerationLocation(); - } - - public CDOID getRootResourceID() - { - return getDelegate().getRootResourceID(); - } - - public Object processPackage(Object value) - { - return getDelegate().processPackage(value); - } - - @Deprecated - public boolean isSupportingEcore() - { - return getDelegate().isSupportingEcore(); - } - - public boolean isEnsuringReferentialIntegrity() - { - return getDelegate().isEnsuringReferentialIntegrity(); - } - - public void setType(Type type) - { - getDelegate().setType(type); - } - - public long waitForCommit(long timeout) - { - return getDelegate().waitForCommit(timeout); - } - - public void setState(State state) - { - getDelegate().setState(state); - } - - public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler) - { - return getDelegate().loadBranches(startID, endID, branchHandler); - } - - public Semaphore getPackageRegistryCommitLock() - { - return getDelegate().getPackageRegistryCommitLock(); - } - - @Deprecated - public CDOCommitInfoHandler[] getCommitInfoHandlers() - { - return getDelegate().getCommitInfoHandlers(); - } - - @Deprecated - public void addCommitInfoHandler(CDOCommitInfoHandler handler) - { - getDelegate().addCommitInfoHandler(handler); - } - - @Deprecated - public void removeCommitInfoHandler(CDOCommitInfoHandler handler) - { - getDelegate().removeCommitInfoHandler(handler); - } - - public InternalCDOCommitInfoManager getCommitInfoManager() - { - return getDelegate().getCommitInfoManager(); - } - - public Set<Handler> getHandlers() - { - return getDelegate().getHandlers(); - } - - public void setInitialPackages(EPackage... initialPackages) - { - getDelegate().setInitialPackages(initialPackages); - } - - public InternalLockManager getLockingManager() - { - return getDelegate().getLockingManager(); - } - - public InternalCommitContext createCommitContext(InternalTransaction transaction) - { - return getDelegate().createCommitContext(transaction); - } - - public long[] forceCommitTimeStamp(long timestamp, OMMonitor monitor) - { - return getDelegate().forceCommitTimeStamp(timestamp, monitor); - } - - public void endCommit(long timeStamp) - { - getDelegate().endCommit(timeStamp); - } - - public void failCommit(long timeStamp) - { - getDelegate().failCommit(timeStamp); - } - - @Deprecated - public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo) - { - getDelegate().sendCommitNotification(sender, commitInfo); - } - - public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache) - { - getDelegate().sendCommitNotification(sender, commitInfo, clearResourcePathCache); - } - - public void setRootResourceID(CDOID rootResourceID) - { - getDelegate().setRootResourceID(rootResourceID); - } - - public void setLastCommitTimeStamp(long commitTimeStamp) - { - getDelegate().setLastCommitTimeStamp(commitTimeStamp); - } - - public void ensureChunk(InternalCDORevision revision, int chunkSize) - { - getDelegate().ensureChunks(revision, chunkSize); - } - - public void replicate(CDOReplicationContext context) - { - getDelegate().replicate(context); - } - - public CDOReplicationInfo replicateRaw(CDODataOutput out, int lastReplicatedBranchID, long lastReplicatedCommitTime) - throws IOException - { - return getDelegate().replicateRaw(out, lastReplicatedBranchID, lastReplicatedCommitTime); - } - - public CDOChangeSetData getChangeSet(CDOBranchPoint startPoint, CDOBranchPoint endPoint) - { - return getDelegate().getChangeSet(startPoint, endPoint); - } - - public Set<CDOID> getMergeData(CDORevisionAvailabilityInfo targetInfo, CDORevisionAvailabilityInfo sourceInfo, - CDORevisionAvailabilityInfo targetBaseInfo, CDORevisionAvailabilityInfo sourceBaseInfo, OMMonitor monitor) - { - return getDelegate().getMergeData(targetInfo, sourceInfo, targetBaseInfo, sourceBaseInfo, monitor); - } - - public void queryLobs(List<byte[]> ids) - { - getDelegate().queryLobs(ids); - } - - public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException - { - getDelegate().handleLobs(fromTime, toTime, handler); - } - - public void loadLob(byte[] id, OutputStream out) throws IOException - { - getDelegate().loadLob(id, out); - } - - public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, - CDORevisionHandler handler) - { - getDelegate().handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler); - } - - public boolean isSkipInitialization() - { - return getDelegate().isSkipInitialization(); - } - - public void setSkipInitialization(boolean skipInitialization) - { - getDelegate().setSkipInitialization(skipInitialization); - } - - public void initSystemPackages() - { - getDelegate().initSystemPackages(); - } - - public void initMainBranch(InternalCDOBranchManager branchManager, long timeStamp) - { - getDelegate().initMainBranch(branchManager, timeStamp); - } - - public LockObjectsResult lock(InternalView view, LockType type, List<CDORevisionKey> keys, boolean recursive, - long timeout) - { - return getDelegate().lock(view, type, keys, recursive, timeout); - } - - public UnlockObjectsResult unlock(InternalView view, LockType type, List<CDOID> ids, boolean recursive) - { - return getDelegate().unlock(view, type, ids, recursive); - } -} diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java index 84a9d1ac5b..7a29c97536 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java @@ -41,6 +41,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; @@ -1042,12 +1043,19 @@ public class Repository extends Container<Object> implements InternalRepository commitInfoManager.removeCommitInfoHandler(handler); } + @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache) { + sendCommitNotification(sender, commitInfo, clearResourcePathCache, null); + } + + public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider) + { boolean isFailureCommitInfo = commitInfo.getBranch() == null; if (isFailureCommitInfo || !commitInfo.isEmpty()) { - sessionManager.sendCommitNotification(sender, commitInfo, clearResourcePathCache); + sessionManager.sendCommitNotification(sender, commitInfo, clearResourcePathCache, revisionProvider); commitInfoManager.notifyCommitInfoHandlers(commitInfo); } } diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java index 443a7d5247..26e6b31855 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java @@ -27,6 +27,7 @@ import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.server.IStoreAccessor; import org.eclipse.emf.cdo.session.CDORepositoryInfo; import org.eclipse.emf.cdo.session.CDOSession; @@ -942,22 +943,35 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd throw new UnsupportedOperationException(); } + @Deprecated public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache) { throw new UnsupportedOperationException(); } + public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache, + Map<CDOID, CDOPermission> permissions) + { + throw new UnsupportedOperationException(); + } + @Deprecated public void handleCommitNotification(CDOCommitInfo commitInfo) { throw new UnsupportedOperationException(); } + @Deprecated public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) { throw new UnsupportedOperationException(); } + public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly) + { + throw new UnsupportedOperationException(); + } + public void handleLockNotification(CDOLockChangeInfo lockChangeInfo, InternalCDOView sender) { throw new UnsupportedOperationException(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java index ab8f065d15..2d6b8d4049 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java @@ -26,7 +26,9 @@ import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.internal.common.commit.DelegatingCommitInfo; import org.eclipse.emf.cdo.server.IPermissionManager; @@ -57,6 +59,7 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.core.runtime.Platform; import java.text.MessageFormat; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -407,7 +410,14 @@ public class Session extends Container<IView> implements InternalSession sendCommitNotification(commitInfo, true); } - public void sendCommitNotification(final CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception + @Deprecated + public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception + { + sendCommitNotification(commitInfo, true, null); + } + + public void sendCommitNotification(final CDOCommitInfo commitInfo, boolean clearResourcePathCache, + final CDORevisionProvider revisionProvider) throws Exception { if (protocol == null) { @@ -419,7 +429,10 @@ public class Session extends Container<IView> implements InternalSession return; } + final IPermissionManager permissionManager = manager.getPermissionManager(); + final Set<CDOID> readOnly = new HashSet<CDOID>(); final InternalView[] views = getViews(); + protocol.sendCommitNotification(new DelegatingCommitInfo() { private final PassiveUpdateMode passiveUpdateMode = getPassiveUpdateMode(); @@ -443,16 +456,30 @@ public class Session extends Container<IView> implements InternalSession @Override public CDOIDAndVersion get(int index) { - // The following will always be a CDORevision! - CDOIDAndVersion newObject = newObjects.get(index); + CDORevision revision = (CDORevision)newObjects.get(index); if (additions) { - // Return full revisions if not in INVALIDATION mode - return newObject; + if (permissionManager == null) + { + // Return full revision + return revision; + } + + CDOPermission permission = permissionManager.getPermission(revision, commitInfo, Session.this); + if (permission != CDOPermission.NONE) + { + if (permission == CDOPermission.READ) + { + readOnly.add(revision.getID()); + } + + // Return full revision + return revision; + } } - // Prevent sending whole revisions by copying the id and version - return CDOIDUtil.createIDAndVersion(newObject); + // Prevent sending full revision by copying the id and version + return CDOIDUtil.createIDAndVersion(revision); } @Override @@ -472,15 +499,39 @@ public class Session extends Container<IView> implements InternalSession @Override public CDORevisionKey get(int index) { - // The following will always be a CDORevisionDelta! - CDORevisionKey changedObject = changedObjects.get(index); - if (changes || additions || hasSubscription(changedObject.getID(), views)) + CDORevisionDelta revisionDelta = (CDORevisionDelta)changedObjects.get(index); + CDOID id = revisionDelta.getID(); + + if (changes || additions || hasSubscription(id, views)) { - return changedObject; + if (permissionManager == null) + { + // Return full delta + return revisionDelta; + } + + if (revisionProvider == null) + { + // Return full delta + return revisionDelta; + } + + CDORevision newRevision = revisionProvider.getRevision(id); + CDOPermission permission = permissionManager.getPermission(newRevision, commitInfo, Session.this); + if (permission != CDOPermission.NONE) + { + if (permission == CDOPermission.READ) + { + readOnly.add(id); + } + + // Return full delta + return revisionDelta; + } } - // Prevent sending whole revisions by copying the id and version - return CDORevisionUtil.copyRevisionKey(changedObject); + // Prevent sending full delta by copying the id and version + return CDORevisionUtil.copyRevisionKey(revisionDelta); } @Override @@ -490,7 +541,7 @@ public class Session extends Container<IView> implements InternalSession } }; } - }, clearResourcePathCache); + }, clearResourcePathCache, readOnly); synchronized (lastUpdateTimeLock) { diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java index e88c991807..f4444d53f2 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.util.NotAuthenticatedException; import org.eclipse.emf.cdo.internal.server.bundle.OM; import org.eclipse.emf.cdo.server.IPermissionManager; @@ -285,15 +286,22 @@ public class SessionManager extends Container<ISession> implements InternalSessi sendCommitNotification(sender, commitInfo, true); } + @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache) { + sendCommitNotification(sender, commitInfo, true, null); + } + + public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider) + { for (InternalSession session : getSessions()) { if (session != sender) { try { - session.sendCommitNotification(commitInfo, clearResourcePathCache); + session.sendCommitNotification(commitInfo, clearResourcePathCache, revisionProvider); } catch (Exception ex) { 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 3985e6dbf8..8f2acf818c 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 @@ -780,10 +780,7 @@ public class TransactionCommitContext implements InternalCommitContext // Send notifications (in particular FailureCommitInfos) only if timeStamp had been allocated if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE) { - InternalSession sender = transaction.getSession(); - CDOCommitInfo commitInfo = success ? createCommitInfo() : createFailureCommitInfo(); - - repository.sendCommitNotification(sender, commitInfo, clearResourcePathCache); + sendCommitNotifications(success); } } catch (Exception ex) @@ -804,6 +801,14 @@ public class TransactionCommitContext implements InternalCommitContext } } + private void sendCommitNotifications(boolean success) + { + InternalSession sender = transaction.getSession(); + CDOCommitInfo commitInfo = success ? createCommitInfo() : createFailureCommitInfo(); + + repository.sendCommitNotification(sender, commitInfo, clearResourcePathCache, this); + } + public CDOCommitInfo createCommitInfo() { String userID = transaction.getSession().getUserID(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java index 1172e5cac9..ea68f0d544 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedServerSessionProtocol.java @@ -24,6 +24,8 @@ import org.eclipse.net4j.util.lifecycle.Lifecycle; import org.eclipse.net4j.util.security.DiffieHellman.Client.Response; import org.eclipse.net4j.util.security.DiffieHellman.Server.Challenge; +import java.util.Set; + /** * @author Eike Stepper * @deprecated Not yet supported. @@ -95,17 +97,25 @@ public class EmbeddedServerSessionProtocol extends Lifecycle implements ISession clientSession.handleBranchNotification(branch); } + @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo) { EmbeddedClientSession clientSession = clientSessionProtocol.getSession(); clientSession.handleCommitNotification(commitInfo); } + @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception { throw new UnsupportedOperationException(); } + public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly) + throws Exception + { + throw new UnsupportedOperationException(); + } + public void sendLockNotification(CDOLockChangeInfo lockChangeInfo) { EmbeddedClientSession clientSession = clientSessionProtocol.getSession(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java index 4f3ffc4064..a2d026950f 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java @@ -451,7 +451,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem String comment = "<replicate raw commits>"; //$NON-NLS-1$ CDOCommitInfo commitInfo = manager.createCommitInfo(branch, toCommitTime, previousCommitTime, SYSTEM_USER_ID, comment, data); - sessionManager.sendCommitNotification(replicatorSession, commitInfo, true); + sessionManager.sendCommitNotification(replicatorSession, commitInfo, true, null); } CDOLockChangeInfo lockChangeInfo = CDOLockUtil.createLockChangeInfo(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java index 31ca4d1ccf..be490f99e0 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/ISessionProtocol.java @@ -21,6 +21,8 @@ import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; import org.eclipse.net4j.util.security.DiffieHellman.Client.Response; import org.eclipse.net4j.util.security.DiffieHellman.Server.Challenge; +import java.util.Set; + /** * If the meaning of this type isn't clear, there really should be more of a description here... * @@ -63,16 +65,24 @@ public interface ISessionProtocol extends CDOProtocol public void sendBranchNotification(InternalCDOBranch branch) throws Exception; /** - * @deprecated As of 4.2 use {@link #sendCommitNotification(CDOCommitInfo, boolean)} + * @deprecated As of 4.2 use {@link #sendCommitNotification(CDOCommitInfo, boolean)}. */ @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo) throws Exception; /** * @since 4.2 + * @deprecated As of 4.3 use {@link #sendCommitNotification(CDOCommitInfo, boolean, Set)}. */ + @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception; + /** + * @since 4.3 + */ + public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly) + throws Exception; + public void sendRemoteSessionNotification(InternalSession sender, byte opcode) throws Exception; public void sendRemoteMessageNotification(InternalSession sender, CDORemoteSessionMessage message) throws Exception; diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepository.java index 99e515ea9c..4b42ddfabf 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepository.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepository.java @@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.server.IQueryHandlerProvider; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.IStoreAccessor; @@ -173,16 +174,24 @@ public interface InternalRepository extends IRepository, PackageProcessor, Packa /** * @since 4.0 - * @deprecated As of 4.2 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean)} + * @deprecated As of 4.2 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean)}. */ @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo); /** * @since 4.2 + * @deprecated As of 4.3 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean, CDORevisionProvider)}. */ + @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache); + /** + * @since 4.3 + */ + public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider); + public void setRootResourceID(CDOID rootResourceID); /** diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSession.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSession.java index cfd854fb29..6063004af6 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSession.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSession.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDProvider; import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.security.CDOPermissionProvider; import org.eclipse.emf.cdo.server.ISession; import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; @@ -82,16 +83,24 @@ public interface InternalSession extends ISession, CDOIDProvider, CDOPermissionP public void sendBranchNotification(InternalCDOBranch branch) throws Exception; /** - * @deprecated As of 4.2 use {@link #sendCommitNotification(CDOCommitInfo, boolean)} + * @deprecated As of 4.2 use {@link #sendCommitNotification(CDOCommitInfo, boolean)}. */ @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo) throws Exception; /** * @since 4.2 + * @deprecated As of 4.3 use {@link #sendCommitNotification(CDOCommitInfo, boolean, CDORevisionProvider)}. */ + @Deprecated public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) throws Exception; + /** + * @since 4.3 + */ + public void sendCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider) throws Exception; + public void sendRemoteSessionNotification(InternalSession sender, byte opcode) throws Exception; public void sendRemoteMessageNotification(InternalSession sender, CDORemoteSessionMessage message) throws Exception; diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java index bc5545b01d..4d406f04d1 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalSessionManager.java @@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.common.CDOCommonRepository; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.server.IPermissionManager; import org.eclipse.emf.cdo.server.ISessionManager; import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; @@ -102,17 +103,25 @@ public interface InternalSessionManager extends ISessionManager public void sendBranchNotification(InternalSession sender, InternalCDOBranch branch); /** - * @deprecated As of 4.2 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean)} + * @deprecated As of 4.2 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean)}. */ @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo); /** * @since 4.2 + * @deprecated As of 4.3 use {@link #sendCommitNotification(InternalSession, CDOCommitInfo, boolean, CDORevisionProvider)}. */ + @Deprecated public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache); /** + * @since 4.3 + */ + public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider); + + /** * @since 4.1 */ public void sendLockNotification(InternalSession sender, CDOLockChangeInfo lockChangeInfo); diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java index a545218506..25c5a4fe5b 100644 --- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java +++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java @@ -28,7 +28,7 @@ import org.eclipse.emf.cdo.tests.LockingNotificationsTest; import org.eclipse.emf.cdo.tests.MEMStoreQueryTest; import org.eclipse.emf.cdo.tests.MultiValuedOfAttributeTest; import org.eclipse.emf.cdo.tests.PackageRegistryTest; -import org.eclipse.emf.cdo.tests.SecurityManagerTest; +import org.eclipse.emf.cdo.tests.SecurityTest; import org.eclipse.emf.cdo.tests.UnsetTest; import org.eclipse.emf.cdo.tests.WorkspaceTest; import org.eclipse.emf.cdo.tests.XATransactionTest; @@ -149,7 +149,7 @@ public class AllTestsHibernate extends AllConfigs // the security model inherits from the ecore model // not so well supported for now for auditing - testClasses.remove(SecurityManagerTest.class); + testClasses.remove(SecurityTest.class); // the package registry count changes when auditing // as auditing adds epackages diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java index 7d679e4a67..c26f04e9c0 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java @@ -63,7 +63,7 @@ public class AllConfigs extends ConfigTestSuite testClasses.add(PushTransactionTest.class); testClasses.add(PushTransactionWithoutReconstructSavepointsTest.class); testClasses.add(CommitInfoTest.class); - testClasses.add(SecurityManagerTest.class); + testClasses.add(SecurityTest.class); testClasses.add(AuditTest.class); testClasses.add(AuditEMapTest.class); testClasses.add(AuditSameSessionTest.class); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityManagerTest.java deleted file mode 100644 index 5a032f38e9..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityManagerTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2012, 2013 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.tests; - -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.security.Realm; -import org.eclipse.emf.cdo.security.User; -import org.eclipse.emf.cdo.server.security.ISecurityManager; -import org.eclipse.emf.cdo.server.security.SecurityManagerUtil; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter; -import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; -import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; -import org.eclipse.emf.cdo.tests.config.impl.SessionConfig; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; -import org.eclipse.net4j.util.security.PasswordCredentialsProvider; - -/** - * @author Eike Stepper - */ -@CleanRepositoriesBefore(reason = "TEST_SECURITY_MANAGER") -@CleanRepositoriesAfter(reason = "TEST_SECURITY_MANAGER") -public class SecurityManagerTest extends AbstractCDOTest -{ - private static final String USER_ID = "Stepper"; - - private static final String PASSWORD = "12345"; - - public void testCommit() throws Exception - { - ISecurityManager securityManager = startRepository(); - securityManager.modify(new ISecurityManager.RealmOperation() - { - public void execute(Realm realm) - { - User user = realm.addUser(USER_ID, PASSWORD); - user.getGroups().add(realm.getGroup("Users")); - user.getRoles().add(realm.getRole("All Objects Writer")); - } - }); - - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource(getResourcePath("/res")); - resource.getContents().add(getModel1Factory().createProduct1()); - transaction.commit(); - } - - private ISecurityManager startRepository() - { - ISecurityManager securityManager = SecurityManagerUtil.createSecurityManager("/security", getServerContainer()); - getTestProperties().put(RepositoryConfig.PROP_TEST_SECURITY_MANAGER, securityManager); - - IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(USER_ID, PASSWORD); - getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER, credentialsProvider); - - getRepository(); // Start repository - - return securityManager; - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityTest.java new file mode 100644 index 0000000000..a169b3e7fe --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SecurityTest.java @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2012, 2013 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.tests; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.revision.CDOList; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; +import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.security.PermissionUtil; +import org.eclipse.emf.cdo.security.PatternStyle; +import org.eclipse.emf.cdo.security.PermissionFilter; +import org.eclipse.emf.cdo.security.ResourceFilter; +import org.eclipse.emf.cdo.security.SecurityFactory; +import org.eclipse.emf.cdo.security.impl.PermissionFilterImpl; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class SecurityTest extends AbstractCDOTest +{ + private static final SecurityFactory SF = SecurityFactory.eINSTANCE; + + private static final PermissionFilter FALSE = new BooleanFilter(false); + + private static final PermissionFilter TRUE = new BooleanFilter(true); + + private static final EClass RESOURCE = EresourcePackage.Literals.CDO_RESOURCE; + + private static final EClass FOLDER = EresourcePackage.Literals.CDO_RESOURCE_FOLDER; + + public void testNotFilter() throws Exception + { + assertApplicable(false, FALSE); + assertApplicable(true, SF.createNotFilter(FALSE)); + + assertApplicable(true, TRUE); + assertApplicable(false, SF.createNotFilter(TRUE)); + } + + public void testAndFilter() throws Exception + { + assertApplicable(true, SF.createAndFilter()); + + assertApplicable(false, SF.createAndFilter(FALSE)); + assertApplicable(false, SF.createAndFilter(FALSE, FALSE)); + assertApplicable(false, SF.createAndFilter(FALSE, FALSE, FALSE)); + + assertApplicable(true, SF.createAndFilter(TRUE)); + assertApplicable(true, SF.createAndFilter(TRUE, TRUE)); + assertApplicable(true, SF.createAndFilter(TRUE, TRUE, TRUE)); + + assertApplicable(false, SF.createAndFilter(TRUE, FALSE)); + assertApplicable(false, SF.createAndFilter(FALSE, TRUE)); + } + + public void testOrFilter() throws Exception + { + assertApplicable(false, SF.createOrFilter()); + + assertApplicable(false, SF.createOrFilter(FALSE)); + assertApplicable(false, SF.createOrFilter(FALSE, FALSE)); + assertApplicable(false, SF.createOrFilter(FALSE, FALSE, FALSE)); + + assertApplicable(true, SF.createOrFilter(TRUE)); + assertApplicable(true, SF.createOrFilter(TRUE, TRUE)); + assertApplicable(true, SF.createOrFilter(TRUE, TRUE, TRUE)); + + assertApplicable(true, SF.createOrFilter(TRUE, FALSE)); + assertApplicable(true, SF.createOrFilter(FALSE, TRUE)); + } + + public void testResourceFilter_EXACT_Parents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/Stepper", PatternStyle.EXACT, true); + + checkSegments(filter, "/home/Stepper/private/a/b/c", "1110000"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + } + + public void testResourceFilter_EXACT_NoParents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/Stepper", PatternStyle.EXACT, false); + + checkSegments(filter, "/home/Stepper/private/a/b/c", "0010000"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + } + + public void testResourceFilter_TREE_Parents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/Stepper", PatternStyle.TREE, true); + + checkSegments(filter, "/home/Stepper/private/a/b/c", "1111111"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + } + + public void testResourceFilter_TREE_NoParents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/Stepper", PatternStyle.TREE, false); + + checkSegments(filter, "/home/Stepper/private/a/b/c", "0011111"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + } + + public void testResourceFilter_UserToken_EXACT_Parents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/${user}", PatternStyle.EXACT, true); + + try + { + PermissionUtil.setUser("Stepper"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "1110000"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + + PermissionUtil.setUser("Enemy"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "1100000"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + } + finally + { + PermissionUtil.setUser(null); + } + } + + public void testResourceFilter_UserToken_EXACT_NoParents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/${user}", PatternStyle.EXACT, false); + + try + { + PermissionUtil.setUser("Stepper"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "0010000"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + + PermissionUtil.setUser("Enemy"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "0000000"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + } + finally + { + PermissionUtil.setUser(null); + } + } + + public void testResourceFilter_UserToken_TREE_Parents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/${user}", PatternStyle.TREE, true); + + try + { + PermissionUtil.setUser("Stepper"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "1111111"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + + PermissionUtil.setUser("Enemy"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "1100000"); + checkSegments(filter, "/home/Step/private/a/b/c", "1100000"); + checkSegments(filter, "/homer/Stepper", "100"); + } + finally + { + PermissionUtil.setUser(null); + } + } + + public void testResourceFilter_UserToken_TREE_NoParents() throws Exception + { + ResourceFilter filter = SF.createResourceFilter("/home/${user}", PatternStyle.TREE, false); + + try + { + PermissionUtil.setUser("Stepper"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "0011111"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + + PermissionUtil.setUser("Enemy"); + checkSegments(filter, "/home/Stepper/private/a/b/c", "0000000"); + checkSegments(filter, "/home/Step/private/a/b/c", "0000000"); + checkSegments(filter, "/homer/Stepper", "000"); + } + finally + { + PermissionUtil.setUser(null); + } + } + + private void checkSegments(ResourceFilter filter, String resourcePath, String expectations) throws Exception + { + RevisionMap revisions = new RevisionMap(); + CDORevision[] segments = revisions.addResourceNode(resourcePath, RESOURCE); + + for (int i = 0; i < segments.length; i++) + { + CDORevision segment = segments[i]; + boolean expected = expectations.charAt(i) == '1'; + boolean actual = filter.isApplicable(segment, revisions, null, 0); + + assertEquals(segment.toString(), expected, actual); + } + } + + private void assertApplicable(boolean expected, PermissionFilter filter) throws Exception + { + assertEquals(expected, filter.isApplicable(null, null, null, 0)); + } + + /** + * @author Eike Stepper + */ + private static final class RevisionMap extends HashMap<CDOID, CDORevisionImpl> implements CDORevisionProvider + { + private static final long serialVersionUID = 1L; + + private final Map<String, CDORevisionImpl> resourceNodes = new HashMap<String, CDORevisionImpl>(); + + private long lastID; + + public CDORevisionImpl getRevision(CDOID id) + { + return get(id); + } + + public CDORevisionImpl addRevision(EClass type) + { + CDOID id = CDOIDUtil.createLong(++lastID); + + CDORevisionImpl revision = new CDORevisionImpl(type); + revision.setID(id); + + put(id, revision); + return revision; + } + + public CDORevisionImpl[] addResourceNode(String resourcePath, EClass type) + { + List<CDORevisionImpl> result = new ArrayList<CDORevisionImpl>(); + CDORevisionImpl revision = null; + EClass segmentType = RESOURCE; + + Path path = new Path(resourcePath); + for (int i = path.segmentCount(); i >= 0; --i) + { + IPath p = path.removeLastSegments(i); + String pathStr = p.toString(); + + CDORevisionImpl node = resourceNodes.get(pathStr); + if (node != null) + { + revision = node; + } + else + { + revision = createResource(revision, p.lastSegment(), i == 0 ? type : segmentType); + resourceNodes.put(pathStr, revision); + } + + result.add(revision); + segmentType = FOLDER; + } + + return result.toArray(new CDORevisionImpl[result.size()]); + } + + private CDORevisionImpl createResource(CDORevisionImpl parent, String name, EClass type) + { + CDORevisionImpl revision = addRevision(type); + revision.setValue(EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, name); + + if (parent != null) + { + revision.setContainerID(parent.getID()); + getContents(parent).add(revision.getID()); + + } + + return revision; + } + + private CDOList getContents(CDORevisionImpl revision) + { + if (revision.getEClass() == RESOURCE) + { + if (CDOIDUtil.isNull((CDOID)revision.getContainerID())) + { + return revision.getList(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS, 0); + } + + return null; + } + + return revision.getList(EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES, 0); + } + } + + /** + * @author Eike Stepper + */ + private static final class BooleanFilter extends PermissionFilterImpl + { + private final boolean value; + + public BooleanFilter(boolean value) + { + this.value = value; + } + + public String format() + { + return Boolean.toString(value); + } + + @Override + protected boolean filter(CDORevision revision, CDORevisionProvider revisionProvider, + CDOBranchPoint securityContext, int level) throws Exception + { + return value; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java index b59a11e65b..c4b6977412 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SessionTest.java @@ -382,7 +382,7 @@ public class SessionTest extends AbstractCDOTest getRepository("authrepo7"); getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER, - new PasswordCredentialsProvider(new PasswordCredentials(USER_ID, null))); + new PasswordCredentialsProvider(new PasswordCredentials(USER_ID))); try { diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417483_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417483_Test.java new file mode 100644 index 0000000000..5522ab811c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_417483_Test.java @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2013 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: + * Alex Lagarde - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.CDODeltaNotification; +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; +import org.eclipse.emf.cdo.common.security.CDOPermission; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.security.Access; +import org.eclipse.emf.cdo.security.PatternStyle; +import org.eclipse.emf.cdo.security.Realm; +import org.eclipse.emf.cdo.security.Role; +import org.eclipse.emf.cdo.security.SecurityFactory; +import org.eclipse.emf.cdo.security.User; +import org.eclipse.emf.cdo.server.security.ISecurityManager; +import org.eclipse.emf.cdo.server.security.SecurityManagerUtil; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.spi.server.InternalRepository; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; +import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig; +import org.eclipse.emf.cdo.tests.model1.Category; +import org.eclipse.emf.cdo.tests.model1.Company; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent; + +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.security.IPasswordCredentials; +import org.eclipse.net4j.util.security.PasswordCredentials; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.impl.TransactionChangeRecorder; +import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * Bug 417483 - [Security] Issues in invalidation when missing write Permission. + * <p> + * Tests ensuring that the permissions are correctly computed, no matter what passive update mode is chosen. + * + * @author Alex Lagarde + */ +@CleanRepositoriesBefore(reason = "TEST_SECURITY_MANAGER") +@CleanRepositoriesAfter(reason = "TEST_SECURITY_MANAGER") +public class Bugzilla_417483_Test extends AbstractCDOTest +{ + private static final SecurityFactory SF = SecurityFactory.eINSTANCE; + + private static final IPasswordCredentials CREDENTIALS = new PasswordCredentials("Stepper", "12345"); + + private static final IPasswordCredentials CREDENTIALS_READ_ONLY = new PasswordCredentials("Lagarde", "54321"); + + @Override + protected void doSetUp() throws Exception + { + super.doSetUp(); + + ISecurityManager securityManager = SecurityManagerUtil.createSecurityManager("/security", getServerContainer()); + + // Start repository + getTestProperties().put(RepositoryConfig.PROP_TEST_SECURITY_MANAGER, securityManager); + getRepository(); + + securityManager.modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(CREDENTIALS); + user.getRoles().add(realm.getRole("All Objects Writer")); + + User userReadOnly = realm.addUser(CREDENTIALS_READ_ONLY); + userReadOnly.getRoles().add(realm.getRole("All Objects Reader")); + } + }); + } + + public void testPassiveUpdates_Invalidations() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.INVALIDATIONS, false); + } + + public void testPassiveUpdates_InvalidationsWithEditingDomain() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.INVALIDATIONS, true); + } + + public void testPassiveUpdates_Changes() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.CHANGES, false); + } + + public void testPassiveUpdates_Changes_WithEditingDomain() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.CHANGES, true); + } + + public void testPassiveUpdates_Additions() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.ADDITIONS, false); + } + + public void testPassiveUpdates_Additions_WithEditingDomain() throws Exception + { + doPassiveUpdates(PassiveUpdateMode.ADDITIONS, true); + } + + protected void doPassiveUpdates(PassiveUpdateMode passiveUpdateMode, boolean withEditingDomain) throws Exception + { + // Both users connect to the repository + CDOSession session = openSession(CREDENTIALS); + CDOTransaction transaction = session.openTransaction(); + + CDOSession sessionReadOnly = openSession(CREDENTIALS_READ_ONLY); + sessionReadOnly.options().setPassiveUpdateEnabled(true); + sessionReadOnly.options().setPassiveUpdateMode(passiveUpdateMode); + + ResourceSet resourceSetReadOnly; + if (withEditingDomain) + { + resourceSetReadOnly = createTransactionalEditingDomain().getResourceSet(); + } + else + { + resourceSetReadOnly = new ResourceSetImpl(); + } + + CDOTransaction transactionReadOnly = sessionReadOnly.openTransaction(resourceSetReadOnly); + assertEquals(CREDENTIALS.getUserID(), session.getUserID()); + assertEquals(CREDENTIALS_READ_ONLY.getUserID(), sessionReadOnly.getUserID()); + + // User with write permission creates a resource and commits + CDOResource resource = transaction.createResource(getResourcePath("/res")); + assertEquals(true, isWritable(resource)); + + Category category = getModel1Factory().createCategory(); + resource.getContents().add(category); + commitAndSync(transaction, transactionReadOnly); + + // User without write permission should be able to integrate changes without permission issues + CDOResource resourceReadOnly = transactionReadOnly.getResource(getResourcePath("/res")); + assertEquals(1, resourceReadOnly.getContents().size()); + assertEquals("User should not have write permission on resource", false, isWritable(resourceReadOnly)); + + // => Trigger loading of resource root so that invalidation are sent + Category categoryReadOnly = (Category)resourceReadOnly.getContents().get(0); + assertEquals("User should not have write permission on element", false, isWritable(categoryReadOnly)); + + // User with write permission modifies the resource root and commits + category.getProducts().add(getModel1Factory().createProduct1()); + category.setName("RENAMED"); + + final CountDownLatch latch = new CountDownLatch(1); + transactionReadOnly.addListener(new IListener() + { + public void notifyEvent(IEvent event) + { + if (event instanceof CDOViewInvalidationEvent) + { + latch.countDown(); + } + } + }); + + transaction.commit(); + + // User without write permission should be able to integrate changes without permission issues + boolean notified = latch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); + assertEquals("Timeout: User should have been notified of changes", true, notified); + + assertEquals("User should not have write permission on resource", false, isWritable(resourceReadOnly)); + assertEquals("User should not have write permission on element", false, isWritable(categoryReadOnly)); + } + + /** + * Creates a {@link TransactionalEditingDomain} which has a {@link TransactionChangeRecorder} that does not throw an {@link IllegalStateException} if model is modified through a {@link CDODeltaNotification}. + */ + private TransactionalEditingDomain createTransactionalEditingDomain() + { + return new TransactionalEditingDomainImpl(null) + { + @Override + protected TransactionChangeRecorder createChangeRecorder(ResourceSet rset) + { + return new TransactionChangeRecorder(this, rset) + { + @Override + public void notifyChanged(Notification notification) + { + if (!(notification instanceof CDODeltaNotification)) + { + super.notifyChanged(notification); + } + } + }; + } + }; + } + + public void testLoad_NoPermission() throws Exception + { + final IPasswordCredentials credentials = new PasswordCredentials("user", "password"); + final String protectedResource = getResourcePath("/protected"); + + getSecurityManager().modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(credentials); + + Role role = realm.addRole(protectedResource + " Reader"); + role.getPermissions().add(SF.createFilterPermission(Access.READ, // + SF.createResourceFilter(protectedResource, PatternStyle.EXACT, true).setModelObjects(false))); + + user.getRoles().add(role); + } + }); + + { + // Init model with write full access + CDOSession session = openSession(CREDENTIALS); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(protectedResource); + resource.getContents().add(getModel1Factory().createCompany()); + transaction.commit(); + session.close(); + } + + CDOSession session = openSession(credentials); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(protectedResource); + assertEquals(CDOPermission.READ, resource.cdoPermission()); + + Company company = (Company)resource.getContents().get(0); + assertEquals(CDOPermission.NONE, CDOUtil.getCDOObject(company).cdoPermission()); + } + + public void testLoad_ReadPermission() throws Exception + { + final IPasswordCredentials credentials = new PasswordCredentials("user", "password"); + final String protectedResource = getResourcePath("/protected"); + + getSecurityManager().modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(credentials); + + Role role = realm.addRole(protectedResource + " Reader"); + role.getPermissions().add(SF.createFilterPermission(Access.READ, // + SF.createResourceFilter(protectedResource, PatternStyle.TREE, true))); + + user.getRoles().add(role); + } + }); + + { + // Init model with write full access + CDOSession session = openSession(CREDENTIALS); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(protectedResource); + resource.getContents().add(getModel1Factory().createCompany()); + transaction.commit(); + session.close(); + } + + CDOSession session = openSession(credentials); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(protectedResource); + assertEquals(CDOPermission.READ, resource.cdoPermission()); + + Company company = (Company)resource.getContents().get(0); + assertEquals(CDOPermission.READ, CDOUtil.getCDOObject(company).cdoPermission()); + } + + public void testCommit_NoPermission() throws Exception + { + final IPasswordCredentials credentials = new PasswordCredentials("user", "password"); + final String protectedResource = getResourcePath("/protected"); + + getSecurityManager().modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(credentials); + + Role role = realm.addRole(protectedResource + " Writer"); + role.getPermissions().add(SF.createFilterPermission(Access.WRITE, // + SF.createResourceFilter(protectedResource, PatternStyle.EXACT, true).setModelObjects(false))); + + user.getRoles().add(role); + } + }); + + CDOSession session = openSession(credentials); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(protectedResource); + assertEquals(CDOPermission.WRITE, resource.cdoPermission()); + + Company company = getModel1Factory().createCompany(); + resource.getContents().add(company); + assertEquals(CDOPermission.WRITE, CDOUtil.getCDOObject(company).cdoPermission()); + + transaction.commit(); + assertEquals(CDOPermission.NONE, CDOUtil.getCDOObject(company).cdoPermission()); + } + + public void testCommit_ReadPermission() throws Exception + { + final IPasswordCredentials credentials = new PasswordCredentials("user", "password"); + final String protectedResource = getResourcePath("/protected"); + + getSecurityManager().modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(credentials); + + Role role = realm.addRole(protectedResource + " Writer"); + role.getPermissions().add(SF.createFilterPermission(Access.WRITE, // + SF.createResourceFilter(protectedResource, PatternStyle.EXACT, true).setModelObjects(false))); + role.getPermissions().add(SF.createFilterPermission(Access.READ, // + SF.createResourceFilter(protectedResource, PatternStyle.EXACT, false).setModelObjects(true))); + + user.getRoles().add(role); + } + }); + + CDOSession session = openSession(credentials); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(protectedResource); + assertEquals(CDOPermission.WRITE, resource.cdoPermission()); + + Company company = getModel1Factory().createCompany(); + resource.getContents().add(company); + assertEquals(CDOPermission.WRITE, CDOUtil.getCDOObject(company).cdoPermission()); + + transaction.commit(); + assertEquals(CDOPermission.READ, CDOUtil.getCDOObject(company).cdoPermission()); + } + + public void testCommit_WritePermission() throws Exception + { + final IPasswordCredentials credentials = new PasswordCredentials("user", "password"); + final String protectedResource = getResourcePath("/protected"); + + getSecurityManager().modify(new ISecurityManager.RealmOperation() + { + public void execute(Realm realm) + { + User user = realm.addUser(credentials); + + Role role = realm.addRole(protectedResource + " Writer"); + role.getPermissions().add(SF.createFilterPermission(Access.WRITE, // + SF.createResourceFilter(protectedResource, PatternStyle.EXACT, true).setModelObjects(true))); + + user.getRoles().add(role); + } + }); + + CDOSession session = openSession(credentials); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(protectedResource); + assertEquals(CDOPermission.WRITE, resource.cdoPermission()); + + Company company = getModel1Factory().createCompany(); + resource.getContents().add(company); + assertEquals(CDOPermission.WRITE, CDOUtil.getCDOObject(company).cdoPermission()); + + transaction.commit(); + assertEquals(CDOPermission.WRITE, CDOUtil.getCDOObject(company).cdoPermission()); + } + + private ISecurityManager getSecurityManager() + { + InternalRepository repository = getRepository(); + return SecurityManagerUtil.getSecurityManager(repository); + } + + private boolean isWritable(EObject object) + { + return CDOUtil.getCDOObject(object).cdoRevision().isWritable(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java index fcdf638814..1fd7b3e669 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java @@ -55,6 +55,9 @@ import org.eclipse.net4j.util.WrappedException; import org.eclipse.net4j.util.container.IManagedContainer; import org.eclipse.net4j.util.io.IOUtil; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.security.IPasswordCredentials; +import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; +import org.eclipse.net4j.util.security.PasswordCredentialsProvider; import org.eclipse.net4j.util.tests.AbstractOMTest; import org.eclipse.emf.common.notify.Notification; @@ -366,6 +369,24 @@ public abstract class ConfigTest extends AbstractOMTest implements IConstants return sessionConfig.openSession(repositoryName); } + /** + * @category Session + */ + public CDOSession openSession(IPasswordCredentials credentials) + { + if (credentials != null) + { + IPasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(credentials); + getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER, credentialsProvider); + } + else + { + getTestProperties().remove(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER); + } + + return openSession(); + } + // ///////////////////////////////////////////////////////////////////////// // //////////////////////// Model ////////////////////////////////////////// diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java index da018b8963..5cbafbeb94 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.CDOCommonView; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; import org.eclipse.emf.cdo.internal.common.revision.NOOPRevisionCache; import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl; @@ -904,7 +905,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf volatile int counter = 1; @Override - public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) + public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, + Set<CDOID> readOnly) { long delay = getTestDelayed2CommitHandling(); if (delay != 0L && counter++ % 2 == 0) @@ -912,7 +914,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf AbstractOMTest.sleep(delay); } - super.handleCommitNotification(commitInfo, clearResourcePathCache); + super.handleCommitNotification(commitInfo, clearResourcePathCache, readOnly); } }; } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java index 23517efdfc..b635e5a3f1 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionManager.java @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.tests.util; import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.internal.server.SessionManager; import org.eclipse.emf.cdo.spi.server.InternalSession; @@ -54,7 +55,8 @@ public class TestSessionManager extends SessionManager } @Override - public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache) + public void sendCommitNotification(InternalSession sender, CDOCommitInfo commitInfo, boolean clearResourcePathCache, + CDORevisionProvider revisionProvider) { synchronized (lock) { @@ -66,6 +68,6 @@ public class TestSessionManager extends SessionManager } } - super.sendCommitNotification(sender, commitInfo, clearResourcePathCache); + super.sendCommitNotification(sender, commitInfo, clearResourcePathCache, revisionProvider); } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java index 373e071af3..41712dc907 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java @@ -47,6 +47,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; +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.common.util.RepositoryStateChangedEvent; @@ -895,12 +896,29 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme handleCommitNotification(commitInfo, true); } + @Deprecated public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache) { + handleCommitNotification(commitInfo, true, null); + } + + public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly) + { try { registerPackageUnits(commitInfo.getNewPackageUnits()); - invalidate(commitInfo, null, clearResourcePathCache); + + Map<CDOID, CDOPermission> permissions = null; + if (readOnly != null) + { + permissions = CDOIDUtil.createMap(); + for (CDOID id : readOnly) + { + permissions.put(id, CDOPermission.READ); + } + } + + invalidate(commitInfo, null, clearResourcePathCache, permissions); } catch (RuntimeException ex) { @@ -937,77 +955,6 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme } } - private Map<CDOID, InternalCDORevision> reviseRevisions(CDOCommitInfo commitInfo) - { - Map<CDOID, InternalCDORevision> oldRevisions = null; - CDOBranch newBranch = commitInfo.getBranch(); - long timeStamp = commitInfo.getTimeStamp(); - - // Cache new revisions - for (CDOIDAndVersion key : commitInfo.getNewObjects()) - { - if (key instanceof InternalCDORevision) - { - InternalCDORevision newRevision = (InternalCDORevision)key; - revisionManager.addRevision(newRevision); - } - } - - // Apply deltas and cache the resulting new revisions, if possible... - for (CDORevisionKey key : commitInfo.getChangedObjects()) - { - CDOID id = key.getID(); - if (key instanceof CDORevisionDelta) - { - CDORevisionDelta revisionDelta = (CDORevisionDelta)key; - - InternalCDORevision oldRevision = revisionManager.getRevisionByVersion(id, revisionDelta, - CDORevision.UNCHUNKED, false); - if (oldRevision != null) - { - addOldValuesToDelta(oldRevision, revisionDelta); - - InternalCDORevision newRevision = oldRevision.copy(); - newRevision.adjustForCommit(commitInfo.getBranch(), commitInfo.getTimeStamp()); - - CDORevisable target = revisionDelta.getTarget(); - if (target != null) - { - newRevision.setVersion(target.getVersion()); - } - - revisionDelta.apply(newRevision); - newRevision.freeze(); - - revisionManager.addRevision(newRevision); - if (oldRevisions == null) - { - oldRevisions = CDOIDUtil.createMap(); - } - - oldRevisions.put(id, oldRevision); - } - } - else - { - // ... otherwise try to revise old revision if it is in the same branch - if (key.getBranch() == newBranch) - { - revisionManager.reviseVersion(id, key, timeStamp); - } - } - } - - // Revise old revisions - for (CDOIDAndVersion key : commitInfo.getDetachedObjects()) - { - CDOID id = key.getID(); - revisionManager.reviseLatest(id, newBranch); - } - - return oldRevisions; - } - /** * Computes/adjusts CDOMoveFeatureDelta.value, CDORemoveFeatureDelta.value and CDOSetFeatureDelta.oldValue. * <p> @@ -1098,9 +1045,16 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme invalidate(commitInfo, sender, true); } + @Deprecated public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache) { - invalidator.reorderInvalidations(commitInfo, sender, clearResourcePathCache); + invalidate(commitInfo, sender, true, null); + } + + public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache, + Map<CDOID, CDOPermission> permissions) + { + invalidator.reorderInvalidations(commitInfo, sender, clearResourcePathCache, permissions); } public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) @@ -1726,14 +1680,14 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme } public synchronized void reorderInvalidations(CDOCommitInfo commitInfo, InternalCDOTransaction sender, - boolean clearResourcePathCache) + boolean clearResourcePathCache, Map<CDOID, CDOPermission> permissions) { if (!isActive()) { return; } - Invalidation invalidation = new Invalidation(commitInfo, sender, clearResourcePathCache); + Invalidation invalidation = new Invalidation(commitInfo, sender, clearResourcePathCache, permissions); reorderQueue.add(invalidation); Collections.sort(reorderQueue); @@ -1796,11 +1750,15 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme private final boolean clearResourcePathCache; - public Invalidation(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache) + private final Map<CDOID, CDOPermission> permissions; + + public Invalidation(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache, + Map<CDOID, CDOPermission> permissions) { this.commitInfo = commitInfo; this.sender = sender; this.clearResourcePathCache = clearResourcePathCache; + this.permissions = permissions; } public long getTimeStamp() @@ -1840,7 +1798,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme boolean success = commitInfo.getBranch() != null; if (success) { - oldRevisions = reviseRevisions(commitInfo); + oldRevisions = reviseRevisions(); } if (options.isPassiveUpdateEnabled()/* || sender != null */) @@ -1879,6 +1837,99 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme } } + private Map<CDOID, InternalCDORevision> reviseRevisions() + { + Map<CDOID, InternalCDORevision> oldRevisions = null; + CDOBranch newBranch = commitInfo.getBranch(); + long timeStamp = commitInfo.getTimeStamp(); + + // Cache new revisions + for (CDOIDAndVersion key : commitInfo.getNewObjects()) + { + if (key instanceof InternalCDORevision) + { + InternalCDORevision newRevision = (InternalCDORevision)key; + addNewRevision(newRevision); + } + } + + // Apply deltas and cache the resulting new revisions, if possible... + for (CDORevisionKey key : commitInfo.getChangedObjects()) + { + CDOID id = key.getID(); + if (key instanceof CDORevisionDelta) + { + CDORevisionDelta revisionDelta = (CDORevisionDelta)key; + + InternalCDORevision oldRevision = revisionManager.getRevisionByVersion(id, revisionDelta, + CDORevision.UNCHUNKED, false); + if (oldRevision != null) + { + addOldValuesToDelta(oldRevision, revisionDelta); + + InternalCDORevision newRevision = oldRevision.copy(); + newRevision.adjustForCommit(commitInfo.getBranch(), commitInfo.getTimeStamp()); + + CDORevisable target = revisionDelta.getTarget(); + if (target != null) + { + newRevision.setVersion(target.getVersion()); + } + + try + { + newRevision.bypassPermissionChecks(true); + revisionDelta.apply(newRevision); + } + finally + { + newRevision.bypassPermissionChecks(false); + newRevision.freeze(); + } + + addNewRevision(newRevision); + if (oldRevisions == null) + { + oldRevisions = CDOIDUtil.createMap(); + } + + oldRevisions.put(id, oldRevision); + } + } + else + { + // ... otherwise try to revise old revision if it is in the same branch + if (key.getBranch() == newBranch) + { + revisionManager.reviseVersion(id, key, timeStamp); + } + } + } + + // Revise old revisions + for (CDOIDAndVersion key : commitInfo.getDetachedObjects()) + { + CDOID id = key.getID(); + revisionManager.reviseLatest(id, newBranch); + } + + return oldRevisions; + } + + private void addNewRevision(InternalCDORevision newRevision) + { + if (permissions != null) + { + CDOPermission permission = permissions.get(newRevision.getID()); + if (permission != null) + { + newRevision.setPermission(permission); + } + } + + revisionManager.addRevision(newRevision); + } + private void invalidateView(CDOCommitInfo commitInfo, InternalCDOView view, InternalCDOTransaction sender, Map<CDOID, InternalCDORevision> oldRevisions, boolean clearResourcePathCache) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java index 360e004d7d..31651ba3a3 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java @@ -57,6 +57,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDOOriginSizeProvider; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.common.util.CDOException; import org.eclipse.emf.cdo.eresource.CDOBinaryResource; import org.eclipse.emf.cdo.eresource.CDOFileResource; @@ -2995,7 +2996,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa if (result.getRollbackMessage() != null) { CDOCommitInfo commitInfo = new FailureCommitInfo(timeStamp, result.getPreviousTimeStamp()); - session.invalidate(commitInfo, transaction, clearResourcePathCache); + session.invalidate(commitInfo, transaction, clearResourcePathCache, null); return; } @@ -3028,7 +3029,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa CDOCommitInfo commitInfo = makeCommitInfo(timeStamp, result.getPreviousTimeStamp()); if (!commitInfo.isEmpty()) { - session.invalidate(commitInfo, transaction, clearResourcePathCache); + Map<CDOID, CDOPermission> newPermissions = result.getNewPermissions(); + session.invalidate(commitInfo, transaction, clearResourcePathCache, newPermissions); } // Bug 290032 - Sticky views diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java index 7ea3d99090..9c39626f1b 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java @@ -32,6 +32,7 @@ import org.eclipse.emf.cdo.common.protocol.CDOProtocol; import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.common.util.CDOCommonUtil; import org.eclipse.emf.cdo.session.remote.CDORemoteSession; import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; @@ -685,6 +686,8 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo private CDOLockState[] newLockStates; + private Map<CDOID, CDOPermission> newPermissions; + private boolean clearResourcePathCache; /** @@ -838,6 +841,27 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo this.newLockStates = newLockStates; } + /** + * @since 4.3 + */ + public Map<CDOID, CDOPermission> getNewPermissions() + { + return newPermissions; + } + + /** + * @since 4.3 + */ + public void addNewPermission(CDOID id, CDOPermission permission) + { + if (newPermissions == null) + { + newPermissions = CDOIDUtil.createMap(); + } + + newPermissions.put(id, permission); + } + protected PostCommitReferenceAdjuster createReferenceAdjuster() { return new PostCommitReferenceAdjuster(idProvider, new CDOIDMapper(idMappings)); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java index 417abfe656..f9815bcc33 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java @@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.id.CDOIDGenerator; import org.eclipse.emf.cdo.common.lob.CDOLobStore; import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.security.CDOPermission; import org.eclipse.emf.cdo.session.CDORepositoryInfo; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; @@ -192,17 +193,24 @@ public interface InternalCDOSession extends CDOSession, PackageProcessor, Packag /** * @since 3.0 - * @deprecated As of 4.2 use {@link #handleCommitNotification(CDOCommitInfo, boolean)} + * @deprecated As of 4.2 use {@link #handleCommitNotification(CDOCommitInfo, boolean)}. */ @Deprecated public void handleCommitNotification(CDOCommitInfo commitInfo); /** * @since 4.2 + * @deprecated As of 4.3 use {@link #handleCommitNotification(CDOCommitInfo, boolean, Set)}. */ + @Deprecated public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache); /** + * @since 4.3 + */ + public void handleCommitNotification(CDOCommitInfo commitInfo, boolean clearResourcePathCache, Set<CDOID> readOnly); + + /** * @since 4.1 */ public void handleLockNotification(CDOLockChangeInfo lockChangeInfo, InternalCDOView sender); @@ -219,17 +227,25 @@ public interface InternalCDOSession extends CDOSession, PackageProcessor, Packag /** * @since 3.0 - * @deprecated As of 4.2 use {@link #invalidate(CDOCommitInfo, InternalCDOTransaction, boolean)} + * @deprecated As of 4.2 use {@link #invalidate(CDOCommitInfo, InternalCDOTransaction, boolean)}. */ @Deprecated public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender); /** * @since 4.2 + * @deprecated As of 4.3 use {@link #invalidate(CDOCommitInfo, InternalCDOTransaction, boolean, Map)}. */ + @Deprecated public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache); /** + * @since 4.3 + */ + public void invalidate(CDOCommitInfo commitInfo, InternalCDOTransaction sender, boolean clearResourcePathCache, + Map<CDOID, CDOPermission> permissions); + + /** * @since 3.0 */ public void processRefreshSessionResult(RefreshSessionResult result, CDOBranch branch, 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 1500b32cf4..0b22c222a4 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 @@ -125,9 +125,17 @@ public final class StringUtil public static String safe(String str) { + return safe(str, EMPTY); + } + + /** + * @since 3.4 + */ + public static String safe(String str, String def) + { if (str == null) { - return EMPTY; + return def; } return str; |