mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
MT fix to ensure behaviour is triggered. Also fixes AR-1745.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6782 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -876,6 +876,9 @@
|
||||
<property name="authenticationService">
|
||||
<ref bean="authenticationService" />
|
||||
</property>
|
||||
<property name="tenantService">
|
||||
<ref bean="tenantService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Multilingual Document-->
|
||||
|
@@ -35,6 +35,7 @@ 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.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -65,6 +66,7 @@ public class AuditableAspect
|
||||
private NodeService nodeService;
|
||||
private AuthenticationService authenticationService;
|
||||
private PolicyComponent policyComponent;
|
||||
private TenantService tenantService;
|
||||
|
||||
// Behaviours
|
||||
private Behaviour onCreateAudit;
|
||||
@@ -96,6 +98,15 @@ public class AuditableAspect
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantService the tenant service
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the Auditable Aspect
|
||||
*/
|
||||
@@ -155,7 +166,9 @@ public class AuditableAspect
|
||||
{
|
||||
// Set the updated property values (but do not cascade to update audit behaviour)
|
||||
onUpdateAudit.disable();
|
||||
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), AuthenticationUtil.getSystemUserName());
|
||||
|
||||
// note: special MT case - need to run in context of user's domain ... although checkForLock requires System
|
||||
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getCurrentUserDomain()));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -187,7 +200,9 @@ public class AuditableAspect
|
||||
properties.put(ContentModel.PROP_MODIFIER, modifier);
|
||||
|
||||
// Set the updated property values
|
||||
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), AuthenticationUtil.getSystemUserName());
|
||||
|
||||
// note: special MT case - need to run in context of user's domain ... although checkForLock requires System
|
||||
AuthenticationUtil.runAs(new SetAuditProperties(nodeService, nodeRef, properties), tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenantService.getCurrentUserDomain()));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Auditable node " + nodeRef + " updated [modified=" + now + ";modifier=" + modifier + "]");
|
||||
|
@@ -346,20 +346,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
||||
String tenantDomain = tenantService.getCurrentUserDomain();
|
||||
if (tenantDomain != "")
|
||||
{
|
||||
// note: special case, if running as System - e.g. addAuditAspect
|
||||
String currentUserName = AuthenticationUtil.getCurrentUserName();
|
||||
|
||||
if (currentUserName != null)
|
||||
{
|
||||
if ((tenantService.isTenantUser(currentUserName)) ||
|
||||
(currentUserName.equals(AuthenticationUtil.getSystemUserName()) && tenantService.isTenantName(uri)))
|
||||
{
|
||||
if (currentUserName.equals(AuthenticationUtil.getSystemUserName()))
|
||||
{
|
||||
tenantDomain = tenantService.getDomain(uri);
|
||||
}
|
||||
uri = tenantService.getBaseName(uri, true);
|
||||
|
||||
// get non-tenant models (if any)
|
||||
List<CompiledModel> models = getUriToModels("").get(uri);
|
||||
|
||||
@@ -397,8 +383,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
||||
}
|
||||
return models;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<CompiledModel> models = getUriToModels().get(uri);
|
||||
if (models == null)
|
||||
@@ -554,10 +538,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
||||
{
|
||||
List<CompiledModel> models = getModelsForUri(className.getNamespaceURI());
|
||||
|
||||
// note: special case, if running as System - e.g. addAuditAspect
|
||||
// now force, even for System user
|
||||
className = tenantService.getBaseName(className, true);
|
||||
|
||||
for (CompiledModel model : models)
|
||||
{
|
||||
ClassDefinition classDef = model.getClass(className);
|
||||
|
@@ -474,8 +474,8 @@ public class LockServiceImpl implements LockService,
|
||||
// Ensure we have found a node reference
|
||||
if (nodeRef != null && userName != null)
|
||||
{
|
||||
// Check to see if should just ignore this node
|
||||
if (!(this.ignoreNodeRefs.contains(nodeRef) || userName.equals(AuthenticationUtil.getSystemUserName())))
|
||||
// Check to see if should just ignore this node - note: special MT System due to AuditableAspect
|
||||
if (!(this.ignoreNodeRefs.contains(nodeRef) || tenantService.getBaseNameUser(userName).equals(AuthenticationUtil.getSystemUserName())))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -534,8 +534,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
|
||||
{
|
||||
Set<QName> aspectQNames = getAspects(nodeRef);
|
||||
|
||||
// special case, e.g. when onAuditAspect runs as System
|
||||
QName typeQName = getTypeInternal(nodeRef);
|
||||
QName typeQName = getType(nodeRef);
|
||||
|
||||
qnames = new HashSet<QName>(aspectQNames.size() + 1);
|
||||
qnames.addAll(aspectQNames);
|
||||
@@ -549,12 +548,6 @@ public abstract class AbstractNodeServiceImpl implements NodeService
|
||||
return qnames;
|
||||
}
|
||||
|
||||
// default implementation, should be overridden to support MT
|
||||
protected QName getTypeInternal(NodeRef nodeRef)
|
||||
{
|
||||
return getType(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a GUID for the node using either the creation properties or just by
|
||||
* generating a value randomly.
|
||||
|
@@ -567,15 +567,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
return node.getTypeQName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QName getTypeInternal(NodeRef nodeRef)
|
||||
{
|
||||
Node node = getNodeNotNull(nodeRef);
|
||||
|
||||
// special case, e.g. when onAuditAspect runs as System
|
||||
return tenantService.getName(nodeRef, node.getTypeQName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.NodeService#setType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user