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">
|
<property name="authenticationService">
|
||||||
<ref bean="authenticationService" />
|
<ref bean="authenticationService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tenantService">
|
||||||
|
<ref bean="tenantService"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Multilingual Document-->
|
<!-- Multilingual Document-->
|
||||||
|
@@ -35,6 +35,7 @@ import org.alfresco.repo.policy.PolicyComponent;
|
|||||||
import org.alfresco.repo.policy.PolicyScope;
|
import org.alfresco.repo.policy.PolicyScope;
|
||||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
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.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -65,6 +66,7 @@ public class AuditableAspect
|
|||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private AuthenticationService authenticationService;
|
private AuthenticationService authenticationService;
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
// Behaviours
|
// Behaviours
|
||||||
private Behaviour onCreateAudit;
|
private Behaviour onCreateAudit;
|
||||||
@@ -96,6 +98,15 @@ public class AuditableAspect
|
|||||||
this.authenticationService = authenticationService;
|
this.authenticationService = authenticationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tenantService the tenant service
|
||||||
|
*/
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise the Auditable Aspect
|
* Initialise the Auditable Aspect
|
||||||
*/
|
*/
|
||||||
@@ -155,7 +166,9 @@ public class AuditableAspect
|
|||||||
{
|
{
|
||||||
// Set the updated property values (but do not cascade to update audit behaviour)
|
// Set the updated property values (but do not cascade to update audit behaviour)
|
||||||
onUpdateAudit.disable();
|
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
|
finally
|
||||||
{
|
{
|
||||||
@@ -187,7 +200,9 @@ public class AuditableAspect
|
|||||||
properties.put(ContentModel.PROP_MODIFIER, modifier);
|
properties.put(ContentModel.PROP_MODIFIER, modifier);
|
||||||
|
|
||||||
// Set the updated property values
|
// 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())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Auditable node " + nodeRef + " updated [modified=" + now + ";modifier=" + modifier + "]");
|
logger.debug("Auditable node " + nodeRef + " updated [modified=" + now + ";modifier=" + modifier + "]");
|
||||||
|
@@ -346,20 +346,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
String tenantDomain = tenantService.getCurrentUserDomain();
|
String tenantDomain = tenantService.getCurrentUserDomain();
|
||||||
if (tenantDomain != "")
|
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)
|
// get non-tenant models (if any)
|
||||||
List<CompiledModel> models = getUriToModels("").get(uri);
|
List<CompiledModel> models = getUriToModels("").get(uri);
|
||||||
|
|
||||||
@@ -397,8 +383,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
}
|
}
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CompiledModel> models = getUriToModels().get(uri);
|
List<CompiledModel> models = getUriToModels().get(uri);
|
||||||
if (models == null)
|
if (models == null)
|
||||||
@@ -554,10 +538,6 @@ public class DictionaryDAOImpl implements DictionaryDAO
|
|||||||
{
|
{
|
||||||
List<CompiledModel> models = getModelsForUri(className.getNamespaceURI());
|
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)
|
for (CompiledModel model : models)
|
||||||
{
|
{
|
||||||
ClassDefinition classDef = model.getClass(className);
|
ClassDefinition classDef = model.getClass(className);
|
||||||
|
@@ -474,8 +474,8 @@ public class LockServiceImpl implements LockService,
|
|||||||
// Ensure we have found a node reference
|
// Ensure we have found a node reference
|
||||||
if (nodeRef != null && userName != null)
|
if (nodeRef != null && userName != null)
|
||||||
{
|
{
|
||||||
// Check to see if should just ignore this node
|
// Check to see if should just ignore this node - note: special MT System due to AuditableAspect
|
||||||
if (!(this.ignoreNodeRefs.contains(nodeRef) || userName.equals(AuthenticationUtil.getSystemUserName())))
|
if (!(this.ignoreNodeRefs.contains(nodeRef) || tenantService.getBaseNameUser(userName).equals(AuthenticationUtil.getSystemUserName())))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@@ -534,8 +534,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
|
|||||||
{
|
{
|
||||||
Set<QName> aspectQNames = getAspects(nodeRef);
|
Set<QName> aspectQNames = getAspects(nodeRef);
|
||||||
|
|
||||||
// special case, e.g. when onAuditAspect runs as System
|
QName typeQName = getType(nodeRef);
|
||||||
QName typeQName = getTypeInternal(nodeRef);
|
|
||||||
|
|
||||||
qnames = new HashSet<QName>(aspectQNames.size() + 1);
|
qnames = new HashSet<QName>(aspectQNames.size() + 1);
|
||||||
qnames.addAll(aspectQNames);
|
qnames.addAll(aspectQNames);
|
||||||
@@ -549,12 +548,6 @@ public abstract class AbstractNodeServiceImpl implements NodeService
|
|||||||
return qnames;
|
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
|
* Generates a GUID for the node using either the creation properties or just by
|
||||||
* generating a value randomly.
|
* generating a value randomly.
|
||||||
|
@@ -567,15 +567,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
return node.getTypeQName();
|
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)
|
* @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