From c8cf1df78c73f6b7d649663667a19d3bce75122b Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 8 Jul 2013 10:22:53 +0000 Subject: [PATCH] RM-764 (In-Place roles should not appear when managing users and groups) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@52221 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../role/FilePlanRoleService.java | 18 +++++++++++++----- .../role/FilePlanRoleServiceImpl.java | 19 ++----------------- .../service/FilePlanRoleServiceImplTest.java | 7 +++++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java index c0b54f35dc..cdf37efd07 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleService.java @@ -18,6 +18,8 @@ */ package org.alfresco.module.org_alfresco_module_rm.role; +import java.util.Arrays; +import java.util.List; import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.capability.Capability; @@ -40,6 +42,12 @@ public interface FilePlanRoleService public static final String ROLE_EXTENDED_READERS = "ExtendedReaders"; public static final String ROLE_EXTENDED_WRITERS = "ExtendedWriters"; + /** System roles */ + public static final List SYSTEM_ROLES = Arrays.asList( + ROLE_EXTENDED_READERS, + ROLE_EXTENDED_WRITERS + ); + /** * Returns the name of the container group for all roles of a specified file * plan. @@ -51,7 +59,7 @@ public interface FilePlanRoleService /** * Get all the available roles for the given records management root node - * includes also the system roles + * (includes also the system roles) * * @param filePlan file plan * @return @@ -59,7 +67,7 @@ public interface FilePlanRoleService Set getRoles(NodeRef filePlan); /** - * Get all the available roles for the given records management root node + * Get all the available roles for the given records management root node. * System roles can be filtered * * @param filePlan file plan @@ -70,8 +78,8 @@ public interface FilePlanRoleService /** * Gets the roles for a given user - * includes also the system roles - * + * (includes also the system roles) + * * @param filePlan file plan * @param user user * @return @@ -79,7 +87,7 @@ public interface FilePlanRoleService Set getRolesByUser(NodeRef filePlan, String user); /** - * Gets the roles for a given user + * Gets the roles for a given user. * System roles can be filtered * * @param filePlan file plan diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java index d3410a0ff1..a6d3bc9086 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/role/FilePlanRoleServiceImpl.java @@ -24,7 +24,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; @@ -37,9 +36,9 @@ import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamic import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authority.RMAuthority; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -402,19 +401,6 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService, return sb.toString(); } - /** - * Helper method for retrieving the system roles - * - * @return Returns the system roles - */ - private List getSystemRoles() - { - return Arrays.asList( - FilePlanRoleService.ROLE_EXTENDED_READERS, - FilePlanRoleService.ROLE_EXTENDED_WRITERS - ); - } - /** * Helper method to check whether the current authority is a system role or not * @@ -424,9 +410,8 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService, private boolean isSystemRole(String roleAuthority) { boolean isSystemRole = false; - List systemRoles = getSystemRoles(); - for (String systemRole : systemRoles) + for (String systemRole : SYSTEM_ROLES) { if (StringUtils.contains(roleAuthority, systemRole)) { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanRoleServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanRoleServiceImplTest.java index b809c30889..1d6d8ee106 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanRoleServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanRoleServiceImplTest.java @@ -23,6 +23,7 @@ import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; @@ -69,6 +70,12 @@ public class FilePlanRoleServiceImplTest extends BaseRMTestCase assertTrue(roles.size() != 0); assertTrue(roles.size() == rolesIncludingSystemRoles.size()); + Set rolesWithoutSystemRoles = filePlanRoleService.getRoles(filePlan, false); + assertNotNull(rolesWithoutSystemRoles); + assertTrue(rolesWithoutSystemRoles.size() != 0); + assertTrue(rolesIncludingSystemRoles.size() > rolesWithoutSystemRoles.size()); + assertTrue(rolesIncludingSystemRoles.size() == rolesWithoutSystemRoles.size() + FilePlanRoleService.SYSTEM_ROLES.size()); + return null; } });