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..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 @@ -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);