RM-7062 add noderef to audit entry for hold

This commit is contained in:
Sara Aspery
2019-12-19 22:46:07 +00:00
parent 5b68c47866
commit 46918e41eb
2 changed files with 28 additions and 24 deletions
@@ -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);
}
}
@@ -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;
}