diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index 38076241c7..1cef0b44e0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -67,7 +67,7 @@ public class FilePlanType extends BaseBehaviourBean NodeServicePolicies.BeforeDeleteNodePolicy { private final static List ACCEPTED_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD_CONTAINER, TYPE_TRANSFER_CONTAINER, TYPE_UNFILED_RECORD_CONTAINER); - private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, ContentModel.TYPE_FOLDER); + private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY); private static final String BEHAVIOUR_NAME = "onDeleteFilePlan"; /** file plan service */ @@ -214,35 +214,18 @@ public class FilePlanType extends BaseBehaviourBean @Override public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) { + // We need to automatically cast the created folder to category if it is a plain folder + // This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes. + // Some modules use hidden files to store information (see RM-3283) + if (nodeService.getType(childAssocRef.getChildRef()).equals(ContentModel.TYPE_FOLDER)) + { + nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_CATEGORY); + } + // check the created child is of an accepted type validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES); } - /** - * On transaction commit - * - * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) - */ - @Behaviour - ( - kind = BehaviourKind.ASSOCIATION, - policy = "alf:onCreateChildAssociation", - notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT - ) - public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, boolean bNew) - { - NodeRef child = childAssocRef.getChildRef(); - - // We need to automatically cast the created folder to category if it is a plain folder - // This occurs if the RM folder has been created via IMap, WebDav, etc - // Ignore hidden files. Some modules use hidden files to store information (see RM-3283) - if (nodeService.getType(child).equals(ContentModel.TYPE_FOLDER) && - !nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN)) - { - nodeService.setType(child, TYPE_RECORD_CATEGORY); - } - } - /** * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) */ diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java index 3dc8d4d04a..b5f35e7320 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java @@ -65,7 +65,7 @@ public class RecordCategoryType extends BaseBehaviourBean NodeServicePolicies.OnCreateNodePolicy { private final static List ACCEPTED_UNIQUE_CHILD_TYPES = new ArrayList(); - private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER, ContentModel.TYPE_FOLDER); + private final static List ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER); /** vital record service */ protected VitalRecordService vitalRecordService; @@ -112,7 +112,23 @@ public class RecordCategoryType extends BaseBehaviourBean ) public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew) { + QName childType = nodeService.getType(childAssocRef.getChildRef()); + + // We need to automatically cast the created folder to record folder if it is a plain folder + // This occurs if the RM folder has been created via IMap, WebDav, etc. Don't check subtypes. + // Some modules use hidden folders to store information (see RM-3283). + if (childType.equals(ContentModel.TYPE_FOLDER)) + { + nodeService.setType(childAssocRef.getChildRef(), TYPE_RECORD_FOLDER); + } + validateNewChildAssociation(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES); + + if (bNew) + { + // setup the record folder + recordFolderService.setupRecordFolder(childAssocRef.getChildRef()); + } } /** @@ -129,7 +145,6 @@ public class RecordCategoryType extends BaseBehaviourBean public void onCreateChildAssociationOnCommit(ChildAssociationRef childAssocRef, final boolean bNew) { final NodeRef child = childAssocRef.getChildRef(); - final QName childType = nodeService.getType(child); behaviourFilter.disableBehaviour(); try @@ -139,21 +154,6 @@ public class RecordCategoryType extends BaseBehaviourBean @Override public Void doWork() { - // We need to automatically cast the created folder to record folder if it is a plain folder - // This occurs if the RM folder has been created via IMap, WebDav, etc - // Ignore hidden files. Some modules use hidden files to store information (see RM-3283) - if ( childType.equals(ContentModel.TYPE_FOLDER) && - !nodeService.hasAspect(child, ContentModel.ASPECT_HIDDEN)) - { - nodeService.setType(child, TYPE_RECORD_FOLDER); - } - - if (bNew) - { - // setup the record folder - recordFolderService.setupRecordFolder(child); - } - // setup vital record definition vitalRecordService.setupVitalRecordDefinition(child); diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java index af6a035acc..d25d6ecb19 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanTypeUnitTest.java @@ -195,7 +195,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest try { - filePlanType.onCreateChildAssociationOnCommit(childAssocRef, true); + filePlanType.onCreateChildAssociation(childAssocRef, true); } catch(IntegrityException ex) { diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java index df9f2e1826..2560615bca 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryTypeUnitTest.java @@ -123,7 +123,7 @@ public class RecordCategoryTypeUnitTest extends BaseUnitTest try { - recordCategoryType.onCreateChildAssociationOnCommit(childAssocRef, true); + recordCategoryType.onCreateChildAssociation(childAssocRef, true); } catch(IntegrityException ex) {