From 3c1df3c25aabdf727c910d74c24e1454febda534 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 28 Nov 2019 03:54:07 +0000 Subject: [PATCH 1/2] RM-7070 Show role in audit for active content --- .../rm-audit-context.xml | 1 + .../AuthenticatedUserRolesDataExtractor.java | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml index ac1382d699..47d9cae1dc 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-audit-context.xml @@ -12,6 +12,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java index fcbe2deeac..680732b1e7 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java @@ -31,19 +31,21 @@ import java.io.Serializable; import java.util.Objects; import java.util.Set; +import org.alfresco.model.ContentModel; 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.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.repo.audit.extractor.AbstractDataExtractor; import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; /** * An extractor that uses a node context to determine the currently-authenticated * user's RM roles. This is not a data generator because it can only function in - * the context of a give node. + * the context of a given node. * * @author Derek Hulley * @since 3.2 @@ -53,6 +55,7 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra private NodeService nodeService; private FilePlanService filePlanService; private FilePlanRoleService filePlanRoleService; + private DictionaryService dictionaryService; /** * Used to check that the node in the context is a fileplan component @@ -79,8 +82,16 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra } /** - * @return Returns true if the data is a NodeRef and it represents - * a fileplan component + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + + /** + * @return Returns true if the data is a NodeRef and it represents either + * a fileplan component or a subtype of content */ public boolean isSupported(Serializable data) { @@ -88,7 +99,9 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra { return false; } - return nodeService.hasAspect((NodeRef)data, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT); + NodeRef nodeRef = (NodeRef) data; + return nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT) || + dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT); } /** @@ -109,6 +122,14 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra // Get the rm root NodeRef rmRootNodeRef = filePlanService.getFilePlan(nodeRef); + // if we don't have an rm root and the given node is a subtype of content + if (rmRootNodeRef == null && + dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT)) + { + // use the default file plan + rmRootNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + } + if (rmRootNodeRef != null) { Set roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user); From b9d923d0d0831b836764ebe31e0fb69f85b26c9a Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Thu, 28 Nov 2019 16:48:21 +0000 Subject: [PATCH 2/2] RM-7070 updates from review --- .../audit/extractor/AuthenticatedUserRolesDataExtractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java index 680732b1e7..86c624737a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/AuthenticatedUserRolesDataExtractor.java @@ -90,8 +90,8 @@ public final class AuthenticatedUserRolesDataExtractor extends AbstractDataExtra } /** - * @return Returns true if the data is a NodeRef and it represents either - * a fileplan component or a subtype of content + * @return Returns true if the data is a NodeRef and it represents either a fileplan component or + * a subtype of content */ public boolean isSupported(Serializable data) {