diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java index a7ac339093..d3572729e9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceImpl.java @@ -30,6 +30,7 @@ import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; +import org.alfresco.model.RenditionModel; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -194,6 +195,13 @@ public class RecordsManagementServiceImpl implements RecordsManagementService, TYPE_RECORD_CATEGORY, ContentModel.ASSOC_CONTAINS, new JavaBehaviour(this, "onAddContentToContainer", NotificationFrequency.EVERY_EVENT)); + + policyComponent.bindAssociationBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), + ASPECT_RECORD, + RenditionModel.ASSOC_RENDITION, + new JavaBehaviour(this, "onAddRecordThumbnail", NotificationFrequency.TRANSACTION_COMMIT) + ); // Register script execution behaviour on RM property update. this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), @@ -228,8 +236,23 @@ public class RecordsManagementServiceImpl implements RecordsManagementService, */ public void onFileContent(ChildAssociationRef childAssocRef, boolean bNew) { - // File the document - rmActionService.executeRecordsManagementAction(childAssocRef.getChildRef(), "file"); + NodeRef nodeRef = childAssocRef.getChildRef(); + if (nodeService.exists(nodeRef) == true) + { + // Ensure that the filed item is cm:content + QName type = nodeService.getType(nodeRef); + if (ContentModel.TYPE_CONTENT.equals(type) == true || + dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true) + { + // File the document + rmActionService.executeRecordsManagementAction(childAssocRef.getChildRef(), "file"); + } + else + { + // Raise an exception since we should only be filling content into a record folder + throw new AlfrescoRuntimeException("Unable to complete operation, because only content can be filed within a record folder."); + } + } } /** @@ -254,6 +277,22 @@ public class RecordsManagementServiceImpl implements RecordsManagementService, } } + /** + * Make sure the thumbnails of records are marked as file plan components as are therefore subject to the same + * permission restrictions. + * + * @param childAssocRef + * @param bNew + */ + public void onAddRecordThumbnail(ChildAssociationRef childAssocRef, boolean bNew) + { + NodeRef thumbnail = childAssocRef.getChildRef(); + if (nodeService.exists(thumbnail) == true) + { + nodeService.addAspect(thumbnail, ASPECT_FILE_PLAN_COMPONENT, null); + } + } + /** * Called after a DispositionActionDefinition property has been updated. */