diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml index fa32d07589..20d9b80e9b 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml @@ -7,10 +7,10 @@ - - - - + + + + - + @@ -427,7 +427,7 @@ - + @@ -445,7 +445,7 @@ - + @@ -473,7 +473,7 @@ - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml index 8d6aa004ec..0aeebecf42 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml @@ -719,12 +719,70 @@ - + + + + org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + + + @@ -798,10 +856,9 @@ - - - - + + + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml index 133bf8bc76..1e4b5290be 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml @@ -17,7 +17,7 @@ - + assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - if (isFrozen(assoc.getChildRef()) == true) - { - result = true; - break; - } - } - } - return result; - } - /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isCutoff(org.alfresco.service.cmr.repository.NodeRef) */ @@ -1270,4 +1230,34 @@ public class RecordsManagementServiceImpl implements RecordsManagementService, { return serviceRegistry.getRecordService().isDeclared(nodeRef); } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isHold(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public boolean isHold(NodeRef nodeRef) + { + return serviceRegistry.getFreezeService().isHold(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isFrozen(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public boolean isFrozen(NodeRef nodeRef) + { + return serviceRegistry.getFreezeService().isFrozen(nodeRef); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#hasFrozenChildren(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + @Deprecated + public boolean hasFrozenChildren(NodeRef nodeRef) + { + return serviceRegistry.getFreezeService().hasFrozenChildren(nodeRef); + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java index 551d1d406c..7e5deb7c53 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistry.java @@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditSe import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; import org.alfresco.service.NotAuditable; @@ -47,6 +48,7 @@ public interface RecordsManagementServiceRegistry extends ServiceRegistry static final QName RECORDS_MANAGEMENT_AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAuditService"); static final QName CAPABILITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CapabilityService"); static final QName RECORD_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordService"); + static final QName FREEZE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FreezeService"); /** * @return records management service @@ -101,4 +103,10 @@ public interface RecordsManagementServiceRegistry extends ServiceRegistry */ @NotAuditable CapabilityService getCapabilityService(); + + /** + * @return freeze service + */ + @NotAuditable + FreezeService getFreezeService(); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java index d340b0190f..9c8e94ce8d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementServiceRegistryImpl.java @@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditSe import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; import org.alfresco.repo.service.ServiceDescriptorRegistry; @@ -35,77 +36,93 @@ import org.alfresco.repo.service.ServiceDescriptorRegistry; public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry implements RecordsManagementServiceRegistry { - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementActionService() - */ - public RecordsManagementActionService getRecordsManagementActionService() - { - return (RecordsManagementActionService)getService(RECORDS_MANAGEMENT_ACTION_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementActionService() + */ + @Override + public RecordsManagementActionService getRecordsManagementActionService() + { + return (RecordsManagementActionService)getService(RECORDS_MANAGEMENT_ACTION_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAdminService() - */ - public RecordsManagementAdminService getRecordsManagementAdminService() - { - return (RecordsManagementAdminService)getService(RECORDS_MANAGEMENT_ADMIN_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAdminService() + */ + @Override + public RecordsManagementAdminService getRecordsManagementAdminService() + { + return (RecordsManagementAdminService)getService(RECORDS_MANAGEMENT_ADMIN_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementEventService() - */ - public RecordsManagementEventService getRecordsManagementEventService() - { - return (RecordsManagementEventService)getService(RECORDS_MANAGEMENT_EVENT_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementEventService() + */ + @Override + public RecordsManagementEventService getRecordsManagementEventService() + { + return (RecordsManagementEventService)getService(RECORDS_MANAGEMENT_EVENT_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementService() - */ - public RecordsManagementService getRecordsManagementService() - { - return (RecordsManagementService)getService(RECORDS_MANAGEMENT_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService() - */ - public RecordService getRecordService() - { - return (RecordService)getService(RECORD_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementService() + */ + @Override + public RecordsManagementService getRecordsManagementService() + { + return (RecordsManagementService)getService(RECORDS_MANAGEMENT_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService() - */ - public RecordsManagementSecurityService getRecordsManagementSecurityService() - { - return (RecordsManagementSecurityService)getService(RECORDS_MANAGEMENT_SECURITY_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService() + */ + @Override + public RecordService getRecordService() + { + return (RecordService)getService(RECORD_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService() - */ - public RecordsManagementAuditService getRecordsManagementAuditService() - { - return (RecordsManagementAuditService)getService(RECORDS_MANAGEMENT_AUDIT_SERVICE); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getDictionaryService() - */ - @Override - public DispositionService getDispositionService() - { - return (DispositionService)getService(DISPOSITION_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService() + */ + @Override + public RecordsManagementSecurityService getRecordsManagementSecurityService() + { + return (RecordsManagementSecurityService)getService(RECORDS_MANAGEMENT_SECURITY_SERVICE); + } - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getCapabilityService() - */ - @Override - public CapabilityService getCapabilityService() - { - return (CapabilityService)getService(CAPABILITY_SERVICE); - } + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService() + */ + @Override + public RecordsManagementAuditService getRecordsManagementAuditService() + { + return (RecordsManagementAuditService)getService(RECORDS_MANAGEMENT_AUDIT_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getDictionaryService() + */ + @Override + public DispositionService getDispositionService() + { + return (DispositionService)getService(DISPOSITION_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getCapabilityService() + */ + @Override + public CapabilityService getCapabilityService() + { + return (CapabilityService)getService(CAPABILITY_SERVICE); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFreezeService() + */ + @Override + public FreezeService getFreezeService() + { + return (FreezeService)getService(FREEZE_SERVICE); + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java index de14389358..6c132c28e2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java @@ -185,7 +185,15 @@ public class FreezeServiceImpl implements FreezeService, { ParameterCheck.mandatory("nodeRef", nodeRef); - return dictionaryService.isSubClass(nodeService.getType(nodeRef), TYPE_HOLD); + QName type = nodeService.getType(nodeRef); + if (nodeService.exists(nodeRef) && (TYPE_HOLD.equals(type)) || dictionaryService.isSubClass(type, TYPE_HOLD)) + { + return true; + } + else + { + return false; + } } /** diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java index 037dd56ae9..b04c443f7e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordService.java @@ -32,39 +32,46 @@ import org.alfresco.service.namespace.QName; */ public interface RecordService { - /** - * Get a list of all the record meta-data aspects - * - * @return {@link Set}<{@link QName}> list of record meta-data aspects - */ - Set getRecordMetaDataAspects(); - - /** - * Indicates whether the record is declared - * - * @param nodeRef node reference (record) - * @return boolean true if record is declared, false otherwise - */ - boolean isDeclared(NodeRef nodeRef); - - /** - * Create a new record from an existing document. - * - * @param filePlan - * @param document - */ - void createRecordFromDocument(NodeRef filePlan, NodeRef document); - - // TODO boolean isRecordFiled(NodeRef record); - // TODO boolean isRecordClassified(NodeRef record); - - // NodeRef getNewRecordContainer(NodeRef filePlan); - - //NodeRef createRecord(NodeRef filePlan, NodeRef document); - - // TODO NodeRef createAndFileRecord(NodeRef recordFolder, NodeRef document); - - // TODO void fileRecord(NodeRef recordFolder, NodeRef record); - - public NodeRef getUnfiledRecordContainer(NodeRef filePlan); + /** + * Gets a list of all the record meta-data aspects + * + * @return {@link Set}<{@link QName}> list of record meta-data aspects + */ + Set getRecordMetaDataAspects(); + + /** + * Indicates whether the record is declared + * + * @param nodeRef node reference of the record for which the check would be performed + * @return boolean true if record is declared, false otherwise + */ + boolean isDeclared(NodeRef nodeRef); + + /** + * Creates a new record from an existing document. + * + * @param filePlan The filePlan in which the record should be placed + * @param document The document from which the record will be created + */ + void createRecordFromDocument(NodeRef filePlan, NodeRef document); + + /** + * Gets the unfiled record container for the given file plan + * + * @param filePlan The filePlan for which the unfiled record container should be retrieved + * @return NodeRef The nodeRef of the container object + */ + public NodeRef getUnfiledRecordContainer(NodeRef filePlan); + + // TODO boolean isRecordFiled(NodeRef record); + + // TODO boolean isRecordClassified(NodeRef record); + + // TODO NodeRef getNewRecordContainer(NodeRef filePlan); + + // TODO NodeRef createRecord(NodeRef filePlan, NodeRef document); + + // TODO NodeRef createAndFileRecord(NodeRef recordFolder, NodeRef document); + + // TODO void fileRecord(NodeRef recordFolder, NodeRef record); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index dc53ecf1c9..73fc50b984 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -25,11 +25,9 @@ import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; -import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -38,6 +36,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.ParameterCheck; /** * Record service implementation @@ -47,193 +46,200 @@ import org.alfresco.service.namespace.RegexQNamePattern; */ public class RecordServiceImpl implements RecordService, RecordsManagementModel { - /** Node service **/ - private NodeService nodeService; - - /** Indentiy service */ - private IdentifierService identifierService; - - /** Records management service */ - private RecordsManagementService recordsManagementService; - - /** Dictionary service */ - private DictionaryService dictionaryService; - - /** Policy component */ - private PolicyComponent policyComponent; - - /** Permission service */ - private PermissionService permissionService; - - /** Records management security service */ - private RecordsManagementSecurityService recordsManagementSecurityService; - - /** List of available record meta-data aspects */ - private Set recordMetaDataAspects; - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setIdentifierService(IdentifierService identifierService) - { - this.identifierService = identifierService; - } - - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - public void setPermissionService(PermissionService permissionService) - { - this.permissionService = permissionService; - } - - public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService) - { - this.recordsManagementSecurityService = recordsManagementSecurityService; - } - - public void init() - { - // policyComponent.bindAssociationBehaviour( - // QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), - // TYPE_UNFILED_RECORD_CONTAINER, - // ContentModel.ASSOC_CONTAINS, - // new JavaBehaviour(this, "onCreateNewRecord", NotificationFrequency.TRANSACTION_COMMIT)); - } - -// public void onCreateNewRecord(final ChildAssociationRef childAssocRef, boolean bNew) -// { -// AuthenticationUtil.runAsSystem(new RunAsWork() -// { -// @Override -// public Void doWork() throws Exception -// { -// NodeRef nodeRef = childAssocRef.getChildRef(); -// if (nodeService.exists(nodeRef) == true) -// { -// QName type = nodeService.getType(nodeRef); -// if (ContentModel.TYPE_CONTENT.equals(type) == true || -// dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true) -// { -// makeRecord(nodeRef); -// } -// else -// { -// throw new AlfrescoRuntimeException("Only content can be created as a record."); -// } -// } -// -// return null; -// } -// }); -// } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects() - */ - public Set getRecordMetaDataAspects() - { - if (recordMetaDataAspects == null) - { - recordMetaDataAspects = new HashSet(7); - Collection aspects = dictionaryService.getAllAspects(); - for (QName aspect : aspects) - { - AspectDefinition def = dictionaryService.getAspect(aspect); - if (def != null) - { - QName parent = def.getParentName(); - if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) == true) - { - recordMetaDataAspects.add(aspect); - } - } - } - } - return recordMetaDataAspects; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isDeclared(NodeRef record) - { - return (nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); - } - - @Override - public void createRecordFromDocument(NodeRef filePlan, NodeRef document) - { - // skip everything if the document is already a record - if (nodeService.hasAspect(document, ASPECT_RECORD) == false) - { - // get the documents readers - Long aclId = nodeService.getNodeAclId(document); - Set readers = permissionService.getReaders(aclId); - - // get the documents primary parent assoc - ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(document); - - /// get the new record container for the file plan - NodeRef newRecordContainer = getUnfiledRecordContainer(filePlan); - if (newRecordContainer == null) - { - throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found."); - } - - // move the document into the file plan - nodeService.moveNode(document, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); - - // maintain the original primary location - nodeService.addChild(parentAssoc.getParentRef(), document, parentAssoc.getTypeQName(), parentAssoc.getQName()); - - // make the document a record - makeRecord(document); - - // set the readers - recordsManagementSecurityService.setExtendedReaders(document, readers); - } - } - - /** - * - * @param document - */ - private void makeRecord(NodeRef document) - { - nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, null); - - String recordId = identifierService.generateIdentifier(ASPECT_RECORD, nodeService.getPrimaryParent(document).getParentRef()); - nodeService.setProperty(document, PROP_IDENTIFIER, recordId); - } - - /** - * - * @param filePlan - * @return - */ - public NodeRef getUnfiledRecordContainer(NodeRef filePlan) - { - List assocs = nodeService.getChildAssocs(filePlan, ASSOC_UNFILED_RECORDS, RegexQNamePattern.MATCH_ALL); - if (assocs.size() != 1) - { - throw new AlfrescoRuntimeException("Error getting the unfiled container, because the container cannot be indentified."); - } - return assocs.get(0).getChildRef(); - } + /** Node service **/ + private NodeService nodeService; + /** Indentiy service */ + private IdentifierService identifierService; + + /** Dictionary service */ + private DictionaryService dictionaryService; + +// /** Policy component */ +// private PolicyComponent policyComponent; + + /** Permission service */ + private PermissionService permissionService; + + /** Records management security service */ + private RecordsManagementSecurityService recordsManagementSecurityService; + + /** List of available record meta-data aspects */ + private Set recordMetaDataAspects; + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setIdentifierService(IdentifierService identifierService) + { + this.identifierService = identifierService; + } + + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + +// public void setPolicyComponent(PolicyComponent policyComponent) +// { +// this.policyComponent = policyComponent; +// } + + public void setPermissionService(PermissionService permissionService) + { + this.permissionService = permissionService; + } + + public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService) + { + this.recordsManagementSecurityService = recordsManagementSecurityService; + } + + public void init() + { +// policyComponent.bindAssociationBehaviour( +// QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), +// TYPE_UNFILED_RECORD_CONTAINER, +// ContentModel.ASSOC_CONTAINS, +// new JavaBehaviour(this, "onCreateNewRecord", NotificationFrequency.TRANSACTION_COMMIT)); + } + +// public void onCreateNewRecord(final ChildAssociationRef childAssocRef, boolean bNew) +// { +// AuthenticationUtil.runAsSystem(new RunAsWork() +// { +// @Override +// public Void doWork() throws Exception +// { +// NodeRef nodeRef = childAssocRef.getChildRef(); +// if (nodeService.exists(nodeRef) == true) +// { +// QName type = nodeService.getType(nodeRef); +// if (ContentModel.TYPE_CONTENT.equals(type) == true || +// dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true) +// { +// makeRecord(nodeRef); +// } +// else +// { +// throw new AlfrescoRuntimeException("Only content can be created as a record."); +// } +// } +// return null; +// } +// }); +// } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects() + */ + @Override + public Set getRecordMetaDataAspects() + { + if (recordMetaDataAspects == null) + { + recordMetaDataAspects = new HashSet(7); + Collection aspects = dictionaryService.getAllAspects(); + for (QName aspect : aspects) + { + AspectDefinition def = dictionaryService.getAspect(aspect); + if (def != null) + { + QName parent = def.getParentName(); + if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) == true) + { + recordMetaDataAspects.add(aspect); + } + } + } + } + return recordMetaDataAspects; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public boolean isDeclared(NodeRef record) + { + ParameterCheck.mandatory("record", record); + + return (nodeService.hasAspect(record, ASPECT_DECLARED_RECORD)); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecordFromDocument(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public void createRecordFromDocument(NodeRef filePlan, NodeRef document) + { + ParameterCheck.mandatory("filePlan", filePlan); + ParameterCheck.mandatory("document", document); + + // skip everything if the document is already a record + if (nodeService.hasAspect(document, ASPECT_RECORD) == false) + { + // get the new record container for the file plan + NodeRef newRecordContainer = getUnfiledRecordContainer(filePlan); + if (newRecordContainer == null) + { + throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found."); + } + + // get the documents primary parent assoc + ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(document); + + // move the document into the file plan + nodeService.moveNode(document, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); + + // maintain the original primary location + nodeService.addChild(parentAssoc.getParentRef(), document, parentAssoc.getTypeQName(), parentAssoc.getQName()); + + // make the document a record + makeRecord(document); + + // get the documents readers + Long aclId = nodeService.getNodeAclId(document); + Set readers = permissionService.getReaders(aclId); + + // set the readers + recordsManagementSecurityService.setExtendedReaders(document, readers); + } + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getUnfiledRecordContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + @Override + public NodeRef getUnfiledRecordContainer(NodeRef filePlan) + { + ParameterCheck.mandatory("filePlan", filePlan); + + List assocs = nodeService.getChildAssocs(filePlan, ASSOC_UNFILED_RECORDS, RegexQNamePattern.MATCH_ALL); + if (assocs.size() != 1) + { + throw new AlfrescoRuntimeException("Error getting the unfiled container, because the container cannot be indentified."); + } + + return assocs.get(0).getChildRef(); + } + + /** + * Helper Methods + */ + + /** + * Creates a record from the given document + * + * @param document the document from which a record will be created + */ + private void makeRecord(NodeRef document) + { + nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, null); + + String recordId = identifierService.generateIdentifier(ASPECT_RECORD, nodeService.getPrimaryParent(document).getParentRef()); + nodeService.setProperty(document, PROP_IDENTIFIER, recordId); + } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DataSetServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DataSetServiceImplTest.java index 8912e72632..5599591cc8 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DataSetServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DataSetServiceImplTest.java @@ -15,24 +15,9 @@ import org.alfresco.service.cmr.repository.NodeRef; public class DataSetServiceImplTest extends BaseRMTestCase { - /** Data Set Service */ - private DataSetService dataSetService; - /** Id of the test data set*/ private static final String DATA_SET_ID = "testExampleData"; - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - - // Get Data Set Service - dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); - } - /** * @see DataSetService#getDataSets() */ diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java index ba99b6a3df..d5c055bd1a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java @@ -10,8 +10,6 @@ import java.util.Set; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; -import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.ContentWriter; @@ -21,12 +19,6 @@ import org.alfresco.service.namespace.QName; public class FreezeServiceImplTest extends BaseRMTestCase { - /** Data Set Service */ - private DataSetService dataSetService; - - /** Freeze Service */ - private FreezeService freezeService; - /** Id of the test data set*/ private static final String DATA_SET_ID = "testExampleData"; @@ -42,20 +34,6 @@ public class FreezeServiceImplTest extends BaseRMTestCase /** Fourth Record */ private NodeRef recordFour; - /** - * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#initServices() - */ - @Override - protected void initServices() - { - super.initServices(); - - // Get Data Set Service - dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); - // Get Freeze Service - freezeService = (FreezeService) applicationContext.getBean("freezeService"); - } - public void testFreezeService() throws Exception { doTestInTransaction(new Test() diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java new file mode 100644 index 0000000000..7838611b35 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordServiceImplTest.java @@ -0,0 +1,102 @@ +package org.alfresco.module.org_alfresco_module_rm.test.service; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.namespace.QName; + +public class RecordServiceImplTest extends BaseRMTestCase +{ + + /** + * @see RecordService#getRecordMetaDataAspects() + */ + public void testGetRecordMetaDataAspects() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + Set aspects = recordService.getRecordMetaDataAspects(); + assertNotNull(aspects); + assertEquals(5, aspects.size()); + assertTrue(aspects.containsAll(getAspectList())); + + return null; + } + + /** + * Helper method for getting a list of record meta data aspects + * + * @return Record meta data aspects as list + */ + private List getAspectList() + { + QName[] aspects = new QName[] + { + DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD, + DOD5015Model.ASPECT_PDF_RECORD, + DOD5015Model.ASPECT_WEB_RECORD, + DOD5015Model.ASPECT_SCANNED_RECORD, + ASPECT_RECORD_META_DATA + }; + + return Arrays.asList(aspects); + } + }); + } + + /** + * @see RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testIsDeclared() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // FIXME + return null; + } + }); + } + + /** + * @see RecordService#createRecordFromDocument(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef) + */ + public void testCreateRecordFromDocument() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // FIXME + return null; + } + }); + } + + /** + * @see RecordService#getUnfiledRecordContainer(org.alfresco.service.cmr.repository.NodeRef) + */ + public void testGetUnfiledRecordContainer() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // FIXME + return null; + } + }); + } + +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementServiceImplTest.java index f9d818bdaa..610175439f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementServiceImplTest.java @@ -19,16 +19,13 @@ package org.alfresco.module.org_alfresco_module_rm.test.service; import java.util.List; -import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; -import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; -import org.springframework.util.CollectionUtils; /** @@ -578,41 +575,9 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase } /********** Record methods **********/ - - // TODO void testIsRecordFrozen() - - /** - * @see RecordsManagementService#getRecordMetaDataAspects() - */ - public void testGetRecordMetaDataAspects() - { - doTestInTransaction(new Test() - { - @Override - public Void run() - { - Set aspects = rmService.getRecordMetaDataAspects(); - assertNotNull(aspects); - assertEquals(5, aspects.size()); - assertTrue(aspects.containsAll( - CollectionUtils.arrayToList(new QName[] - { - DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD, - DOD5015Model.ASPECT_PDF_RECORD, - DOD5015Model.ASPECT_WEB_RECORD, - DOD5015Model.ASPECT_SCANNED_RECORD, - ASPECT_RECORD_META_DATA - }))); - - return null; - } - }); - } - + // TODO void testGetRecordFolders(NodeRef record); - // TODO void testIsRecordDeclared(NodeRef nodeRef); - /********** RM2 - Multi-hierarchy record taxonomy's **********/ /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index c5536ea33d..0396b72697 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -27,11 +27,14 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; +import org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RmSiteType; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; @@ -112,6 +115,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase protected RecordsManagementSecurityService securityService; protected CapabilityService capabilityService; protected VitalRecordService vitalRecordService; + protected DataSetService dataSetService; + protected FreezeService freezeService; + protected RecordService recordService; /** test data */ protected StoreRef storeRef; @@ -266,6 +272,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase securityService = (RecordsManagementSecurityService)this.applicationContext.getBean("RecordsManagementSecurityService"); capabilityService = (CapabilityService)this.applicationContext.getBean("CapabilityService"); vitalRecordService = (VitalRecordService)this.applicationContext.getBean("VitalRecordService"); + dataSetService = (DataSetService) applicationContext.getBean("DataSetService"); + freezeService = (FreezeService) applicationContext.getBean("FreezeService"); + recordService = (RecordService) applicationContext.getBean("RecordService"); } /**