diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml index 6be1b778bb..290e36f303 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml @@ -15,6 +15,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 04ca0201a0..df1100e548 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -36,9 +36,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; @@ -47,6 +49,8 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.JavaBehaviour; @@ -58,6 +62,7 @@ import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; +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.NamespaceService; @@ -95,6 +100,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS /** File plan service */ private FilePlanService filePlanService; + /** File plan role service */ + protected FilePlanRoleService filePlanRoleService; + /** Capability service */ private CapabilityService capabilityService; @@ -156,6 +164,14 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS this.filePlanService = filePlanService; } + /** + * @param filePlanRoleService file plan role service + */ + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + { + this.filePlanRoleService = filePlanRoleService; + } + /** * @param capabilityService capability service */ @@ -277,7 +293,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS // Set the base root values super.setRootValues(nodeInfo, rootJSONObject, useShortQNames); - // check the exisitance of the RM site + // check the existence of the RM site checkRmSiteExistence(rootJSONObject); // get the record contributor information @@ -301,11 +317,22 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS addInfo(nodeInfo, rootJSONObject); } } + Set filePlans = filePlanService.getFilePlans(); + if (!filePlans.isEmpty()) + { + NodeRef filePlanNodeRef = filePlans.stream().findFirst().orElse(null); + if (filePlanNodeRef != null) + { + Set roles = filePlanRoleService.getRolesByUser(filePlanNodeRef, AuthenticationUtil.getFullyAuthenticatedUser()); + boolean hasFilingPermission = (roles != null && roles.size() > 0) ? true : false; + rootJSONObject.put("isVisibleForCurrentUser", hasFilingPermission); + } + } } } /** - * Checks for the existance of the RM site + * Checks for the existence of the RM site * * @param rootJSONObject the root JSON object */