Fix case where audit information needs to be applied to locked node.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2657 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-04-13 17:52:53 +00:00
parent 4769aa8a64
commit 9bd553336b
2 changed files with 41 additions and 5 deletions

View File

@@ -22,11 +22,11 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -146,7 +146,7 @@ public class AuditableAspect
{
// Set the updated property values (but do not cascade to update audit behaviour)
onUpdateAudit.disable();
this.nodeService.setProperties(nodeRef, properties);
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), AuthenticationUtil.getSystemUserName());
}
finally
{
@@ -178,7 +178,7 @@ public class AuditableAspect
properties.put(ContentModel.PROP_MODIFIER, modifier);
// Set the updated property values
this.nodeService.setProperties(nodeRef, properties);
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), AuthenticationUtil.getSystemUserName());
if (logger.isDebugEnabled())
logger.debug("Auditable node " + nodeRef + " updated [modified=" + now + ";modifier=" + modifier + "]");
@@ -220,4 +220,39 @@ public class AuditableAspect
{
// The auditable aspect should not be copied
}
/**
* Helper to set Audit Properties as System User
*/
private static class SetAuditProperties implements AuthenticationUtil.RunAsWork<Boolean>
{
private NodeService nodeService;
private NodeRef nodeRef;
private Map<QName, Serializable> properties;
/**
* Construct
*
* @param nodeRef
* @param properties
*/
private SetAuditProperties(NodeService nodeService, NodeRef nodeRef, Map<QName, Serializable> properties)
{
this.nodeService = nodeService;
this.nodeRef = nodeRef;
this.properties = properties;
}
/* (non-Javadoc)
* @see org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork#doWork()
*/
public Boolean doWork() throws Exception
{
nodeService.setProperties(nodeRef, properties);
return Boolean.TRUE;
}
}
}

View File

@@ -30,6 +30,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus;
import org.alfresco.service.cmr.lock.LockType;
@@ -431,7 +432,7 @@ public class LockServiceImpl implements LockService
if (nodeRef != null && userName != null)
{
// Check to see if should just ignore this node
if (this.ignoreNodeRefs.contains(nodeRef) == false)
if (!(this.ignoreNodeRefs.contains(nodeRef) || userName.equals(AuthenticationUtil.getSystemUserName())))
{
try
{