From 2b9e7f1dd98d06ee691bb91b17d4249c446132b7 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 9 Aug 2016 10:27:16 +1000 Subject: [PATCH] RM-3074: Inplace move no longer needs to modify extended security * inplace move no longer needs to store and reset extended security * no need to clear extended security when assoc is removed * a couple of extra checks to inplace move integration test --- .../fileplan/FilePlanServiceImpl.java | 2 -- .../model/rma/aspect/RecordAspect.java | 2 +- .../patch/v21/RMv21InPlacePatch.java | 3 -- .../record/InplaceRecordServiceImpl.java | 8 ----- .../record/RecordServiceImpl.java | 30 ------------------- .../record/MoveInplaceRecordTest.java | 23 +++++++++++++- 6 files changed, 23 insertions(+), 45 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 6af06fb7fd..a8429536ba 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -42,8 +42,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.domain.node.NodeDAO; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index 2d266a39ea..08a2d66172 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -136,7 +136,7 @@ public class RecordAspect extends AbstractDisposableItem Set writers = extendedSecurityService.getExtendedWriters(parent); if (readers != null && readers.size() != 0) { - extendedSecurityService.addExtendedSecurity(thumbnail, readers, writers, false); + extendedSecurityService.addExtendedSecurity(thumbnail, readers, writers); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java index 9853a5633b..5eb2b2a992 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/patch/v21/RMv21InPlacePatch.java @@ -34,13 +34,10 @@ import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; -import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority; -import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java index 4a009c07f1..929eddcb04 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/InplaceRecordServiceImpl.java @@ -30,7 +30,6 @@ package org.alfresco.module.org_alfresco_module_rm.record; import static org.alfresco.model.ContentModel.ASPECT_PENDING_DELETE; import java.util.List; -import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -173,18 +172,11 @@ public class InplaceRecordServiceImpl extends ServiceBaseImpl implements Inplace { try { - // Get the extended readers/writers - Set extendedReaders = extendedSecurityService.getExtendedReaders(nodeRef); - Set extendedWriters = extendedSecurityService.getExtendedWriters(nodeRef); - // Move the record fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null); // Update the originating location property nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef); - - // Set the extended readers/writers - extendedSecurityService.addExtendedSecurity(nodeRef, extendedReaders, extendedWriters); } catch (FileExistsException | FileNotFoundException ex) { diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index c9dc3b07a1..aefb7c97a9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -253,10 +253,6 @@ public class RecordServiceImpl extends BaseBehaviourBean this, "onCreateChildAssociation", NotificationFrequency.FIRST_EVENT); - private JavaBehaviour onDeleteDeclaredRecordLink = new JavaBehaviour( - this, - "onDeleteDeclaredRecordLink", - NotificationFrequency.FIRST_EVENT); /** * @param identifierService identifier service @@ -417,11 +413,6 @@ public class RecordServiceImpl extends BaseBehaviourBean TYPE_RECORD_FOLDER, ContentModel.ASSOC_CONTAINS, onCreateChildAssociation); - policyComponent.bindAssociationBehaviour( - NodeServicePolicies.BeforeDeleteChildAssociationPolicy.QNAME, - ContentModel.TYPE_FOLDER, - ContentModel.ASSOC_CONTAINS, - onDeleteDeclaredRecordLink); } /** @@ -592,27 +583,6 @@ public class RecordServiceImpl extends BaseBehaviourBean }, AuthenticationUtil.getSystemUserName()); } - /** - * Looking specifically at linked content that was declared a record from a non-rm site. - * When the site or the folder that the link was declared in is deleted we need to remove - * the extended security property accounts in the tree - * - * @param childAssocRef - */ - public void onDeleteDeclaredRecordLink(ChildAssociationRef childAssocRef) - { - // Is the deleted child association not a primary association? - // Does the deleted child association have the rma:recordOriginatingDetails aspect? - // Is the parent of the deleted child association a folder (cm:folder)? - if (!childAssocRef.isPrimary() && - nodeService.hasAspect(childAssocRef.getChildRef(), ASPECT_RECORD_ORIGINATING_DETAILS) && - nodeService.getType(childAssocRef.getParentRef()).equals(ContentModel.TYPE_FOLDER)) - { - // ..then remove the extended readers and writers up the tree for this remaining node - extendedSecurityService.removeAllExtendedSecurity(childAssocRef.getChildRef()); - } - } - /** * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck() */ diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java index 01aea14033..79f8a43d8c 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/MoveInplaceRecordTest.java @@ -69,6 +69,9 @@ public class MoveInplaceRecordTest extends BaseRMTestCase // Extended Readers/Writers private Set extendedReadersBeforeMove; private Set extendedWritersBeforeMove; + + // primary parent of record + private NodeRef primaryParentBeforeMove; public void given() { @@ -95,6 +98,12 @@ public class MoveInplaceRecordTest extends BaseRMTestCase extendedReadersBeforeMove = extendedSecurityService.getExtendedReaders(dmDocument); extendedWritersBeforeMove = extendedSecurityService.getExtendedWriters(dmDocument); + + // get the primary parent and assert that it's a record management artifact + primaryParentBeforeMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertTrue("Primary parent of newly created should be a records management artifact.", + filePlanService.isFilePlanComponent(primaryParentBeforeMove)); + } public void when() @@ -114,12 +123,24 @@ public class MoveInplaceRecordTest extends BaseRMTestCase public void then() { + // assert that the document is still a record + assertTrue("After move the document should still be a record.", + recordService.isRecord(dmDocument)); + // Check that the source folder is empty now and the destination folder has the document assertEquals(0, nodeService.getChildAssocs(dmFolder).size()); List destinationFolderChildAssocs = nodeService.getChildAssocs(destinationDmFolder); assertEquals(1, destinationFolderChildAssocs.size()); assertEquals(dmDocument, destinationFolderChildAssocs.get(0).getChildRef()); - + + // Check that the primary parent of the record has remained unchanged + NodeRef primaryParentAfterMove = nodeService.getPrimaryParent(dmDocument).getParentRef(); + assertTrue("Primary parent of record after inplace move should be a records management artifact.", + filePlanService.isFilePlanComponent(primaryParentAfterMove)); + assertEquals("Primary parent of record after inplace move should remain the same.", + primaryParentBeforeMove, + primaryParentAfterMove); + // Check extended readers/writers Set extendedReadersAfterMove = extendedSecurityService.getExtendedReaders(dmDocument); Set extendedWritersAfterMove = extendedSecurityService.getExtendedWriters(dmDocument);