ACS-9429 Fix AGS Roles API (#3365)

This commit is contained in:
Damian Ujma
2025-05-23 08:34:27 +02:00
committed by GitHub
parent 7c8a75ce6c
commit 075b02baee
2 changed files with 26 additions and 1 deletions

View File

@@ -81,6 +81,7 @@
<bean class="org.alfresco.rm.rest.api.fileplans.FilePlanRolesRelation">
<property name="apiUtils" ref="apiUtils" />
<property name="rmRoles" ref="rm.roles" />
<property name="filePlanService" ref="FilePlanService" />
</bean>
<bean class="org.alfresco.rm.rest.api.holds.HoldsEntityResource" >

View File

@@ -30,7 +30,9 @@ import static org.alfresco.util.ParameterCheck.mandatory;
import org.springframework.beans.factory.InitializingBean;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
@@ -44,6 +46,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class FilePlanRolesRelation implements RelationshipResourceAction.Read<RoleModel>, InitializingBean
{
private RMRoles rmRoles;
private FilePlanService filePlanService;
private FilePlanComponentsApiUtils apiUtils;
@Override
@@ -51,15 +54,31 @@ public class FilePlanRolesRelation implements RelationshipResourceAction.Read<Ro
{
mandatory("rmRoles", this.rmRoles);
mandatory("apiUtils", this.apiUtils);
mandatory("filePlanService", this.filePlanService);
}
@Override
public CollectionWithPagingInfo<RoleModel> readAll(String filePlanId, Parameters params)
{
NodeRef filePlanNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, RecordsManagementModel.TYPE_FILE_PLAN);
NodeRef filePlanNodeRef = getFilePlan(filePlanId);
if (filePlanNodeRef == null)
{
throw new EntityNotFoundException(filePlanId);
}
return rmRoles.getRoles(filePlanNodeRef, params);
}
private NodeRef getFilePlan(String filePlanId)
{
NodeRef filePlanNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, RecordsManagementModel.TYPE_FILE_PLAN);
if (!FilePlanComponentsApiUtils.FILE_PLAN_ALIAS.equals(filePlanId))
{
filePlanNodeRef = filePlanService.getFilePlan(filePlanNodeRef);
}
return filePlanNodeRef;
}
public void setRmRoles(RMRoles rmRoles)
{
this.rmRoles = rmRoles;
@@ -69,4 +88,9 @@ public class FilePlanRolesRelation implements RelationshipResourceAction.Read<Ro
{
this.apiUtils = apiUtils;
}
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
}