mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-634: A records admin can access the users and groups within a RM role (or all the roles) via a web script API.
* add additional user/group management methods to FilePlanRoleService java API * add file plan retrieval methods to FilePlanService .. including retrieving file plan node reference from RM site id * deprecate file plan retrieval methods on RecordsManagementService * add FilePlanService unit tests * refactor role web service API implementations to allow the file plan (or rm site) to be specified * GET roles can optionally include information about the assigned users and groups git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@48438 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -50,7 +50,6 @@
|
|||||||
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
|
||||||
<property name="nodeService" ref="nodeService"/>
|
<property name="nodeService" ref="nodeService"/>
|
||||||
<property name="policyComponent" ref="policyComponent"/>
|
<property name="policyComponent" ref="policyComponent"/>
|
||||||
<property name="nodeDAO" ref="nodeDAO"/>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="RecordsManagementService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="RecordsManagementService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
@@ -440,7 +439,10 @@
|
|||||||
<bean id="filePlanService"
|
<bean id="filePlanService"
|
||||||
parent="baseService"
|
parent="baseService"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
||||||
<property name="permissionService" ref="PermissionService"/>
|
<property name="permissionService" ref="PermissionService"/>
|
||||||
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
|
<property name="internalNodeService" ref="nodeService"/>
|
||||||
|
<property name="siteService" ref="SiteService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
@@ -466,10 +468,13 @@
|
|||||||
<value>
|
<value>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.isFilePlan=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.isFilePlan=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.getFilePlans=RM_ALLOW,AFTER_RM.FilterNode
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.getFilePlan=RM_ALLOW,AFTER_RM.FilterNode
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.getFilePlanBySiteId=RM_ALLOW,AFTER_RM.FilterNode
|
||||||
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.existsUnfiledContainer=RM.Read.0
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.existsUnfiledContainer=RM.Read.0
|
||||||
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.getUnfiledContainer=RM.Read.0
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.getUnfiledContainer=RM.Read.0,AFTER_RM.FilterNode
|
||||||
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.createUnfiledContainer=RM.Write.0
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.createUnfiledContainer=RM.Write.0
|
||||||
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.*=RM_DENY
|
org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService.*=RM_DENY
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
@@ -597,7 +602,11 @@
|
|||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.createRole=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.createRole=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.updateRole=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.updateRole=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.deleteRole=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.deleteRole=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getUsersAssignedToRole=RM.Read.0
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getGroupsAssignedToRole=RM.Read.0
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getAllAssignedToRole=RM.Read.0
|
||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.assignRoleToAuthority=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.assignRoleToAuthority=RM_ALLOW
|
||||||
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.unassignRoleFromAuthority=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getAllRolesContainerGroup=RM_ALLOW
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.getAllRolesContainerGroup=RM_ALLOW
|
||||||
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.*=RM_DENY
|
org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.*=RM_DENY
|
||||||
]]>
|
]]>
|
||||||
|
@@ -268,38 +268,43 @@
|
|||||||
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmroles.get"
|
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmroles.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolesGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolesGet"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmroles.post"
|
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmroles.post"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolesPost"
|
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolesPost"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
||||||
<property name="capabilityService" ref="CapabilityService" />
|
<property name="capabilityService" ref="CapabilityService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.get"
|
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.get"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRoleGet"
|
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRoleGet"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.put"
|
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.put"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolePut"
|
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRolePut"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
||||||
<property name="capabilityService" ref="CapabilityService" />
|
<property name="capabilityService" ref="CapabilityService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.delete"
|
<bean id="webscript.org.alfresco.rma.admin.rmrole.rmrole.delete"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRoleDelete"
|
class="org.alfresco.module.org_alfresco_module_rm.script.admin.RmRoleDelete"
|
||||||
parent="webscript">
|
parent="webscript">
|
||||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
|
||||||
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
<property name="filePlanRoleService" ref="FilePlanRoleService" />
|
||||||
|
<property name="filePlanService" ref="FilePlanService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Capability API -->
|
<!-- Capability API -->
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/admin/rmroles/{rolename}</url>
|
<url>/api/rma/admin/rmroles/{rolename}</url> <!-- Deprecated URL -->
|
||||||
|
<url>/api/rma/admin/{siteid}/rmroles/{rolename}</url>
|
||||||
|
<url>/api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/admin/rmroles/{rolename}</url>
|
<url>/api/rma/admin/rmroles/{rolename}</url> <!-- Deprecated URL -->
|
||||||
|
<url>/api/rma/admin/{siteid}/rmroles/{rolename}</url>
|
||||||
|
<url>/api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
|
@@ -10,6 +10,27 @@
|
|||||||
"${capability.name}": "${capability.title}" <#if capability_has_next>,</#if>
|
"${capability.name}": "${capability.title}" <#if capability_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
}
|
}
|
||||||
|
<#if role.showAuths>
|
||||||
|
,
|
||||||
|
"assignedUsers" :
|
||||||
|
[
|
||||||
|
<#list role.assignedUsers as user>
|
||||||
|
{
|
||||||
|
"name" : "${user.name}",
|
||||||
|
"displayLabel" : "${user.displayLabel}"
|
||||||
|
}<#if user_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
],
|
||||||
|
"assignedGroups" :
|
||||||
|
[
|
||||||
|
<#list role.assignedGroups as group>
|
||||||
|
{
|
||||||
|
"name" : "${group.name}",
|
||||||
|
"displayLabel" : "${group.displayLabel}"
|
||||||
|
}<#if group_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
]
|
||||||
|
</#if>
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
||||||
</#macro>
|
</#macro>
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/admin/rmroles/{rolename}</url>
|
<url>/api/rma/admin/rmroles/{rolename}</url> <!-- Deprecated URL -->
|
||||||
|
<url>/api/rma/admin/{siteid}/rmroles/{rolename}</url>
|
||||||
|
<url>/api/rma/admin/{store_type}/{store_id}/{id}/rmroles/{rolename}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -1,12 +1,19 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>Get list of records management roles</shortname>
|
<shortname>Get list of records management roles and their details, for a file plan.</shortname>
|
||||||
<description>
|
<description>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
The file plan should be specified in the URL parmeters. If not the default file plan will be used.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
store_type, store_id, id - file plan node reference
|
||||||
|
siteid - id of a RM site to take the file plan from
|
||||||
|
user - only returns roles that this user is assigned to
|
||||||
|
auths - if true, returns details of authorites directly assigned to the role. false by default.
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/admin/rmroles?user={user?}</url>
|
<url>/api/rma/admin/rmroles?user={user?}&auths={auths?}</url> <!-- NOTE: this URL should be considered as deprecated -->
|
||||||
|
<url>/api/rma/admin/{store_type}/{store_id}/{id}/rmroles?user={user?}&auths={auths?}</url>
|
||||||
|
<url>/api/rma/admin/{siteid}/rmroles?user={user?}&auths={auths?}</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction allow="readonly">required</transaction>
|
<transaction allow="readonly">required</transaction>
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<url>/api/rma/admin/rmroles</url>
|
<url>/api/rma/admin/rmroles</url> <!-- Deprecated URL -->
|
||||||
|
<url>/api/rma/admin/{siteid}/rmroles</url>
|
||||||
|
<url>/api/rma/admin/{store_type}/{store_id}/{id}/rmroles</url>
|
||||||
<format default="json">argument</format>
|
<format default="json">argument</format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -154,8 +154,11 @@ public interface RecordsManagementService
|
|||||||
/**
|
/**
|
||||||
* Gets the file plan the node is in.
|
* Gets the file plan the node is in.
|
||||||
*
|
*
|
||||||
* @return {@link NodeRef} file node reference, null if none
|
* @return {@link NodeRef} file node reference, null if none
|
||||||
|
*
|
||||||
|
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
NodeRef getFilePlan(NodeRef nodeRef);
|
NodeRef getFilePlan(NodeRef nodeRef);
|
||||||
|
|
||||||
/********** File Plan Methods **********/
|
/********** File Plan Methods **********/
|
||||||
@@ -165,11 +168,11 @@ public interface RecordsManagementService
|
|||||||
* Searches the SpacesStore by default.
|
* Searches the SpacesStore by default.
|
||||||
*
|
*
|
||||||
* @return List<NodeRef> list of file plan nodes
|
* @return List<NodeRef> list of file plan nodes
|
||||||
|
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
List<NodeRef> getFilePlans();
|
List<NodeRef> getFilePlans();
|
||||||
|
|
||||||
// TODO NodeRef getFilePlanById(String id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a file plan as a child of the given parent node, with the name
|
* Creates a file plan as a child of the given parent node, with the name
|
||||||
* provided.
|
* provided.
|
||||||
|
@@ -35,7 +35,6 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomM
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||||
@@ -47,8 +46,10 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +61,8 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
implements RecordsManagementService,
|
implements RecordsManagementService,
|
||||||
RecordsManagementModel,
|
RecordsManagementModel,
|
||||||
RecordsManagementPolicies.OnCreateReference,
|
RecordsManagementPolicies.OnCreateReference,
|
||||||
RecordsManagementPolicies.OnRemoveReference
|
RecordsManagementPolicies.OnRemoveReference,
|
||||||
|
ApplicationContextAware
|
||||||
{
|
{
|
||||||
/** I18N */
|
/** I18N */
|
||||||
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
||||||
@@ -86,9 +88,6 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
/** Service registry */
|
/** Service registry */
|
||||||
private RecordsManagementServiceRegistry serviceRegistry;
|
private RecordsManagementServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
/** Node DAO */
|
|
||||||
private NodeDAO nodeDAO;
|
|
||||||
|
|
||||||
/** Policy component */
|
/** Policy component */
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
@@ -99,6 +98,18 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
/** Java behaviour */
|
/** Java behaviour */
|
||||||
private JavaBehaviour onChangeToDispositionActionDefinition;
|
private JavaBehaviour onChangeToDispositionActionDefinition;
|
||||||
|
|
||||||
|
/** Application context */
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||||
|
{
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the service registry service
|
* Set the service registry service
|
||||||
*
|
*
|
||||||
@@ -120,16 +131,6 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
this.policyComponent = policyComponent;
|
this.policyComponent = policyComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the node DAO object
|
|
||||||
*
|
|
||||||
* @param nodeDAO node DAO
|
|
||||||
*/
|
|
||||||
public void setNodeDAO(NodeDAO nodeDAO)
|
|
||||||
{
|
|
||||||
this.nodeDAO = nodeDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default RM store reference
|
* Sets the default RM store reference
|
||||||
@@ -571,32 +572,13 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public NodeRef getFilePlan(NodeRef nodeRef)
|
public NodeRef getFilePlan(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
NodeRef result = null;
|
FilePlanService filePlanService = (FilePlanService)applicationContext.getBean("filePlanService");
|
||||||
|
return filePlanService.getFilePlan(nodeRef);
|
||||||
if (nodeRef != null)
|
|
||||||
{
|
|
||||||
result = (NodeRef)nodeService.getProperty(nodeRef, PROP_ROOT_NODEREF);
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
if (instanceOf(nodeRef, TYPE_FILE_PLAN) == true)
|
|
||||||
{
|
|
||||||
result = nodeRef;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
|
|
||||||
if (parentAssocRef != null)
|
|
||||||
{
|
|
||||||
result = getFilePlan(parentAssocRef.getParentRef());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -648,27 +630,13 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordsManagementRoots(org.alfresco.service.cmr.repository.StoreRef)
|
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordsManagementRoots(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*
|
||||||
|
* @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<NodeRef> getFilePlans()
|
public List<NodeRef> getFilePlans()
|
||||||
{
|
{
|
||||||
final List<NodeRef> results = new ArrayList<NodeRef>();
|
return new ArrayList<NodeRef>(serviceRegistry.getFilePlanService().getFilePlans());
|
||||||
Set<QName> aspects = new HashSet<QName>(1);
|
|
||||||
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
|
||||||
nodeDAO.getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean handle(Pair<Long, NodeRef> nodePair)
|
|
||||||
{
|
|
||||||
NodeRef nodeRef = nodePair.getSecond();
|
|
||||||
if (StoreRef.STORE_REF_ARCHIVE_SPACESSTORE.equals(nodeRef.getStoreRef()) == false)
|
|
||||||
{
|
|
||||||
results.add(nodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -29,28 +29,15 @@ import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
|
|||||||
public interface RMPermissionModel
|
public interface RMPermissionModel
|
||||||
{
|
{
|
||||||
// Assignment of Filing
|
// Assignment of Filing
|
||||||
|
|
||||||
public static final String FILING = "Filing";
|
public static final String FILING = "Filing";
|
||||||
|
|
||||||
public static final String READ_RECORDS = "ReadRecords";
|
public static final String READ_RECORDS = "ReadRecords";
|
||||||
|
|
||||||
public static final String FILE_RECORDS = "FileRecords";
|
public static final String FILE_RECORDS = "FileRecords";
|
||||||
|
|
||||||
// Roles
|
// Roles
|
||||||
|
|
||||||
public static final String ROLE_NAME_USER = "User";
|
public static final String ROLE_NAME_USER = "User";
|
||||||
//public static final String ROLE_USER = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_USER).toString();
|
|
||||||
|
|
||||||
public static final String ROLE_NAME_POWER_USER = "PowerUser";
|
public static final String ROLE_NAME_POWER_USER = "PowerUser";
|
||||||
// public static final String ROLE_POWER_USER = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_POWER_USER).toString();
|
|
||||||
|
|
||||||
public static final String ROLE_NAME_SECURITY_OFFICER = "SecurityOfficer";
|
public static final String ROLE_NAME_SECURITY_OFFICER = "SecurityOfficer";
|
||||||
// public static final String ROLE_SECURITY_OFFICER = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_SECURITY_OFFICER)
|
|
||||||
// .toString();
|
|
||||||
|
|
||||||
public static final String ROLE_NAME_RECORDS_MANAGER = "RecordsManager";
|
public static final String ROLE_NAME_RECORDS_MANAGER = "RecordsManager";
|
||||||
// public static final String ROLE_RECORDS_MANAGER = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_RECORDS_MANAGER)
|
|
||||||
// .toString();
|
|
||||||
|
|
||||||
public static final String ROLE_NAME_ADMINISTRATOR = "Administrator";
|
public static final String ROLE_NAME_ADMINISTRATOR = "Administrator";
|
||||||
public static final String ROLE_ADMINISTRATOR = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_ADMINISTRATOR).toString();
|
public static final String ROLE_ADMINISTRATOR = SimplePermissionReference.getPermissionReference(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT, ROLE_NAME_ADMINISTRATOR).toString();
|
||||||
|
@@ -18,7 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.fileplan;
|
package org.alfresco.module.org_alfresco_module_rm.fileplan;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
|
||||||
import com.hazelcast.impl.Node;
|
import com.hazelcast.impl.Node;
|
||||||
|
|
||||||
@@ -38,6 +41,38 @@ public interface FilePlanService
|
|||||||
*/
|
*/
|
||||||
boolean isFilePlan(NodeRef nodeRef);
|
boolean isFilePlan(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the file plan nodes.
|
||||||
|
* Looks in the SpacesStore by default.
|
||||||
|
*
|
||||||
|
* @return Set<NodeRef> set of file plan nodes
|
||||||
|
*/
|
||||||
|
Set<NodeRef> getFilePlans();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getse all the file plan nodes in a store.
|
||||||
|
*
|
||||||
|
* @param storeRef store reference
|
||||||
|
* @return Set<NodeRef> set of file plan nodes
|
||||||
|
*/
|
||||||
|
Set<NodeRef> getFilePlans(StoreRef storeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file plan the node is in.
|
||||||
|
*
|
||||||
|
* @return {@link NodeRef} file node reference, null if none
|
||||||
|
*/
|
||||||
|
NodeRef getFilePlan(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a file plan by site id. Assumes the site is a RM site and that the file plan node, ie
|
||||||
|
* the document library container, has been already created. Otherwise returns null.
|
||||||
|
*
|
||||||
|
* @param siteId records management site id
|
||||||
|
* @return NodeRef file plan, null if can't be found
|
||||||
|
*/
|
||||||
|
NodeRef getFilePlanBySiteId(String siteId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the unfiled container exists for a given file plan or not.
|
* Indicates whether the unfiled container exists for a given file plan or not.
|
||||||
*
|
*
|
||||||
|
@@ -20,8 +20,10 @@ package org.alfresco.module.org_alfresco_module_rm.fileplan;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
@@ -31,10 +33,16 @@ import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||||
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -55,12 +63,27 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
private static final String NAME_UNFILED_CONTAINER = "Unfiled Records";
|
private static final String NAME_UNFILED_CONTAINER = "Unfiled Records";
|
||||||
private static final QName QNAME_UNFILED_CONTAINER = QName.createQName(RM_URI, NAME_UNFILED_CONTAINER);
|
private static final QName QNAME_UNFILED_CONTAINER = QName.createQName(RM_URI, NAME_UNFILED_CONTAINER);
|
||||||
|
|
||||||
|
/** RM site file plan container */
|
||||||
|
private static final String FILE_PLAN_CONTAINER = "documentLibrary";
|
||||||
|
|
||||||
/** Services */
|
/** Services */
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
|
|
||||||
/** Application context */
|
/** Application context */
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
/** Node DAO */
|
||||||
|
private NodeDAO nodeDAO;
|
||||||
|
|
||||||
|
/** Internal node service */
|
||||||
|
private NodeService internalNodeService;
|
||||||
|
|
||||||
|
/** Site service */
|
||||||
|
private SiteService siteService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||||
{
|
{
|
||||||
@@ -86,6 +109,30 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nodeDAO node DAO
|
||||||
|
*/
|
||||||
|
public void setNodeDAO(NodeDAO nodeDAO)
|
||||||
|
{
|
||||||
|
this.nodeDAO = nodeDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param internalNodeService node service (internal bean)
|
||||||
|
*/
|
||||||
|
public void setInternalNodeService(NodeService internalNodeService)
|
||||||
|
{
|
||||||
|
this.internalNodeService = internalNodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param siteService site service
|
||||||
|
*/
|
||||||
|
public void setSiteService(SiteService siteService)
|
||||||
|
{
|
||||||
|
this.siteService = siteService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +141,97 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
return instanceOf(nodeRef, TYPE_FILE_PLAN);
|
return instanceOf(nodeRef, TYPE_FILE_PLAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<NodeRef> getFilePlans()
|
||||||
|
{
|
||||||
|
return getFilePlans(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<NodeRef> getFilePlans(final StoreRef storeRef)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("storeRef", storeRef);
|
||||||
|
|
||||||
|
final Set<NodeRef> results = new HashSet<NodeRef>();
|
||||||
|
Set<QName> aspects = new HashSet<QName>(1);
|
||||||
|
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
||||||
|
nodeDAO.getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean handle(Pair<Long, NodeRef> nodePair)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = nodePair.getSecond();
|
||||||
|
if (storeRef.equals(nodeRef.getStoreRef()) == true)
|
||||||
|
{
|
||||||
|
results.add(nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public NodeRef getFilePlan(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
NodeRef result = null;
|
||||||
|
if (nodeRef != null)
|
||||||
|
{
|
||||||
|
result = (NodeRef)internalNodeService.getProperty(nodeRef, PROP_ROOT_NODEREF);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
if (instanceOf(nodeRef, TYPE_FILE_PLAN) == true)
|
||||||
|
{
|
||||||
|
result = nodeRef;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChildAssociationRef parentAssocRef = internalNodeService.getPrimaryParent(nodeRef);
|
||||||
|
if (parentAssocRef != null)
|
||||||
|
{
|
||||||
|
result = getFilePlan(parentAssocRef.getParentRef());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanBySiteId(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public NodeRef getFilePlanBySiteId(String siteId)
|
||||||
|
{
|
||||||
|
NodeRef filePlan = null;
|
||||||
|
|
||||||
|
SiteInfo siteInfo = siteService.getSite(siteId);
|
||||||
|
if (siteInfo != null)
|
||||||
|
{
|
||||||
|
if (siteService.hasContainer(siteId, FILE_PLAN_CONTAINER) == true)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = siteService.getContainer(siteId, FILE_PLAN_CONTAINER);
|
||||||
|
if (instanceOf(nodeRef, TYPE_FILE_PLAN) == true)
|
||||||
|
{
|
||||||
|
filePlan = nodeRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filePlan;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#existsUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#existsUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
|
@@ -120,6 +120,33 @@ public interface FilePlanRoleService
|
|||||||
*/
|
*/
|
||||||
void deleteRole(NodeRef filePlan, String role);
|
void deleteRole(NodeRef filePlan, String role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the users that have been directly assigned to a role.
|
||||||
|
*
|
||||||
|
* @param filePlan file plan
|
||||||
|
* @param role role
|
||||||
|
* @return {@link Set}<{@link String}> set of users
|
||||||
|
*/
|
||||||
|
Set<String> getUsersAssignedToRole(NodeRef filePlan, String role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the groups that have been directly assigned to a role.
|
||||||
|
*
|
||||||
|
* @param filePlan file plan
|
||||||
|
* @param role role
|
||||||
|
* @return {@link Set}<{@link String}> set of groups
|
||||||
|
*/
|
||||||
|
Set<String> getGroupsAssignedToRole(NodeRef filePlan, String role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the groups and users that have been directly assigned to a role.
|
||||||
|
*
|
||||||
|
* @param filePlan file plan
|
||||||
|
* @param role role
|
||||||
|
* @return {@link Set}<{@link String}> set of groups and users
|
||||||
|
*/
|
||||||
|
Set<String> getAllAssignedToRole(NodeRef filePlan, String role);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a role to an authority
|
* Assign a role to an authority
|
||||||
*
|
*
|
||||||
@@ -128,4 +155,14 @@ public interface FilePlanRoleService
|
|||||||
* @param authorityName authority name
|
* @param authorityName authority name
|
||||||
*/
|
*/
|
||||||
void assignRoleToAuthority(NodeRef filePlan, String role, String authorityName);
|
void assignRoleToAuthority(NodeRef filePlan, String role, String authorityName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign a role from an authority
|
||||||
|
*
|
||||||
|
* @param filePlan file plan
|
||||||
|
* @param role role
|
||||||
|
* @param authorityName authority name
|
||||||
|
*/
|
||||||
|
void unassignRoleFromAuthority(NodeRef filePlan, String role, String authorityName);
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ import org.alfresco.service.cmr.security.AccessPermission;
|
|||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@@ -686,23 +687,105 @@ 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)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<String> getUsersAssignedToRole(final NodeRef filePlan, final String roleName)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
|
ParameterCheck.mandatory("roleName", roleName);
|
||||||
|
|
||||||
|
return getAuthoritiesAssignedToRole(filePlan, roleName, AuthorityType.USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the authorities of a given type directly assigned to the given role in the file plan.
|
||||||
|
*
|
||||||
|
* @param filePlan file plan
|
||||||
|
* @param roleName role name
|
||||||
|
* @param authorityType authority type
|
||||||
|
* @return Set<String> directly assigned authorities
|
||||||
|
*/
|
||||||
|
private Set<String> getAuthoritiesAssignedToRole(final NodeRef filePlan, final String roleName, final AuthorityType authorityType)
|
||||||
|
{
|
||||||
|
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Set<String>>()
|
||||||
|
{
|
||||||
|
public Set<String> doWork() throws Exception
|
||||||
|
{
|
||||||
|
Role role = getRole(filePlan, roleName);
|
||||||
|
if (role == null)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService#getGroupsAssignedToRole(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<String> getGroupsAssignedToRole(final NodeRef filePlan, final String roleName)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
|
ParameterCheck.mandatory("roleName", roleName);
|
||||||
|
|
||||||
|
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)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<String> getAllAssignedToRole(NodeRef filePlan, String role)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("filePlan", filePlan);
|
||||||
|
ParameterCheck.mandatory("roleName", role);
|
||||||
|
|
||||||
|
Set<String> result = new HashSet<String>(21);
|
||||||
|
result.addAll(getUsersAssignedToRole(filePlan, role));
|
||||||
|
result.addAll(getGroupsAssignedToRole(filePlan, role));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String)
|
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void assignRoleToAuthority(final NodeRef rmRootNode, final String role, final String authorityName)
|
public void assignRoleToAuthority(final NodeRef filePlan, final String role, final String authorityName)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
public Boolean doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, rmRootNode));
|
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan));
|
||||||
authorityService.addAuthority(roleAuthority, authorityName);
|
authorityService.addAuthority(roleAuthority, authorityName);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}, 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)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void unassignRoleFromAuthority(final NodeRef filePlan, final String role, final String authorityName)
|
||||||
|
{
|
||||||
|
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
String roleAuthority = authorityService.getName(AuthorityType.GROUP, getFullRoleName(role, filePlan));
|
||||||
|
authorityService.removeAuthority(roleAuthority, authorityName);
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getAllRolesContainerGroup(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
|
@@ -19,43 +19,30 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Delete role web script
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmRoleDelete extends DeclarativeWebScript
|
public class RmRoleDelete extends RoleDeclarativeWebScript
|
||||||
{
|
{
|
||||||
|
/** Logger */
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Log logger = LogFactory.getLog(RmRoleDelete.class);
|
private static Log logger = LogFactory.getLog(RmRoleDelete.class);
|
||||||
|
|
||||||
private RecordsManagementService rmService;
|
|
||||||
private FilePlanRoleService filePlanRoleService;
|
|
||||||
|
|
||||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
|
||||||
{
|
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
|
||||||
{
|
|
||||||
this.rmService = rmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
@@ -69,16 +56,21 @@ public class RmRoleDelete extends DeclarativeWebScript
|
|||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL.");
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
// get the file plan
|
||||||
NodeRef root = roots.get(0);
|
NodeRef filePlan = getFilePlan(req);
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the role exists
|
// Check that the role exists
|
||||||
if (filePlanRoleService.existsRole(root, roleParam) == false)
|
if (filePlanRoleService.existsRole(filePlan, roleParam) == false)
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + root);
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
|
"The role " + roleParam + " does not exist on the records managment root " + filePlan.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
filePlanRoleService.deleteRole(root, roleParam);
|
filePlanRoleService.deleteRole(filePlan, roleParam);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@@ -19,42 +19,25 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Role GET web script API
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmRoleGet extends DeclarativeWebScript
|
public class RmRoleGet extends RoleDeclarativeWebScript
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Log logger = LogFactory.getLog(RmRoleGet.class);
|
private static Log logger = LogFactory.getLog(RmRoleGet.class);
|
||||||
|
|
||||||
private RecordsManagementService rmService;
|
|
||||||
private FilePlanRoleService filePlanRoleService;
|
|
||||||
|
|
||||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
|
||||||
{
|
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
|
||||||
{
|
|
||||||
this.rmService = rmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
@@ -69,18 +52,22 @@ public class RmRoleGet extends DeclarativeWebScript
|
|||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL.");
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the root records management node
|
// get the file plan
|
||||||
// TODO this should be passed
|
NodeRef filePlan = getFilePlan(req);
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
if (filePlan == null)
|
||||||
NodeRef root = roots.get(0);
|
|
||||||
|
|
||||||
// Check that the role exists
|
|
||||||
if (filePlanRoleService.existsRole(root, roleParam) == false)
|
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + root);
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
model.put("role", filePlanRoleService.getRole(root, roleParam));
|
// Check that the role exists
|
||||||
|
if (filePlanRoleService.existsRole(filePlan, roleParam) == false)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
|
"The role " + roleParam + " does not exist on the records managment root " + filePlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
RoleItem item = new RoleItem(filePlanRoleService.getRole(filePlan, roleParam));
|
||||||
|
model.put("role", item);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
@@ -21,14 +21,11 @@ package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||||
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.role.Role;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -38,7 +35,6 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
@@ -48,24 +44,12 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmRolePut extends DeclarativeWebScript
|
public class RmRolePut extends RoleDeclarativeWebScript
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Log logger = LogFactory.getLog(RmRolePut.class);
|
private static Log logger = LogFactory.getLog(RmRolePut.class);
|
||||||
|
|
||||||
private RecordsManagementService rmService;
|
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
private FilePlanRoleService filePlanRoleService;
|
|
||||||
|
|
||||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
|
||||||
{
|
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
|
||||||
{
|
|
||||||
this.rmService = rmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCapabilityService(CapabilityService capabilityService)
|
public void setCapabilityService(CapabilityService capabilityService)
|
||||||
{
|
{
|
||||||
@@ -101,17 +85,22 @@ public class RmRolePut extends DeclarativeWebScript
|
|||||||
capabilites.add(capability);
|
capabilites.add(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
// get the file plan
|
||||||
NodeRef root = roots.get(0);
|
NodeRef filePlan = getFilePlan(req);
|
||||||
|
if (filePlan == null)
|
||||||
// Check that the role exists
|
|
||||||
if (filePlanRoleService.existsRole(root, roleParam) == false)
|
|
||||||
{
|
{
|
||||||
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + root);
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Role role = filePlanRoleService.updateRole(root, name, displayLabel, capabilites);
|
// Check that the role exists
|
||||||
model.put("role", role);
|
if (filePlanRoleService.existsRole(filePlan, roleParam) == false)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND,
|
||||||
|
"The role " + roleParam + " does not exist on the records managment root " + filePlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
Role role = filePlanRoleService.updateRole(filePlan, name, displayLabel, capabilites);
|
||||||
|
model.put("role", new RoleItem(role));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException iox)
|
catch (IOException iox)
|
||||||
|
@@ -19,20 +19,16 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
|
||||||
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.role.Role;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,55 +36,49 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmRolesGet extends DeclarativeWebScript
|
public class RmRolesGet extends RoleDeclarativeWebScript
|
||||||
{
|
{
|
||||||
|
/** Logger */
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Log logger = LogFactory.getLog(RmRolesGet.class);
|
private static Log logger = LogFactory.getLog(RmRolesGet.class);
|
||||||
|
|
||||||
private RecordsManagementService rmService;
|
/**
|
||||||
|
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
|
||||||
private FilePlanRoleService filePlanRoleService;
|
*/
|
||||||
|
|
||||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
|
||||||
{
|
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
|
||||||
{
|
|
||||||
this.rmService = rmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||||
{
|
{
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
Set<Role> roles = null;
|
Set<Role> roles = null;
|
||||||
|
|
||||||
// TODO should be passed
|
// get the file plan
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
NodeRef filePlan = getFilePlan(req);
|
||||||
if (roots != null && roots.size() > 0)
|
if (filePlan == null)
|
||||||
{
|
{
|
||||||
NodeRef root = roots.get(0);
|
throw new WebScriptException(Status.STATUS_FOUND, "File plan does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
// Get the user filter
|
// get the user filter
|
||||||
String user = req.getParameter("user");
|
String user = req.getParameter("user");
|
||||||
if (user != null && user.length() != 0)
|
if (user != null && user.length() != 0)
|
||||||
{
|
{
|
||||||
roles = filePlanRoleService.getRolesByUser(root, user);
|
roles = filePlanRoleService.getRolesByUser(filePlan, user);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
roles = filePlanRoleService.getRoles(root);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
roles = new HashSet<Role>(1);
|
roles = filePlanRoleService.getRoles(filePlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.put("roles", roles);
|
// get the auths parameter
|
||||||
|
boolean showAuths = false;
|
||||||
|
String auths = req.getParameter("auths");
|
||||||
|
if (auths != null && auths.length() != 0)
|
||||||
|
{
|
||||||
|
showAuths = Boolean.parseBoolean(auths);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<RoleItem> items = createRoleItems(filePlan, roles, showAuths);
|
||||||
|
model.put("roles", items);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -21,14 +21,11 @@ package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||||
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.role.Role;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -38,7 +35,6 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
@@ -48,25 +44,13 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RmRolesPost extends DeclarativeWebScript
|
public class RmRolesPost extends RoleDeclarativeWebScript
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static Log logger = LogFactory.getLog(RmRolesPost.class);
|
private static Log logger = LogFactory.getLog(RmRolesPost.class);
|
||||||
|
|
||||||
private RecordsManagementService rmService;
|
|
||||||
private FilePlanRoleService filePlanRoleService;
|
|
||||||
private CapabilityService capabilityService;
|
private CapabilityService capabilityService;
|
||||||
|
|
||||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
|
||||||
{
|
|
||||||
this.filePlanRoleService = filePlanRoleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordsManagementService(RecordsManagementService rmService)
|
|
||||||
{
|
|
||||||
this.rmService = rmService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCapabilityService(CapabilityService capabilityService)
|
public void setCapabilityService(CapabilityService capabilityService)
|
||||||
{
|
{
|
||||||
this.capabilityService = capabilityService;
|
this.capabilityService = capabilityService;
|
||||||
@@ -93,13 +77,15 @@ public class RmRolesPost extends DeclarativeWebScript
|
|||||||
capabilites.add(capability);
|
capabilites.add(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
// get the file plan
|
||||||
NodeRef root = roots.get(0);
|
NodeRef filePlan = getFilePlan(req);
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
Role role = filePlanRoleService.createRole(root, name, displayString, capabilites);
|
Role role = filePlanRoleService.createRole(filePlan, name, displayString, capabilites);
|
||||||
|
model.put("role", new RoleItem(role));
|
||||||
//Set<Role> roles = rmSecurityService.getRoles(root);
|
|
||||||
model.put("role", role);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException iox)
|
catch (IOException iox)
|
||||||
|
@@ -0,0 +1,263 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.script.admin;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.apache.cxf.common.util.StringUtils;
|
||||||
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base declarative web script for role API.
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
||||||
|
{
|
||||||
|
/** File plan service */
|
||||||
|
protected FilePlanService filePlanService;
|
||||||
|
|
||||||
|
/** File plan role service */
|
||||||
|
protected FilePlanRoleService filePlanRoleService;
|
||||||
|
|
||||||
|
/** Authority service */
|
||||||
|
protected AuthorityService authorityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param filePlanService file plan service
|
||||||
|
*/
|
||||||
|
public void setFilePlanService(FilePlanService filePlanService)
|
||||||
|
{
|
||||||
|
this.filePlanService = filePlanService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param filePlanRoleService file plan role service
|
||||||
|
*/
|
||||||
|
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||||
|
{
|
||||||
|
this.filePlanRoleService = filePlanRoleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param authorityService authority service
|
||||||
|
*/
|
||||||
|
public void setAuthorityService(AuthorityService authorityService)
|
||||||
|
{
|
||||||
|
this.authorityService = authorityService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to get the file plan from the passed parameters.
|
||||||
|
*
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected NodeRef getFilePlan(WebScriptRequest req)
|
||||||
|
{
|
||||||
|
NodeRef filePlan = null;
|
||||||
|
|
||||||
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
|
String siteId = templateVars.get("siteid");
|
||||||
|
if (siteId != null)
|
||||||
|
{
|
||||||
|
filePlan = filePlanService.getFilePlanBySiteId(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
String storeType = templateVars.get("store_type");
|
||||||
|
String storeId = templateVars.get("store_id");
|
||||||
|
String id = templateVars.get("id");
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(storeType) == false &&
|
||||||
|
StringUtils.isEmpty(storeId) == false &&
|
||||||
|
StringUtils.isEmpty(id) == false)
|
||||||
|
{
|
||||||
|
StoreRef storeRef = new StoreRef(storeType, storeId);
|
||||||
|
NodeRef nodeRef = new NodeRef(storeRef, id);
|
||||||
|
if (filePlanService.isFilePlan(nodeRef) == true)
|
||||||
|
{
|
||||||
|
filePlan = nodeRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
// Assume we are in a legacy repository and we will grab the default file plan
|
||||||
|
filePlan = filePlanService.getFilePlanBySiteId("rm");
|
||||||
|
}
|
||||||
|
|
||||||
|
return filePlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePlan
|
||||||
|
* @param roles
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Set<RoleItem> createRoleItems(NodeRef filePlan, Set<Role> roles)
|
||||||
|
{
|
||||||
|
return createRoleItems(filePlan, roles, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param filePlan
|
||||||
|
* @param roles
|
||||||
|
* @param showAuths
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Set<RoleItem> createRoleItems(NodeRef filePlan, Set<Role> roles, boolean showAuths)
|
||||||
|
{
|
||||||
|
Set<RoleItem> items = new HashSet<RoleItem>(roles.size());
|
||||||
|
for (Role role : roles)
|
||||||
|
{
|
||||||
|
RoleItem item = null;
|
||||||
|
if (showAuths == true)
|
||||||
|
{
|
||||||
|
item = new RoleItem(role,
|
||||||
|
createAuthorityItems(filePlanRoleService.getUsersAssignedToRole(filePlan, role.getName())),
|
||||||
|
createAuthorityItems(filePlanRoleService.getGroupsAssignedToRole(filePlan, role.getName())));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item = new RoleItem(role);
|
||||||
|
}
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param authorities
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Set<AuthorityItem> createAuthorityItems(Set<String> authorities)
|
||||||
|
{
|
||||||
|
Set<AuthorityItem> result = new HashSet<AuthorityItem>(authorities.size());
|
||||||
|
|
||||||
|
for (String authority : authorities)
|
||||||
|
{
|
||||||
|
String displayLabel = authorityService.getAuthorityDisplayName(authority);
|
||||||
|
result.add(new AuthorityItem(authority, displayLabel));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Role item utility class
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RoleItem
|
||||||
|
{
|
||||||
|
private String name;
|
||||||
|
private String displayLabel;
|
||||||
|
private Set<Capability> capabilities;
|
||||||
|
private boolean showAuths = false;
|
||||||
|
private Set<AuthorityItem> assignedUsers;
|
||||||
|
private Set<AuthorityItem> assignedGroups;
|
||||||
|
|
||||||
|
public RoleItem(Role role)
|
||||||
|
{
|
||||||
|
this.name = role.getName();
|
||||||
|
this.displayLabel = role.getDisplayLabel();
|
||||||
|
this.capabilities = role.getCapabilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleItem(Role role, Set<AuthorityItem> assignedUsers, Set<AuthorityItem> assignedGroups)
|
||||||
|
{
|
||||||
|
this.name = role.getName();
|
||||||
|
this.displayLabel = role.getDisplayLabel();
|
||||||
|
this.capabilities = role.getCapabilities();
|
||||||
|
this.showAuths = true;
|
||||||
|
this.assignedUsers = assignedUsers;
|
||||||
|
this.assignedGroups = assignedGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayLabel()
|
||||||
|
{
|
||||||
|
return displayLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Capability> getCapabilities()
|
||||||
|
{
|
||||||
|
return capabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getShowAuths()
|
||||||
|
{
|
||||||
|
return showAuths;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<AuthorityItem> getAssignedGroups()
|
||||||
|
{
|
||||||
|
return assignedGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<AuthorityItem> getAssignedUsers()
|
||||||
|
{
|
||||||
|
return assignedUsers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AuthorityItem
|
||||||
|
{
|
||||||
|
private String name;
|
||||||
|
private String displayLabel;
|
||||||
|
|
||||||
|
public AuthorityItem(String name, String displayLabel)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.displayLabel = displayLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayLabel()
|
||||||
|
{
|
||||||
|
return displayLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -24,7 +24,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.repository.MLText;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
@@ -26,6 +26,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.service.DataSetServiceImp
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.DispositionServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.DispositionServiceImplTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.ExtendedSecurityServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.ExtendedSecurityServiceImplTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.FilePlanRoleServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.FilePlanRoleServiceImplTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.service.FilePlanServiceImplTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.FreezeServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.FreezeServiceImplTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.ModelSecurityServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.ModelSecurityServiceImplTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.service.RecordServiceImplTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.service.RecordServiceImplTest;
|
||||||
@@ -67,6 +68,7 @@ public class ServicesTestSuite extends TestSuite
|
|||||||
suite.addTestSuite(RecordServiceImplTest.class);
|
suite.addTestSuite(RecordServiceImplTest.class);
|
||||||
suite.addTestSuite(CapabilityServiceImplTest.class);
|
suite.addTestSuite(CapabilityServiceImplTest.class);
|
||||||
suite.addTestSuite(FilePlanRoleServiceImplTest.class);
|
suite.addTestSuite(FilePlanRoleServiceImplTest.class);
|
||||||
|
suite.addTestSuite(FilePlanServiceImplTest.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
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.role.Role;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
@@ -158,7 +159,11 @@ public class FilePlanRoleServiceImplTest extends BaseRMTestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAssignRoleToAuthority() throws Exception
|
/**
|
||||||
|
* {@link FilePlanRoleService#assignRoleToAuthority(org.alfresco.service.cmr.repository.NodeRef, String, String)}
|
||||||
|
* {@link FilePlanRoleService#getAuthorities(org.alfresco.service.cmr.repository.NodeRef, String)
|
||||||
|
*/
|
||||||
|
public void testAuthorityAssignment() throws Exception
|
||||||
{
|
{
|
||||||
doTestInTransaction(new Test<Void>()
|
doTestInTransaction(new Test<Void>()
|
||||||
{
|
{
|
||||||
@@ -168,12 +173,37 @@ public class FilePlanRoleServiceImplTest extends BaseRMTestCase
|
|||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
assertEquals(1, roles.size());
|
assertEquals(1, roles.size());
|
||||||
|
|
||||||
|
Set<String> authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(1, authorities.size());
|
||||||
|
|
||||||
|
authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(0, authorities.size());
|
||||||
|
|
||||||
|
authorities = filePlanRoleService.getAllAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(1, authorities.size());
|
||||||
|
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, rmUserName);
|
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, rmUserName);
|
||||||
|
|
||||||
roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName);
|
roles = filePlanRoleService.getRolesByUser(filePlan, rmUserName);
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
assertEquals(2, roles.size());
|
assertEquals(2, roles.size());
|
||||||
|
|
||||||
|
authorities = filePlanRoleService.getUsersAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(2, authorities.size());
|
||||||
|
|
||||||
|
authorities = filePlanRoleService.getGroupsAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(0, authorities.size());
|
||||||
|
|
||||||
|
authorities = filePlanRoleService.getAllAssignedToRole(filePlan, ROLE_NAME_RECORDS_MANAGER);
|
||||||
|
assertNotNull(authorities);
|
||||||
|
assertEquals(2, authorities.size());
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.service;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
|
import org.alfresco.util.GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File plan service unit test
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class FilePlanServiceImplTest extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Pull in collaboration test data
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean isCollaborationSiteTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)}
|
||||||
|
*/
|
||||||
|
public void testIsFilePlan()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
assertTrue(filePlanService.isFilePlan(filePlan));
|
||||||
|
assertFalse(filePlanService.isFilePlan(rmContainer));
|
||||||
|
assertFalse(filePlanService.isFilePlan(dmDocument));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)}
|
||||||
|
*/
|
||||||
|
public void testGetFilePlans()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
assertEquals(filePlan, filePlanService.getFilePlan(filePlan));
|
||||||
|
assertEquals(filePlan, filePlanService.getFilePlan(rmContainer));
|
||||||
|
assertEquals(filePlan, filePlanService.getFilePlan(rmFolder));
|
||||||
|
assertNull(filePlanService.getFilePlan(dmDocument));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link FilePlanService#getFilePlanBySiteId(String)}
|
||||||
|
*/
|
||||||
|
public void testGetFilePlanBySiteId()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
assertEquals(filePlan, filePlanService.getFilePlanBySiteId(SITE_ID));
|
||||||
|
assertNull(filePlanService.getFilePlanBySiteId("rubbish"));
|
||||||
|
|
||||||
|
String siteId = GUID.generate();
|
||||||
|
siteService.createSite("anything", siteId, "title", "descrition", SiteVisibility.PUBLIC);
|
||||||
|
assertNull(filePlanService.getFilePlanBySiteId(siteId));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -155,6 +155,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
doTestInTransaction(new Test<NodeRef>()
|
doTestInTransaction(new Test<NodeRef>()
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public NodeRef run()
|
public NodeRef run()
|
||||||
{
|
{
|
||||||
@@ -176,17 +177,10 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase
|
|||||||
{
|
{
|
||||||
doTestInTransaction(new Test<NodeRef>()
|
doTestInTransaction(new Test<NodeRef>()
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public NodeRef run()
|
public NodeRef run()
|
||||||
{
|
{
|
||||||
// List<NodeRef> roots = rmService.getRecordsManagementRoots(storeRef);
|
|
||||||
// assertNotNull(roots);
|
|
||||||
// assertTrue(roots.size() != 0);
|
|
||||||
// assertTrue(roots.contains(rmRootContainer));
|
|
||||||
//
|
|
||||||
// RecordsManagementServiceImpl temp = (RecordsManagementServiceImpl)applicationContext.getBean("recordsManagementService");
|
|
||||||
// temp.setDefaultStoreRef(storeRef);
|
|
||||||
|
|
||||||
List<NodeRef> roots = rmService.getFilePlans();
|
List<NodeRef> roots = rmService.getFilePlans();
|
||||||
assertNotNull(roots);
|
assertNotNull(roots);
|
||||||
assertTrue(roots.size() != 0);
|
assertTrue(roots.size() != 0);
|
||||||
|
@@ -18,14 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.webscript;
|
package org.alfresco.module.org_alfresco_module_rm.test.webscript;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMWebScriptTestCase;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||||
@@ -41,9 +45,20 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
|||||||
public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
||||||
implements RecordsManagementModel
|
implements RecordsManagementModel
|
||||||
{
|
{
|
||||||
protected static final String GET_ROLES_URL = "/api/rma/admin/rmroles";
|
protected static final String GET_ROLES_URL_BY_SITE = "/api/rma/admin/{0}/rmroles";
|
||||||
|
protected static final String GET_ROLES_URL_BY_FILEPLAN = "/api/rma/admin/{0}/{1}/{2}/rmroles";
|
||||||
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
||||||
protected static final String APPLICATION_JSON = "application/json";
|
protected static final String APPLICATION_JSON = "application/json";
|
||||||
|
|
||||||
|
private String getRolesUrlBySite()
|
||||||
|
{
|
||||||
|
return MessageFormat.format(GET_ROLES_URL_BY_SITE, SITE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRoleUrlByFilePlan()
|
||||||
|
{
|
||||||
|
return MessageFormat.format(GET_ROLES_URL_BY_FILEPLAN, filePlan.getStoreRef().getProtocol(), filePlan.getStoreRef().getIdentifier(), filePlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetRoles() throws Exception
|
public void testGetRoles() throws Exception
|
||||||
{
|
{
|
||||||
@@ -54,13 +69,18 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5));
|
||||||
|
|
||||||
|
// create test group
|
||||||
|
String groupName = GUID.generate();
|
||||||
|
String group = authorityService.createAuthority(AuthorityType.GROUP, groupName, "monkey", null);
|
||||||
|
|
||||||
// Add the admin user to one of the roles
|
// Add the admin user to one of the roles
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin");
|
filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin");
|
||||||
|
filePlanRoleService.assignRoleToAuthority(filePlan, role1, group);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the roles
|
// Get the roles (for the default file plan)
|
||||||
Response rsp = sendRequest(new GetRequest(GET_ROLES_URL),200);
|
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite()),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(rspContent);
|
JSONObject obj = new JSONObject(rspContent);
|
||||||
@@ -71,20 +91,16 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
JSONArray caps = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 5);
|
||||||
assertNotNull(caps);
|
|
||||||
assertEquals(5, caps.length());
|
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role2);
|
roleObj = roles.getJSONObject(role2);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role2, roleObj.get("name"));
|
assertEquals(role2, roleObj.get("name"));
|
||||||
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
caps = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 5);
|
||||||
assertNotNull(caps);
|
|
||||||
assertEquals(5, caps.length());
|
|
||||||
|
|
||||||
// Get the roles for "admin"
|
// Get the roles, specifying the file plan
|
||||||
rsp = sendRequest(new GetRequest(GET_ROLES_URL + "?user=admin"),200);
|
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan()),200);
|
||||||
rspContent = rsp.getContentAsString();
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
obj = new JSONObject(rspContent);
|
obj = new JSONObject(rspContent);
|
||||||
@@ -95,11 +111,67 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
caps = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 5);
|
||||||
assertNotNull(caps);
|
|
||||||
assertEquals(5, caps.length());
|
roleObj = roles.getJSONObject(role2);
|
||||||
|
assertNotNull(roleObj);
|
||||||
|
assertEquals(role2, roleObj.get("name"));
|
||||||
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
|
// Get the roles for "admin"
|
||||||
|
rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "?user=admin"),200);
|
||||||
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
|
obj = new JSONObject(rspContent);
|
||||||
|
roles = obj.getJSONObject("data");
|
||||||
|
assertNotNull(roles);
|
||||||
|
|
||||||
|
roleObj = roles.getJSONObject(role1);
|
||||||
|
assertNotNull(roleObj);
|
||||||
|
assertEquals(role1, roleObj.get("name"));
|
||||||
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
assertFalse(roles.has(role2));
|
assertFalse(roles.has(role2));
|
||||||
|
|
||||||
|
// Get the roles including assigned authorities
|
||||||
|
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan() + "?auths=true"),200);
|
||||||
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
|
System.out.println(rspContent);
|
||||||
|
|
||||||
|
obj = new JSONObject(rspContent);
|
||||||
|
roles = obj.getJSONObject("data");
|
||||||
|
assertNotNull(roles);
|
||||||
|
|
||||||
|
roleObj = roles.getJSONObject(role1);
|
||||||
|
assertNotNull(roleObj);
|
||||||
|
assertEquals(role1, roleObj.get("name"));
|
||||||
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
|
JSONArray users = roleObj.getJSONArray("assignedUsers");
|
||||||
|
assertNotNull(users);
|
||||||
|
assertEquals(1, users.length());
|
||||||
|
|
||||||
|
JSONArray groups = roleObj.getJSONArray("assignedGroups");
|
||||||
|
assertNotNull(groups);
|
||||||
|
assertEquals(1, groups.length());
|
||||||
|
|
||||||
|
roleObj = roles.getJSONObject(role2);
|
||||||
|
assertNotNull(roleObj);
|
||||||
|
assertEquals(role2, roleObj.get("name"));
|
||||||
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
|
users = roleObj.getJSONArray("assignedUsers");
|
||||||
|
assertNotNull(users);
|
||||||
|
assertEquals(0, users.length());
|
||||||
|
|
||||||
|
groups = roleObj.getJSONArray("assignedGroups");
|
||||||
|
assertNotNull(groups);
|
||||||
|
assertEquals(0, groups.length());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -110,6 +182,25 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void checkCapabilities(JSONObject role, int expectedCount) throws JSONException
|
||||||
|
{
|
||||||
|
JSONObject capabilities = role.getJSONObject("capabilities");
|
||||||
|
assertNotNull(capabilities);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
Iterator it = capabilities.keys();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
String key = (String)it.next();
|
||||||
|
assertNotNull(key);
|
||||||
|
assertNotNull(capabilities.getString(key));
|
||||||
|
count ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(expectedCount, count);
|
||||||
|
}
|
||||||
|
|
||||||
public void testPostRoles() throws Exception
|
public void testPostRoles() throws Exception
|
||||||
{
|
{
|
||||||
Set<Capability> caps = getListOfCapabilities(5);
|
Set<Capability> caps = getListOfCapabilities(5);
|
||||||
@@ -126,7 +217,7 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
obj.put("displayLabel", "Display Label");
|
obj.put("displayLabel", "Display Label");
|
||||||
obj.put("capabilities", arrCaps);
|
obj.put("capabilities", arrCaps);
|
||||||
|
|
||||||
Response rsp = sendRequest(new PostRequest(GET_ROLES_URL, obj.toString(), APPLICATION_JSON),200);
|
Response rsp = sendRequest(new PostRequest(getRolesUrlBySite(), obj.toString(), APPLICATION_JSON),200);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
@@ -138,9 +229,7 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(roleName, roleObj.get("name"));
|
assertEquals(roleName, roleObj.get("name"));
|
||||||
assertEquals("Display Label", roleObj.get("displayLabel"));
|
assertEquals("Display Label", roleObj.get("displayLabel"));
|
||||||
JSONArray resultCaps = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 5);
|
||||||
assertNotNull(resultCaps);
|
|
||||||
assertEquals(5, resultCaps.length());
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -170,7 +259,7 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
obj.put("capabilities", arrCaps);
|
obj.put("capabilities", arrCaps);
|
||||||
|
|
||||||
// Get the roles
|
// Get the roles
|
||||||
Response rsp = sendRequest(new PutRequest(GET_ROLES_URL + "/" + role1, obj.toString(), APPLICATION_JSON),200);
|
Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject result = new JSONObject(rspContent);
|
JSONObject result = new JSONObject(rspContent);
|
||||||
@@ -180,12 +269,10 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("Changed", roleObj.get("displayLabel"));
|
assertEquals("Changed", roleObj.get("displayLabel"));
|
||||||
JSONArray bob = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 4);
|
||||||
assertNotNull(bob);
|
|
||||||
assertEquals(4, bob.length());
|
|
||||||
|
|
||||||
// Bad requests
|
// Bad requests
|
||||||
sendRequest(new PutRequest(GET_ROLES_URL + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -203,7 +290,7 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the roles
|
// Get the roles
|
||||||
Response rsp = sendRequest(new GetRequest(GET_ROLES_URL + "/" + role1),200);
|
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "/" + role1),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(rspContent);
|
JSONObject obj = new JSONObject(rspContent);
|
||||||
@@ -213,12 +300,10 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
JSONArray caps = roleObj.getJSONArray("capabilities");
|
checkCapabilities(roleObj, 5);
|
||||||
assertNotNull(caps);
|
|
||||||
assertEquals(5, caps.length());
|
|
||||||
|
|
||||||
// Bad requests
|
// Bad requests
|
||||||
sendRequest(new GetRequest(GET_ROLES_URL + "/cheese"), 404);
|
sendRequest(new GetRequest(getRolesUrlBySite() + "/cheese"), 404);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -234,11 +319,11 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
assertTrue(filePlanRoleService.existsRole(filePlan, role1));
|
assertTrue(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
sendRequest(new DeleteRequest(GET_ROLES_URL + "/" + role1),200);
|
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1),200);
|
||||||
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
|
|
||||||
// Bad request
|
// Bad request
|
||||||
sendRequest(new DeleteRequest(GET_ROLES_URL + "/cheese"), 404);
|
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Capability> getListOfCapabilities(int size)
|
private Set<Capability> getListOfCapabilities(int size)
|
||||||
|
Reference in New Issue
Block a user