mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
change the list of capabilities into a set
This commit is contained in:
@@ -35,4 +35,8 @@ package org.alfresco.rest.rm.community.model.user;
|
|||||||
public class UserCapabilities
|
public class UserCapabilities
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** The id of the view records capability. */
|
||||||
|
public static final String VIEW_RECORDS_CAP = "ViewRecords";
|
||||||
|
/** The id of the declare records capability. */
|
||||||
|
public static final String DECLARE_RECORDS_CAP = "DeclareRecords";
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
package org.alfresco.rest.v0.service;
|
package org.alfresco.rest.v0.service;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||||
@@ -57,7 +56,7 @@ public class RoleService
|
|||||||
* @param role role to be updated
|
* @param role role to be updated
|
||||||
* @param capabilities list of capabilities to be added
|
* @param capabilities list of capabilities to be added
|
||||||
*/
|
*/
|
||||||
public void addCapabilitiesToRole(UserRoles role, List<String> capabilities)
|
public void addCapabilitiesToRole(UserRoles role, Set<String> capabilities)
|
||||||
{
|
{
|
||||||
Set<String> roleCapabilities = new HashSet<>();
|
Set<String> roleCapabilities = new HashSet<>();
|
||||||
roleCapabilities.addAll(rmRolesAndActionsAPI.getCapabilitiesForRole(dataUser.getAdminUser().getUsername(),
|
roleCapabilities.addAll(rmRolesAndActionsAPI.getCapabilitiesForRole(dataUser.getAdminUser().getUsername(),
|
||||||
@@ -74,7 +73,7 @@ public class RoleService
|
|||||||
* @param role role to be updated
|
* @param role role to be updated
|
||||||
* @param capabilities list of capabilities to be removed
|
* @param capabilities list of capabilities to be removed
|
||||||
*/
|
*/
|
||||||
public void removeCapabilitiesFromRole(UserRoles role, List<String> capabilities)
|
public void removeCapabilitiesFromRole(UserRoles role, Set<String> capabilities)
|
||||||
{
|
{
|
||||||
Set<String> roleCapabilities = rmRolesAndActionsAPI.getCapabilitiesForRole(dataUser.getAdminUser().getUsername(),
|
Set<String> roleCapabilities = rmRolesAndActionsAPI.getCapabilitiesForRole(dataUser.getAdminUser().getUsername(),
|
||||||
dataUser.getAdminUser().getPassword(), role.roleId);
|
dataUser.getAdminUser().getPassword(), role.roleId);
|
||||||
|
@@ -40,6 +40,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
|
import org.alfresco.rest.rm.community.model.user.UserCapabilities;
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
@@ -52,12 +53,8 @@ import org.testng.annotations.Test;
|
|||||||
*/
|
*/
|
||||||
public class RMRolesTests extends BaseRMRestTest
|
public class RMRolesTests extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
/** The id of the view records capability. */
|
|
||||||
public static final String VIEW_RECORDS_CAP = "ViewRecords";
|
|
||||||
/** The id of the declare records capability. */
|
|
||||||
public static final String DECLARE_RECORDS_CAP = "DeclareRecords";
|
|
||||||
/** A list of capabilities. */
|
/** A list of capabilities. */
|
||||||
private static final java.util.HashSet<String> CAPABILITIES = newHashSet(VIEW_RECORDS_CAP, DECLARE_RECORDS_CAP);
|
private static final java.util.HashSet<String> CAPABILITIES = newHashSet(UserCapabilities.VIEW_RECORDS_CAP, UserCapabilities.DECLARE_RECORDS_CAP);
|
||||||
/** The API for managing RM roles and capabilities. */
|
/** The API for managing RM roles and capabilities. */
|
||||||
@Autowired
|
@Autowired
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||||
@@ -102,14 +99,14 @@ public class RMRolesTests extends BaseRMRestTest
|
|||||||
{
|
{
|
||||||
String roleName = generateTestPrefix(RMRolesTests.class) + "Name";
|
String roleName = generateTestPrefix(RMRolesTests.class) + "Name";
|
||||||
rmRolesAndActionsAPI.createRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName, "Label",
|
rmRolesAndActionsAPI.createRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName, "Label",
|
||||||
singleton(VIEW_RECORDS_CAP));
|
singleton(UserCapabilities.VIEW_RECORDS_CAP));
|
||||||
|
|
||||||
// Call the endpoint under test.
|
// Call the endpoint under test.
|
||||||
rmRolesAndActionsAPI.updateRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName,
|
rmRolesAndActionsAPI.updateRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName,
|
||||||
"Updated Label", singleton(DECLARE_RECORDS_CAP));
|
"Updated Label", singleton(UserCapabilities.DECLARE_RECORDS_CAP));
|
||||||
|
|
||||||
Set<String> actualCapabilities = rmRolesAndActionsAPI
|
Set<String> actualCapabilities = rmRolesAndActionsAPI
|
||||||
.getCapabilitiesForRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName);
|
.getCapabilitiesForRole(getAdminUser().getUsername(), getAdminUser().getPassword(), roleName);
|
||||||
assertEquals("Unexpected capabilities for edited RM User.", actualCapabilities, singleton(DECLARE_RECORDS_CAP));
|
assertEquals("Unexpected capabilities for edited RM User.", actualCapabilities, singleton(UserCapabilities.DECLARE_RECORDS_CAP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user