mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
[MNT-24085] - Fixed ACL Updater job is updating the cm:modifier details (#2406)
* Disabled audibled and versionable behaviour on add and remove pending acl aspect and properties * Added validations to the unit test to assert modification date is not changed
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -582,6 +582,18 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
|
||||
private void addFixedAclPendingAspect(Long nodeId, Long sharedAclToReplace, Long inheritFrom, Long mergeFrom)
|
||||
{
|
||||
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(nodeId);
|
||||
if (nodePair == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
NodeRef nodeRef = nodePair.getSecond();
|
||||
|
||||
try
|
||||
{
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
|
||||
//If the node already has the pending ACL aspect, just update the new inheritFrom value
|
||||
if (nodeDAO.hasNodeAspect(nodeId, ContentModel.ASPECT_PENDING_FIX_ACL))
|
||||
{
|
||||
@@ -600,12 +612,30 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
nodeDAO.addNodeProperties(nodeId, pendingAclProperties);
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Set Fixed Acl Pending : " + nodeId + " " + nodeDAO.getNodePair(nodeId).getSecond());
|
||||
log.debug("Set Fixed Acl Pending : nodeId " + nodeId + " nodeUUID " + nodeRef.getId());
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePendingAclAspect(Long nodeId)
|
||||
{
|
||||
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(nodeId);
|
||||
if (nodePair == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
NodeRef nodeRef = nodePair.getSecond();
|
||||
|
||||
try
|
||||
{
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
|
||||
Set<QName> aspects = new HashSet<>(1);
|
||||
aspects.add(ContentModel.ASPECT_PENDING_FIX_ACL);
|
||||
Set<QName> pendingFixAclProperties = new HashSet<>();
|
||||
@@ -614,6 +644,12 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
nodeDAO.removeNodeAspects(nodeId, aspects);
|
||||
nodeDAO.removeNodeProperties(nodeId, pendingFixAclProperties);
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -168,7 +169,7 @@ public class FixedAclUpdaterTest
|
||||
}
|
||||
|
||||
/*
|
||||
* Test setting permissions explicitly as sync, but the operaration times out
|
||||
* Test setting permissions explicitly as sync, but the operation times out
|
||||
*/
|
||||
@Test
|
||||
public void testSyncTimeOut()
|
||||
@@ -178,6 +179,7 @@ public class FixedAclUpdaterTest
|
||||
|
||||
try
|
||||
{
|
||||
long timestampBeforePermissions = System.currentTimeMillis();
|
||||
setPermissionsOnTree(folderRef, false, true);
|
||||
|
||||
// Get current ACLS on non pending nodes and validate
|
||||
@@ -186,6 +188,13 @@ public class FixedAclUpdaterTest
|
||||
|
||||
// Validate values in pending ACL node
|
||||
NodeRef folderWithPendingAcl = getFirstNodeWithAclPending(ContentModel.TYPE_FOLDER);
|
||||
|
||||
// - Validate modification date
|
||||
long folderWithPendingAclNodeId = nodeDAO.getNodePair(folderWithPendingAcl).getFirst();
|
||||
Date modificationDate = (Date) nodeDAO.getNodeProperty(folderWithPendingAclNodeId, ContentModel.PROP_MODIFIED);
|
||||
assertTrue("Changing permissions updated cm:modified",modificationDate.getTime() < timestampBeforePermissions);
|
||||
|
||||
// - Validate pending values
|
||||
ACLComparator aclComparatorForPending = new ACLComparator(folderWithPendingAcl);
|
||||
assertEquals("Pending inheritFrom value should be the parent ACL id", aclComparator.getParentAcl(),
|
||||
aclComparatorForPending.getPendingInheritFromAcl());
|
||||
@@ -202,6 +211,10 @@ public class FixedAclUpdaterTest
|
||||
assertEquals("Processed Pending ACL children doesn't have correct ACL", aclComparator.getChildAcl(),
|
||||
aclComparatorForPending.getChildAcl());
|
||||
assertTrue("Permissions not applied on pending nodes", aclComparatorForPending.firstChildHasOriginalPermission());
|
||||
|
||||
//Verify removing the pendingAcl aspect did not change the modification date
|
||||
Date modificationDateAfterJob = (Date) nodeDAO.getNodeProperty(folderWithPendingAclNodeId, ContentModel.PROP_MODIFIED);
|
||||
assertEquals("Running the job updated cm:modified",modificationDate.getTime(),modificationDateAfterJob.getTime());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
Reference in New Issue
Block a user