mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
SAIL-390 (SAIL-294): NodeDAO: Allow cm:auditable to be set
- Added test and guard against client code wiping out cm:auditable by not passing in any values - If the cm:auditable behaviour is off and NO cm:auditable properties are passed in, then do nothing git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21192 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,6 +39,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.debug.NodeStoreInspector;
|
import org.alfresco.util.debug.NodeStoreInspector;
|
||||||
|
import org.apache.chemistry.tck.atompub.fixture.AssertNotExistVisitor;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,8 +260,12 @@ public class AuditableAspectTest extends TestCase
|
|||||||
|
|
||||||
// Now modify the node so that the auditable values advance
|
// Now modify the node so that the auditable values advance
|
||||||
nodeService.setProperty(nodeRef, ContentModel.PROP_FIRSTNAME, "TEST-FIRST-NAME-" + System.currentTimeMillis());
|
nodeService.setProperty(nodeRef, ContentModel.PROP_FIRSTNAME, "TEST-FIRST-NAME-" + System.currentTimeMillis());
|
||||||
|
String modifiedBy = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER);
|
||||||
|
assertEquals(
|
||||||
|
"The modifier should have changed to reflect the current user",
|
||||||
|
AuthenticationUtil.getRunAsUser(), modifiedBy);
|
||||||
|
|
||||||
RetryingTransactionCallback<Void> setAuditableCallback = new RetryingTransactionCallback<Void>()
|
RetryingTransactionCallback<Void> setAuditableCallback1 = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
@@ -272,7 +277,22 @@ public class AuditableAspectTest extends TestCase
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(setAuditableCallback);
|
transactionService.getRetryingTransactionHelper().doInTransaction(setAuditableCallback1);
|
||||||
|
// Check
|
||||||
|
assertAuditableProperties(nodeRef, auditableProps);
|
||||||
|
|
||||||
|
RetryingTransactionCallback<Void> setAuditableCallback2 = new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE); // Lasts for txn
|
||||||
|
// Set some other property and ensure that the cm:auditable does not change
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_FIRSTNAME, "TEST-FIRST-NAME-" + System.currentTimeMillis());
|
||||||
|
// Done
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(setAuditableCallback2);
|
||||||
// Check
|
// Check
|
||||||
assertAuditableProperties(nodeRef, auditableProps);
|
assertAuditableProperties(nodeRef, auditableProps);
|
||||||
}
|
}
|
||||||
|
@@ -1600,7 +1600,12 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
if (!policyBehaviourFilter.isEnabled(node.getNodeRef(), ContentModel.ASPECT_AUDITABLE))
|
if (!policyBehaviourFilter.isEnabled(node.getNodeRef(), ContentModel.ASPECT_AUDITABLE))
|
||||||
{
|
{
|
||||||
auditableProps = new AuditablePropertiesEntity();
|
auditableProps = new AuditablePropertiesEntity();
|
||||||
auditableProps.setAuditValues(null, null, newProps);
|
boolean containedAuditProperties = auditableProps.setAuditValues(null, null, newProps);
|
||||||
|
if (!containedAuditProperties)
|
||||||
|
{
|
||||||
|
// The behaviour is disabled, but no audit properties were passed in
|
||||||
|
auditableProps = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove cm:auditable
|
// Remove cm:auditable
|
||||||
|
Reference in New Issue
Block a user