diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java index 112a68efcb..2fda63641b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordComponentIdentifierAspect.java @@ -65,7 +65,7 @@ import org.springframework.extensions.surf.util.I18NUtil; public class RecordComponentIdentifierAspect extends BaseBehaviourBean implements NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.BeforeDeleteNodePolicy, - NodeServicePolicies.OnCreateNodePolicy, + NodeServicePolicies.OnAddAspectPolicy, CopyServicePolicies.OnCopyCompletePolicy { /** I18N */ @@ -258,7 +258,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT ) @Override - public void onCreateNode(final ChildAssociationRef childAssocRef) + public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName) { AuthenticationUtil.runAsSystem(new RunAsWork() { @@ -268,10 +268,9 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean * When creating a new record the identifier is writable to allow the upload in multiple steps. * On transaction commit make the identifier read only (remove the editable aspect). */ - NodeRef newNode = childAssocRef.getChildRef(); - if(nodeService.exists(newNode)) + if(nodeService.exists(nodeRef)) { - nodeService.setProperty(newNode, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false); + nodeService.setProperty(nodeRef, RecordsManagementModel.PROP_ID_IS_TEMPORARILY_EDITABLE, false); } return null; } diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java index c61dec7f92..9360f23fe1 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4619Test.java @@ -28,6 +28,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.service.cmr.model.FileInfo; +import org.alfresco.service.cmr.repository.NodeRef; import org.springframework.extensions.webscripts.GUID; /** @@ -49,14 +50,30 @@ public class RM4619Test extends BaseRMTestCase */ public void testConvertFolderToCategory() throws Exception { + /* + * Create a folder in the unfiled record container and check it is immediately converted + */ + final NodeRef recordCategory = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER); + assertEquals(TYPE_RECORD_CATEGORY, info.getType()); + assertNotNull(info.getProperties().get(PROP_IDENTIFIER)); + return info.getNodeRef(); + } + }, ADMIN_USER); + + /* + * Check that when the transaction ends the identifier is no longer editable + */ doTestInTransaction(new Test() { @Override public Void run() throws Exception { - FileInfo info = fileFolderService.create(filePlan, GUID.generate(), TYPE_FOLDER); - assertEquals(TYPE_RECORD_CATEGORY, info.getType()); - assertNotNull(info.getProperties().get(PROP_IDENTIFIER)); + assertFalse((Boolean)nodeService.getProperty(recordCategory, PROP_ID_IS_TEMPORARILY_EDITABLE)); return null; } @@ -70,14 +87,30 @@ public class RM4619Test extends BaseRMTestCase */ public void testConvertFolderToRecordFolder() throws Exception { + /* + * Create a folder in a record category and check it is immediately converted + */ + final NodeRef recordFolder = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER); + assertEquals(TYPE_RECORD_FOLDER, info.getType()); + assertNotNull(info.getProperties().get(PROP_IDENTIFIER)); + return info.getNodeRef(); + } + }, ADMIN_USER); + + /* + * Check that when the transaction ends the identifier is no longer editable + */ doTestInTransaction(new Test() { @Override public Void run() throws Exception { - FileInfo info = fileFolderService.create(rmContainer, GUID.generate(), TYPE_FOLDER); - assertEquals(TYPE_RECORD_FOLDER, info.getType()); - assertNotNull(info.getProperties().get(PROP_IDENTIFIER)); + assertFalse((Boolean)nodeService.getProperty(recordFolder, PROP_ID_IS_TEMPORARILY_EDITABLE)); return null; } @@ -94,18 +127,59 @@ public class RM4619Test extends BaseRMTestCase */ public void testConvertFolderToUnfiledRecordFolder() throws Exception { + /* + * Create a folder in the unfiled record container and check it is immediately converted + */ + final NodeRef folder1 = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + FileInfo folder = fileFolderService.create(unfiledContainer, GUID.generate(), TYPE_FOLDER); + assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder.getType()); + assertNotNull(folder.getProperties().get(PROP_IDENTIFIER)); + return folder.getNodeRef(); + } + }, ADMIN_USER); + + /* + * Check that when the transaction ends the identified is no longer editable + */ doTestInTransaction(new Test() { @Override public Void run() throws Exception { - FileInfo folder1 = fileFolderService.create(unfiledContainer, GUID.generate(), TYPE_FOLDER); - assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder1.getType()); - assertNotNull(folder1.getProperties().get(PROP_IDENTIFIER)); + assertFalse((Boolean)nodeService.getProperty(folder1, PROP_ID_IS_TEMPORARILY_EDITABLE)); + return null; + } + + }, ADMIN_USER); - FileInfo folder2 = fileFolderService.create(folder1.getNodeRef(), GUID.generate(), TYPE_FOLDER); - assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder2.getType()); - assertNotNull(folder2.getProperties().get(PROP_IDENTIFIER)); + /* + * Create a folder in the unfiled record folder and check it is immediately converted + */ + final NodeRef folder2 = doTestInTransaction(new Test() + { + @Override + public NodeRef run() throws Exception + { + FileInfo folder = fileFolderService.create(folder1, GUID.generate(), TYPE_FOLDER); + assertEquals(TYPE_UNFILED_RECORD_FOLDER, folder.getType()); + assertNotNull(folder.getProperties().get(PROP_IDENTIFIER)); + return folder.getNodeRef(); + } + }, ADMIN_USER); + + /* + * Check that when the transaction ends the identified is no longer editable + */ + doTestInTransaction(new Test() + { + @Override + public Void run() throws Exception + { + assertFalse((Boolean)nodeService.getProperty(folder2, PROP_ID_IS_TEMPORARILY_EDITABLE)); return null; }