mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-7062 fix integration tests
This commit is contained in:
@@ -1871,12 +1871,31 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// must have read permission on hold to see hold name in event
|
// find any hold names in event properties
|
||||||
Map<String, Boolean> holdNamesToHide = new HashMap<>(2);
|
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())
|
||||||
|
{
|
||||||
|
// 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(beforeProperties, holdNamesToHide, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||||
replaceHoldNameIfRequired(afterProperties, holdNamesToHide, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
replaceHoldNameIfRequired(afterProperties, holdNamesToHide, I18NUtil.getMessage(HOLD_PERMISSION_DENIED_MSG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Refactor this to use the builder pattern
|
// TODO: Refactor this to use the builder pattern
|
||||||
RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry(
|
RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry(
|
||||||
@@ -1911,6 +1930,46 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to extract the hold name, if any, from the given event properties
|
||||||
|
* @param holdNamesToHide map of hold names and their hide name status. True if hold name is to be hidden.
|
||||||
|
* @param eventProperties event properties
|
||||||
|
*/
|
||||||
|
private void buildHoldNamesToHide(Map<String, Boolean> holdNamesToHide, Map<QName, Serializable> eventProperties)
|
||||||
|
{
|
||||||
|
// get hold name, if any, from audit event properties
|
||||||
|
String holdName = eventProperties != null ? (String) eventProperties.get(PROPERTY_HOLD_NAME) : null;
|
||||||
|
if (holdName != null)
|
||||||
|
{
|
||||||
|
// assume hold name should be hidden
|
||||||
|
holdNamesToHide.putIfAbsent(holdName, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to get the file plan
|
||||||
|
* @param nodeRef node ref for which to get file plan
|
||||||
|
* @return node ref of file plan
|
||||||
|
*/
|
||||||
|
private NodeRef getFilePlan(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
NodeRef filePlan = filePlanService.getFilePlan(nodeRef);
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
Set<NodeRef> filePlans = filePlanService.getFilePlans();
|
||||||
|
if (filePlans != null && !filePlans.isEmpty())
|
||||||
|
{
|
||||||
|
filePlan = filePlans.iterator().next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePlan == null)
|
||||||
|
{
|
||||||
|
filePlan = getDefaultFilePlan();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filePlan;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to replace the hold name, if required, in the given event properties
|
* Helper method to replace the hold name, if required, in the given event properties
|
||||||
* @param eventProperties event properties
|
* @param eventProperties event properties
|
||||||
@@ -1924,10 +1983,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
String holdName = eventProperties != null ? (String) eventProperties.get(PROPERTY_HOLD_NAME) : null;
|
String holdName = eventProperties != null ? (String) eventProperties.get(PROPERTY_HOLD_NAME) : null;
|
||||||
if (holdName != null)
|
if (holdName != null)
|
||||||
{
|
{
|
||||||
holdNamesToHide.putIfAbsent(holdName,
|
|
||||||
!AccessStatus.ALLOWED.equals(permissionService.hasPermission(getHold(holdName),
|
|
||||||
PermissionService.READ)));
|
|
||||||
|
|
||||||
if (holdNamesToHide.get(holdName))
|
if (holdNamesToHide.get(holdName))
|
||||||
{
|
{
|
||||||
eventProperties.replace(PROPERTY_HOLD_NAME, replacementText);
|
eventProperties.replace(PROPERTY_HOLD_NAME, replacementText);
|
||||||
@@ -1937,13 +1992,14 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to get the hold for a given hold name
|
* Helper method to get the hold for a given hold name
|
||||||
|
* @param filePlan file plan
|
||||||
* @param holdName hold name
|
* @param holdName hold name
|
||||||
* @return node ref of hold
|
* @return node ref of hold
|
||||||
*/
|
*/
|
||||||
private NodeRef getHold(String holdName)
|
private NodeRef getHold(NodeRef filePlan, String holdName)
|
||||||
{
|
{
|
||||||
return AuthenticationUtil.runAsSystem(() -> {
|
return AuthenticationUtil.runAsSystem(() -> {
|
||||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
//NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||||
return holdService.getHold(filePlan, holdName);
|
return holdService.getHold(filePlan, holdName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user