Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

94144: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud)
      94082: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1)
         93943: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.5)
            93775: Merged DEV to V4.1-BUG-FIX (4.1.10)
               93465: MNT-8810 : Audit: Double READ on first Share preview
                  - Audit READ for cm:content no longer occurs when thumbnail is created or read.
                  - Audit READ for cm:thumbnail occurs when content of doclib or webpreview is read.
            93874: MNT-8810 : Audit: Double READ on first Share preview
               - Fixed test failure.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@95045 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 15:32:45 +00:00
parent cb9064aa14
commit 8d0db021a5
4 changed files with 25 additions and 11 deletions

View File

@@ -126,6 +126,7 @@ import org.alfresco.service.namespace.QName;
private NodeInfo nodeInfo;
private String action;
private String runAsUser;
private boolean auditSubActions = false;
private Set<String> subActions = new LinkedHashSet<String>();
@@ -157,6 +158,8 @@ import org.alfresco.service.namespace.QName;
{
// Derive higher level action
String action;
boolean keepRunAsUser = false;
if (subActions.contains(CHECK_OUT))
{
action = "CHECK OUT";
@@ -181,6 +184,8 @@ import org.alfresco.service.namespace.QName;
{
// Reads in combinations with other actions tend to only facilitate the other action.
action = "READ";
// MNT-8810 fix, action is considered as READ -> so let's keep actual user who performed readContent
keepRunAsUser = true;
}
else if (subActions.contains(DELETE_NODE))
{
@@ -203,7 +208,10 @@ import org.alfresco.service.namespace.QName;
// Default to first sub-action
action = this.action;
}
if (!keepRunAsUser)
{
runAsUser = null;
}
return action;
}
@@ -455,6 +463,8 @@ import org.alfresco.service.namespace.QName;
{
appendSubAction(new NodeChange(nodeInfoFactory, namespaceService, nodeRef).
setAction(READ_CONTENT));
// MNT-8810 fix, remember runAsUser for read operation
runAsUser = AuthenticationUtil.getRunAsUser();
}
@Override
@@ -524,7 +534,9 @@ import org.alfresco.service.namespace.QName;
if (!subAction) // no need to repeat for sub actions
{
auditMap.put(USER, AuthenticationUtil.getFullyAuthenticatedUser());
// MNT-8810 fix, if runAsUser is not null this means that this is READ action and we should use real user who performed readContent,
// not the current user as actual read may be executed in runAs block (for example for thumbnail creation)
auditMap.put(USER, (runAsUser == null ? AuthenticationUtil.getFullyAuthenticatedUser() : runAsUser));
addSubActionsToAuditMap(auditMap);
auditMap.put(NODE, nodeInfo.getNodeRef());