Merge branch 'master' of https://git.alfresco.com/records-management/records-management into feature/RM-7066_UpdateToACS62

This commit is contained in:
Rodica Sutu
2019-11-29 14:55:08 +02:00
2 changed files with 26 additions and 4 deletions

View File

@@ -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 <tt>true</tt> 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 <tt>true</tt> 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<Role> roles = filePlanRoleService.getRolesByUser(rmRootNodeRef, user);