mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-690 (A records admin is able to add a user or group to a role from the management console)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@50134 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,6 +30,9 @@
|
|||||||
}<#if group_has_next>,</#if>
|
}<#if group_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
||||||
|
<#if role.groupShortName??>
|
||||||
|
,"groupShortName": "${role.groupShortName}"
|
||||||
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
||||||
|
@@ -56,7 +56,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Role service implementation
|
* Role service implementation
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +65,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
/** Capability service */
|
/** Capability service */
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
|
|
||||||
/** Authority service */
|
/** Authority service */
|
||||||
private AuthorityService authorityService;
|
private AuthorityService authorityService;
|
||||||
|
|
||||||
@@ -74,13 +74,13 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
|
|
||||||
/** Policy component */
|
/** Policy component */
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
|
|
||||||
/** File plan service */
|
/** File plan service */
|
||||||
private FilePlanService filePlanService;
|
private FilePlanService filePlanService;
|
||||||
|
|
||||||
/** Node service */
|
/** Node service */
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
/** File plan authentication service */
|
/** File plan authentication service */
|
||||||
private FilePlanAuthenticationService filePlanAuthenticationService;
|
private FilePlanAuthenticationService filePlanAuthenticationService;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Log logger = LogFactory.getLog(FilePlanRoleServiceImpl.class);
|
private static Log logger = LogFactory.getLog(FilePlanRoleServiceImpl.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param capabilityService capability service
|
* @param capabilityService capability service
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +97,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.capabilityService = capabilityService;
|
this.capabilityService = capabilityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param authorityService authority service
|
* @param authorityService authority service
|
||||||
*/
|
*/
|
||||||
@@ -105,7 +105,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.authorityService = authorityService;
|
this.authorityService = authorityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param permissionService permission service
|
* @param permissionService permission service
|
||||||
*/
|
*/
|
||||||
@@ -113,7 +113,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param policyComponent policy component
|
* @param policyComponent policy component
|
||||||
*/
|
*/
|
||||||
@@ -121,7 +121,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.policyComponent = policyComponent;
|
this.policyComponent = policyComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeService node service
|
* @param nodeService node service
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +129,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePlanService file plan service
|
* @param filePlanService file plan service
|
||||||
*/
|
*/
|
||||||
@@ -137,7 +137,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.filePlanService = filePlanService;
|
this.filePlanService = filePlanService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePlanAuthenticationService file plan authentication service
|
* @param filePlanAuthenticationService file plan authentication service
|
||||||
*/
|
*/
|
||||||
@@ -145,7 +145,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
this.filePlanAuthenticationService = filePlanAuthenticationService;
|
this.filePlanAuthenticationService = filePlanAuthenticationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialisation method
|
* Initialisation method
|
||||||
*/
|
*/
|
||||||
@@ -160,7 +160,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
TYPE_FILE_PLAN,
|
TYPE_FILE_PLAN,
|
||||||
new JavaBehaviour(this, "onDeleteRootNode", NotificationFrequency.TRANSACTION_COMMIT));
|
new JavaBehaviour(this, "onDeleteRootNode", NotificationFrequency.TRANSACTION_COMMIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create root node behaviour
|
* Create root node behaviour
|
||||||
*
|
*
|
||||||
@@ -195,7 +195,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
// set the capabilities
|
// set the capabilities
|
||||||
// permissionService.setPermission(rmRootNode, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.VIEW_RECORDS, true);
|
// permissionService.setPermission(rmRootNode, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.VIEW_RECORDS, true);
|
||||||
// permissionService.setPermission(rmRootNode, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.EDIT_NON_RECORD_METADATA, true);
|
// permissionService.setPermission(rmRootNode, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.EDIT_NON_RECORD_METADATA, true);
|
||||||
|
|
||||||
// Create the unfiled record container
|
// Create the unfiled record container
|
||||||
return filePlanService.createUnfiledContainer(rmRootNode);
|
return filePlanService.createUnfiledContainer(rmRootNode);
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the roles by short name
|
* Get all the roles by short name
|
||||||
*
|
*
|
||||||
@@ -249,7 +249,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param rmRootNode
|
* @param rmRootNode
|
||||||
* @param unfiledContainer
|
* @param unfiledContainer
|
||||||
*/
|
*/
|
||||||
@@ -345,7 +345,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
// Add the creating user to the administration group
|
// Add the creating user to the administration group
|
||||||
String user = AuthenticationUtil.getFullyAuthenticatedUser();
|
String user = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
authorityService.addAuthority(role.getRoleGroupName(), user);
|
authorityService.addAuthority(role.getRoleGroupName(), user);
|
||||||
|
|
||||||
if (filePlanAuthenticationService.getRmAdminUserName().equals(user) == false)
|
if (filePlanAuthenticationService.getRmAdminUserName().equals(user) == false)
|
||||||
{
|
{
|
||||||
// add the dynamic admin authority
|
// add the dynamic admin authority
|
||||||
@@ -441,10 +441,12 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
Set<String> users = authorityService.getContainedAuthorities(AuthorityType.USER, roleAuthority, false);
|
Set<String> users = authorityService.getContainedAuthorities(AuthorityType.USER, roleAuthority, false);
|
||||||
if (users.contains(user) == true)
|
if (users.contains(user) == true)
|
||||||
{
|
{
|
||||||
String name = getShortRoleName(authorityService.getShortName(roleAuthority), rmRootNode);
|
String groupShortName = authorityService.getShortName(roleAuthority);
|
||||||
|
String name = getShortRoleName(groupShortName, rmRootNode);
|
||||||
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
|
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
|
||||||
|
Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority);
|
||||||
Role role = new Role(name, displayLabel, getCapabilitiesImpl(rmRootNode, roleAuthority), roleAuthority);
|
|
||||||
|
Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName);
|
||||||
result.add(role);
|
result.add(role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -612,22 +614,22 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
|
|
||||||
// TODO .. we should be creating a permission set containing all the capabilities and then assigning that
|
// TODO .. we should be creating a permission set containing all the capabilities and then assigning that
|
||||||
// single permission group to the file plan .. would be tidier
|
// single permission group to the file plan .. would be tidier
|
||||||
|
|
||||||
// Assign the various capabilities to the group on the root records management node
|
// Assign the various capabilities to the group on the root records management node
|
||||||
if (capabilities != null)
|
if (capabilities != null)
|
||||||
{
|
{
|
||||||
for (Capability capability : capabilities)
|
for (Capability capability : capabilities)
|
||||||
{
|
{
|
||||||
permissionService.setPermission(rmRootNode, roleGroup, capability.getName(), true);
|
permissionService.setPermission(rmRootNode, roleGroup, capability.getName(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Role(role, roleDisplayLabel, capabilities, roleGroup);
|
return new Role(role, roleDisplayLabel, capabilities, roleGroup);
|
||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set)
|
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#updateRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.Set)
|
||||||
@@ -642,7 +644,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to update role " + role + ", because it does not exist.");
|
throw new AlfrescoRuntimeException("Unable to update role " + role + ", because it does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode));
|
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode));
|
||||||
|
|
||||||
// Reset the role display name
|
// Reset the role display name
|
||||||
@@ -672,10 +674,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
// ensure that we are not trying to delete the admin role
|
// ensure that we are not trying to delete the admin role
|
||||||
if (ROLE_ADMIN.equals(role) == true)
|
if (ROLE_ADMIN.equals(role) == true)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Can not delete the records management administration role.");
|
throw new AlfrescoRuntimeException("Can not delete the records management administration role.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||||
{
|
{
|
||||||
public Boolean doWork() throws Exception
|
public Boolean doWork() throws Exception
|
||||||
@@ -687,7 +689,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getUsersAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getUsersAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@@ -696,13 +698,13 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("filePlan", filePlan);
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
ParameterCheck.mandatory("roleName", roleName);
|
ParameterCheck.mandatory("roleName", roleName);
|
||||||
|
|
||||||
return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.USER);
|
return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the authorities of a given type directly assigned to the given role in the file plan.
|
* Gets all the authorities of a given type directly assigned to the given role in the file plan.
|
||||||
*
|
*
|
||||||
* @param filePlan file plan
|
* @param filePlan file plan
|
||||||
* @param roleName role name
|
* @param roleName role name
|
||||||
* @param authorityType authority type
|
* @param authorityType authority type
|
||||||
@@ -714,17 +716,17 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
public Set<String> doWork() throws Exception
|
public Set<String> doWork() throws Exception
|
||||||
{
|
{
|
||||||
Role role = getRole(filePlan, roleName);
|
Role role = getRole(filePlan, roleName);
|
||||||
if (role == null)
|
if (role == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Can not get authorities for role " + roleName + ", because it does not exist. (filePlan=" + filePlan.toString() + ")");
|
throw new AlfrescoRuntimeException("Can not get authorities for role " + roleName + ", because it does not exist. (filePlan=" + filePlan.toString() + ")");
|
||||||
}
|
}
|
||||||
return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), false);
|
return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), false);
|
||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getGroupsAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getGroupsAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@@ -733,10 +735,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("filePlan", filePlan);
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
ParameterCheck.mandatory("roleName", roleName);
|
ParameterCheck.mandatory("roleName", roleName);
|
||||||
|
|
||||||
return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.GROUP);
|
return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getAllAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getAllAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@@ -745,7 +747,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("filePlan", filePlan);
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
ParameterCheck.mandatory("roleName", role);
|
ParameterCheck.mandatory("roleName", role);
|
||||||
|
|
||||||
Set<String> result = new HashSet<String>(21);
|
Set<String> result = new HashSet<String>(21);
|
||||||
result.addAll(getUsersAssignedToRole(filePlan, role));
|
result.addAll(getUsersAssignedToRole(filePlan, role));
|
||||||
result.addAll(getGroupsAssignedToRole(filePlan, role));
|
result.addAll(getGroupsAssignedToRole(filePlan, role));
|
||||||
@@ -771,7 +773,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
|||||||
}
|
}
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#unassignRoleFromAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String)
|
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#unassignRoleFromAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@@ -31,20 +31,24 @@ public class Role
|
|||||||
{
|
{
|
||||||
/** Role name */
|
/** Role name */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** Role label */
|
/** Role label */
|
||||||
private String displayLabel;
|
private String displayLabel;
|
||||||
|
|
||||||
/** Role capabilities */
|
/** Role capabilities */
|
||||||
private Set<Capability> capabilities;
|
private Set<Capability> capabilities;
|
||||||
|
|
||||||
/** Role group name */
|
/** Role group name */
|
||||||
private String roleGroupName;
|
private String roleGroupName;
|
||||||
|
|
||||||
|
/** Role group short name */
|
||||||
|
private String groupShortName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param displayLabel
|
* @param displayLabel
|
||||||
* @param capabilities
|
* @param capabilities
|
||||||
|
* @param roleGroupName
|
||||||
*/
|
*/
|
||||||
public Role(String name, String displayLabel, Set<Capability> capabilities, String roleGroupName)
|
public Role(String name, String displayLabel, Set<Capability> capabilities, String roleGroupName)
|
||||||
{
|
{
|
||||||
@@ -54,6 +58,19 @@ public class Role
|
|||||||
this.roleGroupName = roleGroupName;
|
this.roleGroupName = roleGroupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param displayLabel
|
||||||
|
* @param capabilities
|
||||||
|
* @param roleGroupName
|
||||||
|
* @param groupShortName
|
||||||
|
*/
|
||||||
|
public Role(String name, String displayLabel, Set<Capability> capabilities, String roleGroupName, String groupShortName)
|
||||||
|
{
|
||||||
|
this(name, displayLabel, capabilities, roleGroupName);
|
||||||
|
this.groupShortName = groupShortName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
@@ -85,4 +102,13 @@ public class Role
|
|||||||
{
|
{
|
||||||
return roleGroupName;
|
return roleGroupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the groupShortName
|
||||||
|
*/
|
||||||
|
public String getGroupShortName()
|
||||||
|
{
|
||||||
|
return this.groupShortName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base declarative web script for role API.
|
* Base declarative web script for role API.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@@ -43,13 +43,13 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
/** File plan service */
|
/** File plan service */
|
||||||
protected FilePlanService filePlanService;
|
protected FilePlanService filePlanService;
|
||||||
|
|
||||||
/** File plan role service */
|
/** File plan role service */
|
||||||
protected FilePlanRoleService filePlanRoleService;
|
protected FilePlanRoleService filePlanRoleService;
|
||||||
|
|
||||||
/** Authority service */
|
/** Authority service */
|
||||||
protected AuthorityService authorityService;
|
protected AuthorityService authorityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePlanService file plan service
|
* @param filePlanService file plan service
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +57,7 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.filePlanService = filePlanService;
|
this.filePlanService = filePlanService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePlanRoleService file plan role service
|
* @param filePlanRoleService file plan role service
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +65,7 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
this.filePlanRoleService = filePlanRoleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param authorityService authority service
|
* @param authorityService authority service
|
||||||
*/
|
*/
|
||||||
@@ -73,10 +73,10 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.authorityService = authorityService;
|
this.authorityService = authorityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to get the file plan from the passed parameters.
|
* Utility method to get the file plan from the passed parameters.
|
||||||
*
|
*
|
||||||
* @param req
|
* @param req
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -90,12 +90,12 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
filePlan = filePlanService.getFilePlanBySiteId(siteId);
|
filePlan = filePlanService.getFilePlanBySiteId(siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePlan == null)
|
if (filePlan == null)
|
||||||
{
|
{
|
||||||
String storeType = templateVars.get("store_type");
|
String storeType = templateVars.get("store_type");
|
||||||
String storeId = templateVars.get("store_id");
|
String storeId = templateVars.get("store_id");
|
||||||
String id = templateVars.get("id");
|
String id = templateVars.get("id");
|
||||||
|
|
||||||
if (StringUtils.isEmpty(storeType) == false &&
|
if (StringUtils.isEmpty(storeType) == false &&
|
||||||
StringUtils.isEmpty(storeId) == false &&
|
StringUtils.isEmpty(storeId) == false &&
|
||||||
@@ -107,9 +107,9 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
filePlan = nodeRef;
|
filePlan = nodeRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePlan == null)
|
if (filePlan == null)
|
||||||
{
|
{
|
||||||
// Assume we are in a legacy repository and we will grab the default file plan
|
// Assume we are in a legacy repository and we will grab the default file plan
|
||||||
@@ -118,10 +118,10 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
|
|
||||||
return filePlan;
|
return filePlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create role items
|
* Create role items
|
||||||
*
|
*
|
||||||
* @param filePlan
|
* @param filePlan
|
||||||
* @param roles
|
* @param roles
|
||||||
* @return
|
* @return
|
||||||
@@ -130,10 +130,10 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
return createRoleItems(filePlan, roles, false);
|
return createRoleItems(filePlan, roles, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create role items
|
* Create role items
|
||||||
*
|
*
|
||||||
* @param filePlan
|
* @param filePlan
|
||||||
* @param roles
|
* @param roles
|
||||||
* @param showAuths
|
* @param showAuths
|
||||||
@@ -147,7 +147,7 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
RoleItem item = null;
|
RoleItem item = null;
|
||||||
if (showAuths == true)
|
if (showAuths == true)
|
||||||
{
|
{
|
||||||
item = new RoleItem(role,
|
item = new RoleItem(role,
|
||||||
createAuthorityItems(filePlanRoleService.getUsersAssignedToRole(filePlan, role.getName())),
|
createAuthorityItems(filePlanRoleService.getUsersAssignedToRole(filePlan, role.getName())),
|
||||||
createAuthorityItems(filePlanRoleService.getGroupsAssignedToRole(filePlan, role.getName())));
|
createAuthorityItems(filePlanRoleService.getGroupsAssignedToRole(filePlan, role.getName())));
|
||||||
}
|
}
|
||||||
@@ -159,92 +159,99 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create authority items
|
* Create authority items
|
||||||
*
|
*
|
||||||
* @param authorities
|
* @param authorities
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Set<AuthorityItem> createAuthorityItems(Set<String> authorities)
|
private Set<AuthorityItem> createAuthorityItems(Set<String> authorities)
|
||||||
{
|
{
|
||||||
Set<AuthorityItem> result = new HashSet<AuthorityItem>(authorities.size());
|
Set<AuthorityItem> result = new HashSet<AuthorityItem>(authorities.size());
|
||||||
|
|
||||||
for (String authority : authorities)
|
for (String authority : authorities)
|
||||||
{
|
{
|
||||||
String displayLabel = authorityService.getAuthorityDisplayName(authority);
|
String displayLabel = authorityService.getAuthorityDisplayName(authority);
|
||||||
result.add(new AuthorityItem(authority, displayLabel));
|
result.add(new AuthorityItem(authority, displayLabel));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Role Item Helper Class
|
* Role Item Helper Class
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class RoleItem
|
public class RoleItem
|
||||||
{
|
{
|
||||||
private String name;
|
private String name;
|
||||||
|
private String groupShortName;
|
||||||
private String displayLabel;
|
private String displayLabel;
|
||||||
private Set<Capability> capabilities;
|
private Set<Capability> capabilities;
|
||||||
private boolean showAuths = false;
|
private boolean showAuths = false;
|
||||||
private Set<AuthorityItem> assignedUsers;
|
private Set<AuthorityItem> assignedUsers;
|
||||||
private Set<AuthorityItem> assignedGroups;
|
private Set<AuthorityItem> assignedGroups;
|
||||||
|
|
||||||
public RoleItem(Role role)
|
public RoleItem(Role role)
|
||||||
{
|
{
|
||||||
this.name = role.getName();
|
this.name = role.getName();
|
||||||
this.displayLabel = role.getDisplayLabel();
|
this.displayLabel = role.getDisplayLabel();
|
||||||
this.capabilities = role.getCapabilities();
|
this.capabilities = role.getCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleItem(Role role, Set<AuthorityItem> assignedUsers, Set<AuthorityItem> assignedGroups)
|
public RoleItem(Role role, Set<AuthorityItem> assignedUsers, Set<AuthorityItem> assignedGroups)
|
||||||
{
|
{
|
||||||
this.name = role.getName();
|
this.name = role.getName();
|
||||||
|
this.groupShortName = role.getGroupShortName();
|
||||||
this.displayLabel = role.getDisplayLabel();
|
this.displayLabel = role.getDisplayLabel();
|
||||||
this.capabilities = role.getCapabilities();
|
this.capabilities = role.getCapabilities();
|
||||||
this.showAuths = true;
|
this.showAuths = true;
|
||||||
this.assignedUsers = assignedUsers;
|
this.assignedUsers = assignedUsers;
|
||||||
this.assignedGroups = assignedGroups;
|
this.assignedGroups = assignedGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroupShortName()
|
||||||
|
{
|
||||||
|
return groupShortName;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayLabel()
|
public String getDisplayLabel()
|
||||||
{
|
{
|
||||||
return displayLabel;
|
return displayLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Capability> getCapabilities()
|
public Set<Capability> getCapabilities()
|
||||||
{
|
{
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowAuths()
|
public boolean getShowAuths()
|
||||||
{
|
{
|
||||||
return showAuths;
|
return showAuths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<AuthorityItem> getAssignedGroups()
|
public Set<AuthorityItem> getAssignedGroups()
|
||||||
{
|
{
|
||||||
return assignedGroups;
|
return assignedGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<AuthorityItem> getAssignedUsers()
|
public Set<AuthorityItem> getAssignedUsers()
|
||||||
{
|
{
|
||||||
return assignedUsers;
|
return assignedUsers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authority Item Helper Class
|
* Authority Item Helper Class
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@@ -252,21 +259,21 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
private String name;
|
private String name;
|
||||||
private String displayLabel;
|
private String displayLabel;
|
||||||
|
|
||||||
public AuthorityItem(String name, String displayLabel)
|
public AuthorityItem(String name, String displayLabel)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayLabel = displayLabel;
|
this.displayLabel = displayLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayLabel()
|
public String getDisplayLabel()
|
||||||
{
|
{
|
||||||
return displayLabel;
|
return displayLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user