mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2026-09-16 18:13:17 +00:00
RM-7062 add noderef to audit entry for hold
This commit is contained in:
+22
-22
@@ -199,6 +199,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
private static final String MSG_AUDIT_VIEW = "rm.audit.audit-view";
|
||||
|
||||
private static final QName PROPERTY_HOLD_NAME = QName.createQName(RecordsManagementModel.RM_URI, "Hold Name");
|
||||
private static final QName PROPERTY_HOLD_NODEREF = QName.createQName(RecordsManagementModel.RM_URI, "Hold NodeRef");
|
||||
private static final String HOLD_PERMISSION_DENIED_MSG = "rm.audit.holdPermission-Error";
|
||||
|
||||
private PolicyComponent policyComponent;
|
||||
@@ -1869,31 +1870,30 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
// get hold nodeRef, if any, from audit event properties
|
||||
NodeRef holdNodeRef = beforeProperties != null ? (NodeRef) beforeProperties.get(PROPERTY_HOLD_NODEREF) : null;
|
||||
if (holdNodeRef != null)
|
||||
{
|
||||
// find any hold names in event properties
|
||||
Map<String, Boolean> holdNamesToHide = new HashMap<>(2);
|
||||
buildHoldNamesToHide(holdNamesToHide, beforeProperties);
|
||||
buildHoldNamesToHide(holdNamesToHide, afterProperties);
|
||||
|
||||
// if audit event contains any hold names, check if any hold name should be hidden
|
||||
if (!holdNamesToHide.isEmpty())
|
||||
if (!AccessStatus.ALLOWED.equals(
|
||||
permissionService.hasPermission(holdNodeRef, PermissionService.READ)))
|
||||
{
|
||||
// get file plan
|
||||
NodeRef filePlan = getFilePlan(nodeRef);
|
||||
|
||||
// check permissions for each hold name
|
||||
for (String holdName : holdNamesToHide.keySet())
|
||||
{
|
||||
boolean hideHoldName = !AccessStatus.ALLOWED.equals(
|
||||
permissionService.hasPermission(getHold(filePlan, holdName), PermissionService.READ));
|
||||
holdNamesToHide.replace(holdName, hideHoldName);
|
||||
}
|
||||
|
||||
// hide hold names, if required, in event properties
|
||||
replaceHoldNameIfRequired(beforeProperties, holdNamesToHide, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||
replaceHoldNameIfRequired(afterProperties, holdNamesToHide, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||
beforeProperties.replace(PROPERTY_HOLD_NAME, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||
}
|
||||
// remove hold node ref from view
|
||||
beforeProperties.remove(PROPERTY_HOLD_NODEREF);
|
||||
}
|
||||
|
||||
holdNodeRef = afterProperties != null ? (NodeRef) afterProperties.get(PROPERTY_HOLD_NODEREF) : null;
|
||||
if (holdNodeRef != null)
|
||||
{
|
||||
if (!AccessStatus.ALLOWED.equals(
|
||||
permissionService.hasPermission(holdNodeRef, PermissionService.READ)))
|
||||
{
|
||||
afterProperties.replace(PROPERTY_HOLD_NAME, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||
}
|
||||
// remove hold node ref from view
|
||||
afterProperties.remove(PROPERTY_HOLD_NODEREF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -47,18 +47,22 @@ class HoldUtils
|
||||
{
|
||||
/** A QName to display for the hold name. */
|
||||
public static final QName HOLD_NAME = QName.createQName(RecordsManagementModel.RM_URI, "Hold Name");
|
||||
/** A QName to display for the hold node ref. */
|
||||
public static final QName HOLD_NODEREF = QName.createQName(RecordsManagementModel.RM_URI, "Hold NodeRef");
|
||||
|
||||
/**
|
||||
* Create a properties map containing the hold name for the given hold.
|
||||
* Create a properties map containing the hold name and node ref for the given hold.
|
||||
*
|
||||
* @param nodeRef The nodeRef of the hold.
|
||||
* @param nodeService The node service.
|
||||
* @return A map containing the name of the hold.
|
||||
* @return A map containing the name and noderef of the hold.
|
||||
*/
|
||||
static Map<QName, Serializable> makePropertiesMap(NodeRef nodeRef, NodeService nodeService)
|
||||
{
|
||||
Map<QName, Serializable> auditProperties = new HashMap<>();
|
||||
|
||||
auditProperties.put(HOLD_NAME, nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
|
||||
auditProperties.put(HOLD_NODEREF, nodeRef);
|
||||
|
||||
return auditProperties;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user