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 0085ecb34e..b4c08ab445 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,12 +7,13 @@ - - + + + - + @@ -128,7 +129,7 @@ - + @@ -175,7 +176,7 @@ parent="capabilityCondition.base" class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.IsRecordCategoryCondition"> - + @@ -200,5 +201,5 @@ - + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml index c14db066d1..99fe40a51f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml @@ -7,6 +7,7 @@ parent="rmBaseCapability" class="org.alfresco.module.org_alfresco_module_rm.capability.impl.CreateCapability"> + @@ -149,7 +150,7 @@ - + @@ -165,7 +166,7 @@ - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml index 3d42979a63..fea08301e7 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -44,10 +44,10 @@ - + - + @@ -118,7 +118,6 @@ - @@ -126,7 +125,6 @@ - @@ -136,12 +134,12 @@ - + @@ -172,7 +170,6 @@ - diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index ea568b59d7..24c2b8c2a3 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -128,7 +128,6 @@ - @@ -138,6 +137,7 @@ + - + @@ -836,7 +836,7 @@ - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml index 21358a322b..072f0cce70 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-job-context.xml @@ -7,37 +7,37 @@ - + - - org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - + - + - - - + + - + @@ -47,7 +47,7 @@ - 0 0/15 * * * ? + 0 0/15 * * * ? @@ -57,26 +57,26 @@ org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - + - + - - - + @@ -86,37 +86,37 @@ - 0 0/15 * * * ? + 0 0/15 * * * ? - + org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJob - + - + - + - 0/30 * * * * ? + 0/30 * * * * ? - - @@ -125,16 +125,15 @@ - + - - - - + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index f7dc62dc12..b0b0dd26b0 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -87,11 +87,12 @@ - + + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml index b219f60cf6..d64a6a7835 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-public-services-security-context.xml @@ -46,7 +46,6 @@ - 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 dc9a296198..0286f0c255 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 @@ -122,12 +122,12 @@ - + @@ -184,6 +184,9 @@ + + + @@ -506,9 +509,9 @@ init-method="init"> - + @@ -563,7 +566,7 @@ + init-method="init" depends-on="org_alfresco_module_rm_dictionaryBootstrap"> @@ -573,7 +576,7 @@ - + @@ -970,13 +973,13 @@ - + @@ -1047,7 +1050,6 @@ - @@ -1105,7 +1107,7 @@ org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.auditEvent=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.clearAuditLog=RM_CAP.0.rma:filePlanComponent.DeleteAudit org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.getAuditTrail=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.getAuditTrailFile=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.getAuditTrailFile=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.getDateAuditLogLastStarted=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.getDateAuditLogLastStopped=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.isAuditLogEnabled=RM_ALLOW @@ -1126,6 +1128,59 @@ + + + + + + + org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService + + + + + + + + + + + + + + + + + + + + ${server.transaction.mode.default} + + + + + + + + + + + + + + + + + + + @@ -1136,15 +1191,17 @@ - - + + + + @@ -1248,7 +1305,6 @@ - @@ -1485,6 +1541,7 @@ + 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 e7cf19c2dd..fbec50a811 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 @@ -6,7 +6,6 @@ - @@ -15,13 +14,14 @@ - + + - + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 3f1ce339f8..ad81f2962f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -7,7 +7,6 @@ - @@ -145,7 +144,6 @@ - @@ -224,7 +222,6 @@ - @@ -250,7 +247,6 @@ class="org.alfresco.module.org_alfresco_module_rm.script.TransferReportGet" parent="rmBaseTransferWebscript"> - @@ -260,7 +256,6 @@ class="org.alfresco.module.org_alfresco_module_rm.script.TransferReportPost" parent="rmBaseTransferWebscript"> - @@ -392,7 +387,6 @@ - diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java index 0d31fd1441..479446e51e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementService.java @@ -23,303 +23,243 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; 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.recordfolder.RecordFolderService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** * Records management service interface. - * + * * Allows simple creation, manipulation and querying of records management components. - * + * * @author Roy Wetherall */ public interface RecordsManagementService { - /********** RM Component methods **********/ - /** - * @deprecated as of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} */ @Deprecated boolean isFilePlanComponent(NodeRef nodeRef); - + /** * @since 2.0 - * @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} */ @Deprecated FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); - + /** * @since 2.0 - * @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} */ @Deprecated FilePlanComponentKind getFilePlanComponentKindFromType(QName type); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} */ @Deprecated boolean isRecordsManagementContainer(NodeRef nodeRef); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} */ @Deprecated boolean isFilePlan(NodeRef nodeRef); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} */ @Deprecated - boolean isRecordCategory(NodeRef nodeRef); - + boolean isRecordCategory(NodeRef nodeRef); + /** - * Indicates whether the given node is a record folder or not. - * - * @param nodeRef node reference - * @return boolean true if record folder, false otherwise + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} */ - boolean isRecordFolder(NodeRef nodeRef); // record folder service - + @Deprecated + boolean isRecordFolder(NodeRef nodeRef); + /** * Indicates whether the given node is a transfer (container) or not. - * + * * @param nodeRef node reference * @return boolean true if transfer, false otherwise - * + * * @since 2.0 */ boolean isTransfer(NodeRef nodeRef); // transfer service - + /** - * Indicates whether the given node (record or record folder) is a metadata stub or not. - * - * @param nodeRef node reference - * @return boolean true if a metadata stub, false otherwise - * * @since 2.0 + * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} */ - boolean isMetadataStub(NodeRef nodeRef); // record service - + @Deprecated + boolean isMetadataStub(NodeRef nodeRef); + /** - * Indicates whether the item is cutoff or not. - * - * @param nodeRef node reference - * @return boolean true if the item is cutoff, false otherwise - * * @since 2.0 + * @deprecated As of 2.2, see {@link DispositionService#isCutoff(NodeRef)} */ - boolean isCutoff(NodeRef nodeRef); // disposition service ?? - + boolean isCutoff(NodeRef nodeRef); + /** - * @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} */ @Deprecated List getNodeRefPath(NodeRef nodeRef); - + /** * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} */ @Deprecated NodeRef getFilePlan(NodeRef nodeRef); - - /********** File Plan Methods **********/ - + /** * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} */ @Deprecated List getFilePlans(); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} */ @Deprecated NodeRef createFilePlan(NodeRef parent, String name, QName type); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} */ @Deprecated NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} */ @Deprecated NodeRef createFilePlan(NodeRef parent, String name); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} */ @Deprecated NodeRef createFilePlan(NodeRef parent, String name, Map properties); - - - /********** Record Category Methods **********/ - + /** - * @deprecated as of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} */ @Deprecated List getAllContained(NodeRef recordCategory, boolean deep); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} */ @Deprecated - List getAllContained(NodeRef recordCategory); - + List getAllContained(NodeRef recordCategory); + /** - * @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} */ @Deprecated List getContainedRecordCategories(NodeRef recordCategory, boolean deep); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} */ @Deprecated List getContainedRecordCategories(NodeRef recordCategory); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} */ @Deprecated List getContainedRecordFolders(NodeRef container, boolean deep); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} */ @Deprecated List getContainedRecordFolders(NodeRef container); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} */ @Deprecated NodeRef createRecordCategory(NodeRef parent, String name, QName type); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} */ @Deprecated NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} */ @Deprecated NodeRef createRecordCategory(NodeRef parent, String name); - + /** - * @deprecated as of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} */ @Deprecated NodeRef createRecordCategory(NodeRef parent, String name, Map properties); - - - /********** Record Folder methods **********/ - - /** - * Indicates whether the contents of a record folder are all declared. - * - * @param nodeRef node reference (record folder) - * @return boolean true if record folder contents are declared, false otherwise - */ - boolean isRecordFolderDeclared(NodeRef nodeRef); - - /** - * Indicates whether a record folder is closed or not. - * - * @param nodeRef node reference (record folder) - * @return boolean true if record folder is closed, false otherwise - * - * @since 2.0 - */ - boolean isRecordFolderClosed(NodeRef nodeRef); - - // TODO NodeRef getRecordFolderByPath(String path); - - // TODO NodeRef getRecordFolderById(String id); - - // TODO NodeRef getRecordFolderByName(NodeRef parent, String name); - - - /** - * Create a record folder in the rm container. The record folder with take the name and type - * provided. - * - * @param rmContainer records management container - * @param name name - * @param type type - * @return NodeRef node reference of record folder - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); - - /** - * - * @param rmContainer - * @param name - * @param type - * @param properties - * @return - */ - NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); - - /** - * Type defaults to rm:recordFolder - * - * @see RecordsManagementService#createRecordCategory(NodeRef, String, QName) - * - * @param rmContainer records management container - * @param name name - * @return NodeRef node reference of record folder - */ - NodeRef createRecordFolder(NodeRef parent, String name); - - /** - * - * @param parent - * @param name - * @param properties - * @return - */ - NodeRef createRecordFolder(NodeRef parent, String name, Map properties); - - // TODO void deleteRecordFolder(NodeRef recordFolder); - - // TODO List getParentRecordsManagementContainers(NodeRef container); // also applicable to record folders - - /** - * Gets a list of all the records within a record folder - * - * @param recordFolder record folder - * @return List list of records in the record folder - */ - // TODO rename to getContainedRecords(NodeRef recordFolder); - List getRecords(NodeRef recordFolder); - - // TODO move? copy? link? - - /** - * Get all the record folders that a record is filed into. - * - * @param record the record node reference - * @return List list of folder record node references - */ - // TODO rename to List getParentRecordFolders(NodeRef record); - List getRecordFolders(NodeRef record); - - /********** Deprecated **********/ - /** + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} + */ + @Deprecated + boolean isRecordFolderDeclared(NodeRef nodeRef); + + /** + * @since 2.0 + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} + */ + @Deprecated + boolean isRecordFolderClosed(NodeRef nodeRef); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} + */ + @Deprecated + NodeRef createRecordFolder(NodeRef parent, String name); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map) + */ + @Deprecated + NodeRef createRecordFolder(NodeRef parent, String name, Map properties); + + /** + * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} + */ + @Deprecated + List getRecords(NodeRef recordFolder); + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} + */ + @Deprecated + List getRecordFolders(NodeRef record); + + /** * @deprecated As of 2.1, replaced by {@link RecordService#getRecordMetaDataAspects()} */ @Deprecated @@ -330,28 +270,28 @@ public interface RecordsManagementService */ @Deprecated boolean isRecordDeclared(NodeRef nodeRef); - + /** * @since 2.0 * @deprecated As of 2.1, replaced by {@link FreezeService#isHold(NodeRef)} */ @Deprecated boolean isHold(NodeRef nodeRef); - + /** * @since 2.0 * @deprecated As of 2.1, replaced by {@link FreezeService#isFrozen(NodeRef)} */ - @Deprecated + @Deprecated boolean isFrozen(NodeRef nodeRef); - + /** * @since 2.0 * @deprecated As of 2.1, replaced by {@link FreezeService#hasFrozenChildren(NodeRef)} */ @Deprecated boolean hasFrozenChildren(NodeRef nodeRef); - + /** * @deprecated As of 2.1, replaced by {@link RecordService#isRecord(NodeRef)} */ 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 5e0178e2c5..24fbddf550 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 @@ -29,10 +29,14 @@ 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.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; @@ -42,15 +46,11 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.ScriptService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.ParameterCheck; import org.alfresco.util.PropertyMap; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; import org.springframework.extensions.surf.util.I18NUtil; /** @@ -62,17 +62,12 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl implements RecordsManagementService, RecordsManagementModel, RecordsManagementPolicies.OnCreateReference, - RecordsManagementPolicies.OnRemoveReference, - ApplicationContextAware + RecordsManagementPolicies.OnRemoveReference { /** I18N */ private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container"; private final static String MSG_UPDATE_DISP_ACT_DEF = "rm.service.update-disposition-action-def"; private final static String MSG_SET_ID = "rm.service.set-id"; - private final static String MSG_RECORD_FOLDER_EXPECTED = "rm.service.record-folder-expected"; - private final static String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root"; - private final static String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type"; - private final static String MSG_RECORD_FOLDER_TYPE = "rm.service.record-folder-type"; /** Store that the RM roots are contained within */ @SuppressWarnings("unused") @@ -91,18 +86,6 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl /** Java behaviour */ private JavaBehaviour onChangeToDispositionActionDefinition; - /** Application context */ - private ApplicationContext applicationContext; - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - this.applicationContext = applicationContext; - } - /** * Set the service registry service * @@ -135,9 +118,68 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl this.defaultStoreRef = defaultStoreRef; } + /** + * @return File plan service + */ private FilePlanService getFilePlanService() { - return (FilePlanService)applicationContext.getBean("filePlanService"); + return serviceRegistry.getFilePlanService(); + } + + /** + * @return Record Folder Service + */ + private RecordFolderService getRecordFolderService() + { + return serviceRegistry.getRecordFolderService(); + } + + /** + * @return Record Service + */ + private RecordService getRecordService() + { + return serviceRegistry.getRecordService(); + } + + /** + * @return Freeze Service + */ + private FreezeService getFreezeService() + { + return serviceRegistry.getFreezeService(); + } + + /** + * @return Disposition Service + */ + private DispositionService getDispositionService() + { + return serviceRegistry.getDispositionService(); + } + + /** + * @return Extended Security Service + */ + private ExtendedSecurityService getExtendedSecurityService() + { + return serviceRegistry.getExtendedSecurityService(); + } + + /** + * @return Script Service + */ + private ScriptService getScriptService() + { + return serviceRegistry.getScriptService(); + } + + /** + * @return Namespace service + */ + private NamespaceService getNamespaceService() + { + return serviceRegistry.getNamespaceService(); } /** @@ -236,8 +278,8 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl nodeService.addAspect(thumbnail, ASPECT_FILE_PLAN_COMPONENT, null); // manage any extended readers - ExtendedSecurityService extendedSecurityService = serviceRegistry.getExtendedSecurityService(); NodeRef parent = childAssocRef.getParentRef(); + ExtendedSecurityService extendedSecurityService = getExtendedSecurityService(); Set readers = extendedSecurityService.getExtendedReaders(parent); Set writers = extendedSecurityService.getExtendedWriters(parent); if (readers != null && readers.size() != 0) @@ -296,6 +338,37 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } } + /** + * This method compares the oldProps map against the newProps map and returns + * a set of QNames of the properties that have changed. Changed here means one of + *
    + *
  • the property has been removed
  • + *
  • the property has had its value changed
  • + *
  • the property has been added
  • + *
+ */ + private Set determineChangedProps(Map oldProps, Map newProps) + { + Set result = new HashSet(); + for (QName qn : oldProps.keySet()) + { + if (newProps.get(qn) == null || + newProps.get(qn).equals(oldProps.get(qn)) == false) + { + result.add(qn); + } + } + for (QName qn : newProps.keySet()) + { + if (oldProps.get(qn) == null) + { + result.add(qn); + } + } + + return result; + } + /** * Called after any Records Management property has been updated. */ @@ -316,6 +389,68 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl }, AuthenticationUtil.getAdminUserName()); } + /** + * This method examines the old and new property sets and for those properties which + * have changed, looks for script resources corresponding to those properties. + * Those scripts are then called via the ScriptService. + * + * @param nodeWithChangedProperties the node whose properties have changed. + * @param oldProps the old properties and their values. + * @param newProps the new properties and their values. + * + * @see #lookupScripts(Map, Map) + */ + private void lookupAndExecuteScripts(NodeRef nodeWithChangedProperties, + Map oldProps, Map newProps) + { + List scriptRefs = lookupScripts(oldProps, newProps); + + Map objectModel = new HashMap(1); + objectModel.put("node", nodeWithChangedProperties); + objectModel.put("oldProperties", oldProps); + objectModel.put("newProperties", newProps); + + ScriptService scriptService = getScriptService(); + for (NodeRef scriptRef : scriptRefs) + { + scriptService.executeScript(scriptRef, null, objectModel); + } + } + + /** + * This method determines which properties have changed and for each such property + * looks for a script resource in a well-known location. + * + * @param oldProps the old properties and their values. + * @param newProps the new properties and their values. + * @return A list of nodeRefs corresponding to the Script resources. + * + * @see #determineChangedProps(Map, Map) + */ + private List lookupScripts(Map oldProps, Map newProps) + { + List result = new ArrayList(); + + Map changedProps = PropertyMap.getChangedProperties(oldProps, newProps); + for (QName propQName : changedProps.keySet()) + { + QName prefixedQName = propQName.getPrefixedQName(getNamespaceService()); + + String [] splitQName = QName.splitPrefixedQName(prefixedQName.toPrefixString()); + final String shortPrefix = splitQName[0]; + final String localName = splitQName[1]; + + // This is the filename pattern which is assumed. + // e.g. a script file cm_name.js would be called for changed to cm:name + String expectedScriptName = shortPrefix + "_" + localName + ".js"; + + NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); + if (nextElement != null) result.add(nextElement); + } + + return result; + } + /** * Property update behaviour implementation * @@ -380,7 +515,7 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl objectModel.put("policy", policy); objectModel.put("reference", referenceId); - serviceRegistry.getScriptService().executeScript(scriptNodeRef, null, objectModel); + getScriptService().executeScript(scriptNodeRef, null, objectModel); } } @@ -401,43 +536,25 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef) - * - * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} - */ - @Deprecated - public boolean isFilePlan(NodeRef nodeRef) - { - return getFilePlanService().isFilePlan(nodeRef); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanComponent(NodeRef)} */ @Override - public boolean isRecordsManagementContainer(NodeRef nodeRef) - { - return getFilePlanService().isFilePlanContainer(nodeRef); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#isFilePlanComponent(NodeRef)} - */ public boolean isFilePlanComponent(NodeRef nodeRef) { return getFilePlanService().isFilePlanComponent(nodeRef); } /** - * @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKind(NodeRef)} */ + @Override public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) { - return getFilePlanService().getFilePlanComponentKind(nodeRef); + return getFilePlanService().getFilePlanComponentKind(nodeRef); } /** - * @deprecated as of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlanComponentKindFromType(QName)} */ @Override public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) @@ -446,102 +563,97 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @deprecated as of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlanContainer(NodeRef)} */ + @Override + public boolean isRecordsManagementContainer(NodeRef nodeRef) + { + return getFilePlanService().isFilePlanContainer(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isFilePlan(NodeRef)} + */ + @Override + public boolean isFilePlan(NodeRef nodeRef) + { + return getFilePlanService().isFilePlan(nodeRef); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#isRecordCategory(NodeRef)} + */ + @Override public boolean isRecordCategory(NodeRef nodeRef) { return getFilePlanService().isRecordCategory(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordFolder(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolder(NodeRef)} */ + @Override public boolean isRecordFolder(NodeRef nodeRef) { - return instanceOf(nodeRef, TYPE_RECORD_FOLDER); + return getRecordFolderService().isRecordFolder(nodeRef); } /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isTransfer(org.alfresco.service.cmr.repository.NodeRef) */ + @Override public boolean isTransfer(NodeRef nodeRef) { return instanceOf(nodeRef, TYPE_TRANSFER); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isMetadataStub(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.2, see {@link RecordService#isMetadataStub(NodeRef)} */ @Override public boolean isMetadataStub(NodeRef nodeRef) { - return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); + return getRecordService().isMetadataStub(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isCutoff(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.2, see {@link DispositionService#isCutoff(NodeRef)} */ @Override public boolean isCutoff(NodeRef nodeRef) { - return nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef) - * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} - */ - @Deprecated - public NodeRef getFilePlan(NodeRef nodeRef) - { - return getFilePlanService().getFilePlan(nodeRef); + return getDispositionService().isCutoff(nodeRef); } /** * @deprecated as of 2.1, see {@link FilePlanService#getNodeRefPath(NodeRef)} */ + @Override public List getNodeRefPath(NodeRef nodeRef) { return getFilePlanService().getNodeRefPath(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordsManagementRoots(org.alfresco.service.cmr.repository.StoreRef) - * + * @deprecated As of 2.1, see {@link FilePlanService#getFilePlan(NodeRef)} + */ + @Override + public NodeRef getFilePlan(NodeRef nodeRef) + { + return getFilePlanService().getFilePlan(nodeRef); + } + + /** * @deprecated As of 2.1, see {@link FilePlanService#getFilePlans()} */ - @Deprecated + @Override public List getFilePlans() { return new ArrayList(getFilePlanService().getFilePlans()); } /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} - */ - public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) - { - return getFilePlanService().createFilePlan(parent, name, type, properties); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} - */ - public NodeRef createFilePlan(NodeRef parent, String name, Map properties) - { - return getFilePlanService().createFilePlan(parent, name, properties); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} - */ - public NodeRef createFilePlan(NodeRef parent, String name) - { - return getFilePlanService().createFilePlan(parent, name); - } - - /** - * @deprecated as of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName)} */ @Override public NodeRef createFilePlan(NodeRef parent, String name, QName type) @@ -550,39 +662,43 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, QName, Map)} */ - public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) + @Override + public NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties) { - return getFilePlanService().createRecordCategory(parent, name, type, properties); + return getFilePlanService().createFilePlan(parent, name, type, properties); } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String)} */ - public NodeRef createRecordCategory(NodeRef parent, String name) + @Override + public NodeRef createFilePlan(NodeRef parent, String name) { - return getFilePlanService().createRecordCategory(parent, name); + return getFilePlanService().createFilePlan(parent, name); } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#createFilePlan(NodeRef, String, Map)} */ - public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) + @Override + public NodeRef createFilePlan(NodeRef parent, String name, Map properties) { - return getFilePlanService().createRecordCategory(parent, name, properties); + return getFilePlanService().createFilePlan(parent, name, properties); } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef, boolean)} */ - public NodeRef createRecordCategory(NodeRef parent, String name, QName type) + @Override + public List getAllContained(NodeRef container, boolean deep) { - return getFilePlanService().createRecordCategory(parent, name, type); + return getFilePlanService().getAllContained(container, deep); } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#getAllContained(NodeRef)} */ @Override public List getAllContained(NodeRef container) @@ -591,25 +707,7 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @deprecated as of 2.1 - */ - @Override - public List getAllContained(NodeRef container, boolean deep) - { - return getFilePlanService().getAllContained(container, deep); - } - - /** - * @deprecated as of 2.1 - */ - @Override - public List getContainedRecordCategories(NodeRef container) - { - return getFilePlanService().getContainedRecordCategories(container); - } - - /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef, boolean)} */ @Override public List getContainedRecordCategories(NodeRef container, boolean deep) @@ -618,16 +716,16 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordCategories(NodeRef)} */ @Override - public List getContainedRecordFolders(NodeRef container) + public List getContainedRecordCategories(NodeRef container) { - return getFilePlanService().getContainedRecordFolders(container); + return getFilePlanService().getContainedRecordCategories(container); } /** - * @deprecated as of 2.1 + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef, boolean)} */ @Override public List getContainedRecordFolders(NodeRef container, boolean deep) @@ -636,311 +734,172 @@ public class RecordsManagementServiceImpl extends ServiceBaseImpl } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordFolderDeclared(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link FilePlanService#getContainedRecordFolders(NodeRef)} */ - public boolean isRecordFolderDeclared(NodeRef recordFolder) + @Override + public List getContainedRecordFolders(NodeRef container) { - // Check we have a record folder - if (isRecordFolder(recordFolder) == false) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); - } - - boolean result = true; - - // Check that each record in the record folder in declared - List records = getRecords(recordFolder); - for (NodeRef record : records) - { - if (serviceRegistry.getRecordService().isDeclared(record) == false) - { - result = false; - break; - } - } - - return result; - + return getFilePlanService().getContainedRecordFolders(container); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordFolderClosed(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name, QName type) + { + return getFilePlanService().createRecordCategory(parent, name, type); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, QName, Map)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties) + { + return getFilePlanService().createRecordCategory(parent, name, type, properties); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String)} + */ + @Override + public NodeRef createRecordCategory(NodeRef parent, String name) + { + return getFilePlanService().createRecordCategory(parent, name); + } + + /** + * @deprecated As of 2.1, see {@link FilePlanService#createRecordCategory(NodeRef, String, Map)} + */ + public NodeRef createRecordCategory(NodeRef parent, String name, Map properties) + { + return getFilePlanService().createRecordCategory(parent, name, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderDeclared(NodeRef)} + */ + @Override + public boolean isRecordFolderDeclared(NodeRef recordFolder) + { + return getRecordFolderService().isRecordFolderDeclared(recordFolder); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#isRecordFolderClosed(NodeRef)} */ @Override public boolean isRecordFolderClosed(NodeRef nodeRef) { - // Check we have a record folder - if (isRecordFolder(nodeRef) == false) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); - } - - return ((Boolean)this.nodeService.getProperty(nodeRef, PROP_IS_CLOSED)).booleanValue(); - } - - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordFolders(org.alfresco.service.cmr.repository.NodeRef) - */ - public List getRecordFolders(NodeRef record) - { - List result = new ArrayList(1); - if (isRecord(record) == true) - { - List assocs = this.nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef parent = assoc.getParentRef(); - if (isRecordFolder(parent) == true) - { - result.add(parent); - } - } - } - return result; + return getRecordFolderService().isRecordFolderClosed(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordFolder(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) - */ - public NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties) - { - ParameterCheck.mandatory("rmContainer", rmContainer); - ParameterCheck.mandatory("name", name); - ParameterCheck.mandatory("type", type); - - // Check that we are not trying to create a record folder in a root container - if (isFilePlan(rmContainer) == true) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_ROOT)); - } - - // Check that the parent is a container - QName parentType = nodeService.getType(rmContainer); - if (TYPE_RECORD_CATEGORY.equals(parentType) == false && - dictionaryService.isSubClass(parentType, TYPE_RECORD_CATEGORY) == false) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_TYPE, parentType.toString())); - } - - // Check that the the provided type is a sub-type of rm:recordFolder - if (TYPE_RECORD_FOLDER.equals(type) == false && - dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER) == false) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_TYPE, type.toString())); - } - - Map props = new HashMap(1); - if (properties != null && properties.size() != 0) - { - props.putAll(properties); - } - props.put(ContentModel.PROP_NAME, name); - - return nodeService.createNode( - rmContainer, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), - type, - props).getChildRef(); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordFolder(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public NodeRef createRecordFolder(NodeRef rmContrainer, String name) - { - // TODO defaults to rm:recordFolder, but in future could auto-detect sub-type of folder based on - // context - return createRecordFolder(rmContrainer, name, TYPE_RECORD_FOLDER); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordFolder(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) - */ - public NodeRef createRecordFolder(NodeRef parent, String name, Map properties) - { - return createRecordFolder(parent, name, TYPE_RECORD_FOLDER, properties); - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#createRecordFolder(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName)} */ + @Override public NodeRef createRecordFolder(NodeRef parent, String name, QName type) { - return createRecordFolder(parent, name, type, null); + return getRecordFolderService().createRecordFolder(parent, name, type); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecords(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, QName, Map)} */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties) + { + return getRecordFolderService().createRecordFolder(rmContainer, name, type, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String)} + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContrainer, String name) + { + return getRecordFolderService().createRecordFolder(rmContrainer, name); + } + + /** + * @deprecated As of 2.2, see {@link RecordFolderService#createRecordFolder(NodeRef, String, Map)} + */ + @Override + public NodeRef createRecordFolder(NodeRef parent, String name, Map properties) + { + return getRecordFolderService().createRecordFolder(parent, name, properties); + } + + /** + * @deprecated As of 2.2, see {@link RecordService#getRecords(NodeRef)} + */ + @Override public List getRecords(NodeRef recordFolder) { - List result = new ArrayList(1); - if (isRecordFolder(recordFolder) == true) - { - List assocs = this.nodeService.getChildAssocs(recordFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef assoc : assocs) - { - NodeRef child = assoc.getChildRef(); - if (isRecord(child) == true) - { - result.add(child); - } - } - } - return result; + return getRecordService().getRecords(recordFolder); } /** - * This method examines the old and new property sets and for those properties which - * have changed, looks for script resources corresponding to those properties. - * Those scripts are then called via the ScriptService. - * - * @param nodeWithChangedProperties the node whose properties have changed. - * @param oldProps the old properties and their values. - * @param newProps the new properties and their values. - * - * @see #lookupScripts(Map, Map) - */ - private void lookupAndExecuteScripts(NodeRef nodeWithChangedProperties, - Map oldProps, Map newProps) - { - List scriptRefs = lookupScripts(oldProps, newProps); - - Map objectModel = new HashMap(1); - objectModel.put("node", nodeWithChangedProperties); - objectModel.put("oldProperties", oldProps); - objectModel.put("newProperties", newProps); - - for (NodeRef scriptRef : scriptRefs) - { - serviceRegistry.getScriptService().executeScript(scriptRef, null, objectModel); - } - } - - /** - * This method determines which properties have changed and for each such property - * looks for a script resource in a well-known location. - * - * @param oldProps the old properties and their values. - * @param newProps the new properties and their values. - * @return A list of nodeRefs corresponding to the Script resources. - * - * @see #determineChangedProps(Map, Map) - */ - private List lookupScripts(Map oldProps, Map newProps) - { - List result = new ArrayList(); - - Map changedProps = PropertyMap.getChangedProperties(oldProps, newProps); - for (QName propQName : changedProps.keySet()) - { - QName prefixedQName = propQName.getPrefixedQName(serviceRegistry.getNamespaceService()); - - String [] splitQName = QName.splitPrefixedQName(prefixedQName.toPrefixString()); - final String shortPrefix = splitQName[0]; - final String localName = splitQName[1]; - - // This is the filename pattern which is assumed. - // e.g. a script file cm_name.js would be called for changed to cm:name - String expectedScriptName = shortPrefix + "_" + localName + ".js"; - - NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); - if (nextElement != null) result.add(nextElement); - } - - return result; - } - - /** - * This method compares the oldProps map against the newProps map and returns - * a set of QNames of the properties that have changed. Changed here means one of - *
    - *
  • the property has been removed
  • - *
  • the property has had its value changed
  • - *
  • the property has been added
  • - *
- */ - private Set determineChangedProps(Map oldProps, Map newProps) - { - Set result = new HashSet(); - for (QName qn : oldProps.keySet()) - { - if (newProps.get(qn) == null || - newProps.get(qn).equals(oldProps.get(qn)) == false) - { - result.add(qn); - } - } - for (QName qn : newProps.keySet()) - { - if (oldProps.get(qn) == null) - { - result.add(qn); - } - } - - return result; - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordMetaDataAspects() + * @deprecated As of 2.2, see {@link RecordFolderService#getRecordFolders(NodeRef)} + */ + @Override + public List getRecordFolders(NodeRef record) + { + return getRecordFolderService().getRecordFolders(record); + } + + /** + * @deprecated As of 2.1, see {@link RecordService#getRecordMetaDataAspects()} */ @Override - @Deprecated public Set getRecordMetaDataAspects() { - return serviceRegistry.getRecordService().getRecordMetaDataAspects(); + return getRecordService().getRecordMetaDataAspects(); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordDeclared(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link RecordService#isDeclared(NodeRef)} */ @Override - @Deprecated public boolean isRecordDeclared(NodeRef nodeRef) { - return serviceRegistry.getRecordService().isDeclared(nodeRef); + return getRecordService().isDeclared(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isHold(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link FreezeService#isHold(NodeRef)} */ @Override - @Deprecated public boolean isHold(NodeRef nodeRef) { - return serviceRegistry.getFreezeService().isHold(nodeRef); + return getFreezeService().isHold(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isFrozen(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link FreezeService#isFrozen(NodeRef)} */ @Override - @Deprecated public boolean isFrozen(NodeRef nodeRef) { - return serviceRegistry.getFreezeService().isFrozen(nodeRef); + return getFreezeService().isFrozen(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#hasFrozenChildren(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link FreezeService#hasFrozenChildren(NodeRef)} */ @Override - @Deprecated public boolean hasFrozenChildren(NodeRef nodeRef) { - return serviceRegistry.getFreezeService().hasFrozenChildren(nodeRef); + return getFreezeService().hasFrozenChildren(nodeRef); } /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecord(org.alfresco.service.cmr.repository.NodeRef) + * @deprecated As of 2.1, see {@link RecordService#isRecord(NodeRef)} */ @Override - @Deprecated public boolean isRecord(NodeRef nodeRef) { - return serviceRegistry.getRecordService().isRecord(nodeRef); + return getRecordService().isRecord(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 a31b64d1cd..615084ea33 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 @@ -28,6 +28,7 @@ import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; @@ -40,7 +41,7 @@ import org.alfresco.service.namespace.QName; /** * Records management service registry - * + * * @author Roy Wetherall */ @SuppressWarnings("deprecation") @@ -64,110 +65,118 @@ public interface RecordsManagementServiceRegistry extends ServiceRegistry static final QName IDENTIFIER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "recordsManagementIdentifierService"); @Deprecated static final QName RECORDS_MANAGEMENT_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementSecurityService"); - - + static final QName RECORD_FOLDER_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordFolderService"); + + /** * @return records management service */ @NotAuditable RecordsManagementService getRecordsManagementService(); - + /** * @return record service */ @NotAuditable RecordService getRecordService(); - + /** * @return disposition service */ @NotAuditable DispositionService getDispositionService(); - + /** * @return records management admin service */ @NotAuditable RecordsManagementAdminService getRecordsManagementAdminService(); - + /** * @return records management action service */ @NotAuditable RecordsManagementActionService getRecordsManagementActionService(); - + /** * @return records management event service */ @NotAuditable RecordsManagementEventService getRecordsManagementEventService(); - + /** * @return records management security service - * + * * @deprecated As of release 2.1, replaced with {@link FilePlanRoleService}, {@link FilePlanPermissionService} and {@link ModelSecurityService} */ @Deprecated @NotAuditable RecordsManagementSecurityService getRecordsManagementSecurityService(); - + /** * @return records management audit service */ @NotAuditable RecordsManagementAuditService getRecordsManagementAuditService(); - + /** * @return capability service * @since 2.0 */ @NotAuditable CapabilityService getCapabilityService(); - + /** * @return freeze service * @since 2.1 */ @NotAuditable FreezeService getFreezeService(); - + /** * @return extended security service * @since 2.1 */ @NotAuditable ExtendedSecurityService getExtendedSecurityService(); - + /** * @return file plan service - * @since 2.1 + * @since 2.1 */ @NotAuditable FilePlanService getFilePlanService(); - + /** * @return file plan role service * @since 2.1 */ @NotAuditable FilePlanRoleService getFilePlanRoleService(); - + /** * @return file plan permission service - * @since 2.1 + * @since 2.1 */ @NotAuditable FilePlanPermissionService getFilePlanPermissionService(); - + /** * @return file plan authentication service * @since 2.1 */ FilePlanAuthenticationService getFilePlanAuthenticationService(); - + /** * @return identifier service * @since 2.1 */ IdentifierService getIdentifierService(); + + /** + * @return record folder service + * @since 2.2 + */ + @NotAuditable + RecordFolderService getRecordFolderService(); } 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 af864c8c49..b42343d2d0 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 @@ -27,6 +27,7 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService; import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; @@ -36,11 +37,11 @@ import org.alfresco.repo.service.ServiceDescriptorRegistry; /** * Records management service registry implementation - * + * * @author Roy Wetherall */ @SuppressWarnings("deprecation") -public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry +public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegistry implements RecordsManagementServiceRegistry { /** @@ -141,7 +142,7 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis { return (ExtendedSecurityService) getService(EXTENDED_SECURITY_SERVICE); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanService() */ @@ -159,7 +160,7 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis { return (FilePlanRoleService) getService(FILE_PLAN_ROLE_SERVICE); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanPermissionService() */ @@ -168,7 +169,7 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis { return (FilePlanPermissionService) getService(FILE_PLAN_PERMISSION_SERVICE); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getFilePlanAuthenticationService() */ @@ -177,7 +178,7 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis { return (FilePlanAuthenticationService) getService(FILE_PLAN_AUTHENTICATION_SERVICE); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getIdentifierService() */ @@ -186,4 +187,13 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis { return (IdentifierService) getService(IDENTIFIER_SERVICE); } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordFolderService() + */ + @Override + public RecordFolderService getRecordFolderService() + { + return (RecordFolderService) getService(RECORD_FOLDER_SERVICE); + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java index 0d6d1b7a6c..4372e67654 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; @@ -42,6 +41,7 @@ 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.security.ModelSecurityService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; import org.alfresco.service.cmr.action.Action; @@ -66,7 +66,7 @@ import org.springframework.util.StringUtils; /** * Records management action executer base class - * + * * @author Roy Wetherall */ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExecuterAbstractBase @@ -76,58 +76,58 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { /** Namespace service */ protected NamespaceService namespaceService; - + /** Used to control transactional behaviour including post-commit auditing */ protected TransactionService transactionService; - + /** Node service */ protected NodeService nodeService; - + /** Dictionary service */ protected DictionaryService dictionaryService; - + /** Content service */ protected ContentService contentService; - + /** Action service */ protected ActionService actionService; - + /** Records management action service */ protected RecordsManagementAuditService recordsManagementAuditService; - + /** Records management action service */ protected RecordsManagementActionService recordsManagementActionService; - - /** Records management service */ - protected RecordsManagementService recordsManagementService; - + /** Record service */ protected RecordService recordService; - + /** Disposition service */ protected DispositionService dispositionService; - + /** Vital record service */ protected VitalRecordService vitalRecordService; - + /** Records management event service */ protected RecordsManagementEventService recordsManagementEventService; - + /** Records management action service */ protected RecordsManagementAdminService recordsManagementAdminService; - + /** Ownable service **/ protected OwnableService ownableService; - - /** Freeze Service */ + + /** Freeze service */ protected FreezeService freezeService; - - /** model security service */ + + /** Model security service */ protected ModelSecurityService modelSecurityService; - + + /** Record folder service */ + protected RecordFolderService recordFolderService; + /** List of kinds for which this action is applicable */ protected Set applicableKinds = new HashSet(); - + /** * Set the namespace service */ @@ -135,7 +135,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.transactionService = transactionService; } - + /** * Set the namespace service */ @@ -143,7 +143,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.namespaceService = namespaceService; } - + /** * Set node service */ @@ -151,7 +151,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.nodeService = nodeService; } - + /** * Set the dictionary service */ @@ -159,7 +159,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.dictionaryService = dictionaryService; } - + /** * Set the content service */ @@ -167,9 +167,9 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.contentService = contentService; } - + /** - * Set action service + * Set action service */ public void setActionService(ActionService actionService) { @@ -191,15 +191,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.recordsManagementActionService = recordsManagementActionService; } - - /** - * Set records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - + /** * Set the disposition service */ @@ -207,7 +199,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.dispositionService = dispositionService; } - + /** * @param vitalRecordService vital record service */ @@ -215,16 +207,16 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.vitalRecordService = vitalRecordService; } - - /** + + /** * Set records management event service */ public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) { this.recordsManagementEventService = recordsManagementEventService; } - - + + /** * Set the ownable service * @param ownableSerice @@ -233,27 +225,27 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.ownableService = ownableService; } - + /** * Set freeze service - * + * * @param freezeService freeze service */ public void setFreezeService(FreezeService freezeService) { this.freezeService = freezeService; } - + /** * Set record service - * + * * @param recordService record service */ public void setRecordService(RecordService recordService) { this.recordService = recordService; } - + /** * @param recordsManagementAdminService records management admin service */ @@ -269,7 +261,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { return recordsManagementAdminService; } - + /** * @param modelSecurityService model security service */ @@ -278,6 +270,14 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe this.modelSecurityService = modelSecurityService; } + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @param applicableKinds kinds that this action is applicable for */ @@ -288,7 +288,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe this.applicableKinds.add(FilePlanComponentKind.valueOf(kind)); } } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#createActionDefinition(java.lang.String) */ @@ -297,18 +297,18 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { return new RecordsManagementActionDefinitionImpl(name); } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition() */ @Override public ActionDefinition getActionDefinition() { - ActionDefinition actionDefinition = super.getActionDefinition(); - ((RecordsManagementActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds); + ActionDefinition actionDefinition = super.getActionDefinition(); + ((RecordsManagementActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds); return actionDefinition; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getRecordsManagementActionDefinition() */ @@ -333,16 +333,15 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe PropertyCheck.mandatory(this, "transactionService", transactionService); PropertyCheck.mandatory(this, "recordsManagementAuditService", recordsManagementAuditService); PropertyCheck.mandatory(this, "recordsManagementActionService", recordsManagementActionService); - PropertyCheck.mandatory(this, "recordsManagementService", recordsManagementService); PropertyCheck.mandatory(this, "recordsManagementAdminService", recordsManagementAdminService); PropertyCheck.mandatory(this, "recordsManagementEventService", recordsManagementEventService); - + super.init(); } - + /** * Indicates whether this records management action is public or not - * + * * @return boolean true if public, false otherwise */ @Override @@ -350,7 +349,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { return publicAction; } - + /** * @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String) */ @@ -359,7 +358,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { this.name = name; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName() */ @@ -367,49 +366,49 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { return this.name; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel() */ public String getLabel() { String label = I18NUtil.getMessage(this.getTitleKey()); - + if (label == null) { // default to the name of the action with first letter capitalised label = StringUtils.capitalize(this.name); } - + return label; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription() */ public String getDescription() { String desc = I18NUtil.getMessage(this.getDescriptionKey()); - + if (desc == null) { // default to the name of the action with first letter capitalised desc = StringUtils.capitalize(this.name); } - + return desc; } /** * By default an action is not a disposition action - * + * * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#isDispositionAction() */ public boolean isDispositionAction() { return false; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#execute(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) */ @@ -418,7 +417,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe // Create the action Action action = this.actionService.createAction(name); action.setParameterValues(parameters); - + // disable model security whilst we execute the RM rule modelSecurityService.disable(); try @@ -430,20 +429,20 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { modelSecurityService.enable(); } - + // Get the result Object value = action.getParameterValue(ActionExecuterAbstractBase.PARAM_RESULT); return new RecordsManagementActionResult(value); } - + /** * Function to pad a string with zero '0' characters to the required length - * + * * @param s String to pad with leading zero '0' characters * @param len Length to pad to - * + * * @return padded string or the original if already at >=len characters - * + * * @deprecated As of 2.1, replaced by {@link org.apache.commons.lang.StringUtils.leftPad} */ @Deprecated @@ -455,11 +454,11 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe result = "0" + result; } return result; - } - + } + /** * By default there are no parameters. - * + * * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List) */ @Override @@ -495,17 +494,17 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe currentDispositionAction = assocs.get(0).getChildRef(); } } - + if (currentDispositionAction != null) { // Move it to the history association this.nodeService.moveNode(currentDispositionAction, nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, ASSOC_DISPOSITION_ACTION_HISTORY); } - + List dispositionActionDefinitions = di.getDispositionActionDefinitions(); DispositionActionDefinition currentDispositionActionDefinition = null; DispositionActionDefinition nextDispositionActionDefinition = null; - + if (currentDispositionAction == null) { if (dispositionActionDefinitions.isEmpty() == false) @@ -519,7 +518,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe // Get the current action String currentADId = (String)this.nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID); currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId); - + // Get the next disposition action int index = currentDispositionActionDefinition.getIndex(); index++; @@ -528,7 +527,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe nextDispositionActionDefinition = dispositionActionDefinitions.get(index); } } - + if (nextDispositionActionDefinition != null) { if (this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) == false) @@ -536,40 +535,40 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe // Add the disposition life cycle aspect this.nodeService.addAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE, null); } - + // Create the properties Map props = new HashMap(10); - + // Calculate the asOf date Date asOfDate = null; Period period = nextDispositionActionDefinition.getPeriod(); if (period != null) { Date contextDate = null; - + // Get the period properties value QName periodProperty = nextDispositionActionDefinition.getPeriodProperty(); - if (periodProperty != null && + if (periodProperty != null && RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty) == false) { // doesn't matter if the period property isn't set ... the asOfDate will get updated later // when the value of the period property is set - contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); + contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); } else { - // for now use 'NOW' as the default context date + // for now use 'NOW' as the default context date // TODO set the default period property ... cut off date or last disposition date depending on context contextDate = new Date(); } - + // Calculate the as of date if (contextDate != null) { asOfDate = period.getNextDate(contextDate); } - } - + } + // Set the property values props.put(PROP_DISPOSITION_ACTION_ID, nextDispositionActionDefinition.getId()); props.put(PROP_DISPOSITION_ACTION, nextDispositionActionDefinition.getName()); @@ -577,15 +576,15 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe { props.put(PROP_DISPOSITION_AS_OF, asOfDate); } - + // Create a new disposition action object NodeRef dispositionActionNodeRef = this.nodeService.createNode( - nodeRef, - ASSOC_NEXT_DISPOSITION_ACTION, - ASSOC_NEXT_DISPOSITION_ACTION, + nodeRef, + ASSOC_NEXT_DISPOSITION_ACTION, + ASSOC_NEXT_DISPOSITION_ACTION, TYPE_DISPOSITION_ACTION, - props).getChildRef(); - + props).getChildRef(); + // Create the events List events = nextDispositionActionDefinition.getEvents(); for (RecordsManagementEvent event : events) @@ -596,10 +595,10 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe } } } - + /** * Creates the given records management event for the given 'next action'. - * + * * @param event The event to create * @param nextActionNodeRef The next action node * @return The created event NodeRef @@ -607,32 +606,32 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe protected NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef) { NodeRef eventNodeRef = null; - + Map eventProps = new HashMap(7); eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName()); // TODO display label RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType()); eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent()); eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false); - + // Create the event execution object this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS, ASSOC_EVENT_EXECUTIONS, TYPE_EVENT_EXECUTION, eventProps); - + return eventNodeRef; } - + /** * Calculates and updates the rma:dispositionEventsEligible * property for the given next disposition action. - * + * * @param nextAction The next disposition action * @return The result of calculation */ protected boolean updateEventEligible(DispositionAction nextAction) { List events = nextAction.getEventCompletionDetails(); - + boolean eligible = false; if (nextAction.getDispositionActionDefinition().eligibleOnFirstCompleteEvent() == false) { @@ -657,12 +656,12 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe } } } - + // Update the property with the eligible value this.nodeService.setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible); - + return eligible; } - - + + } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java index 0f6b36ce8f..0564e46dc4 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDispositionActionExecuterAbstractBase.java @@ -46,13 +46,13 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx private static final String MSG_NEXT_DISP_NOT_SET = "rm.action.next-disp-not-set"; private static final String MSG_NOT_NEXT_DISP = "rm.action.not-next-disp"; private static final String MSG_NOT_RECORD_FOLDER = "rm.action.not-record-folder"; - + /** Parameter value indicating whether we should be doing non-error raising state checks */ public static final String PARAM_NO_ERROR_CHECK = "rm.no-error-check"; /** * All children of this implementation are disposition actions. - * + * * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isDispositionAction() */ @Override @@ -63,28 +63,28 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx /** * Indicates whether the disposition is marked complete - * + * * @return boolean true if marked complete, false otherwise */ public boolean getSetDispositionActionComplete() { return true; } - + /** * Indicates whether we should validate the next disposition action is the action we are * trying to execute. - * + * * @return */ protected boolean checkNextDispositionAction(NodeRef actionedUponNodeRef) { return true; } - + /** * Indicated whether we should validate the disposition action is eligible or not. - * + * * @param actionedUponNodeRef * @return */ @@ -101,7 +101,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { NodeRef nextDispositionActionNodeRef = getNextDispostionAction(actionedUponNodeRef); - + // determine whether we should be raising errors during state checking or not boolean checkError = true; Boolean checkErrorValue = (Boolean)action.getParameterValue(PARAM_NO_ERROR_CHECK); @@ -109,14 +109,14 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx { checkError = checkErrorValue.booleanValue(); } - + // Check the validity of the action (is it the next action, are we dealing with the correct type of object for // the disposition level? DispositionSchedule di = checkDispositionActionExecutionValidity(actionedUponNodeRef, nextDispositionActionNodeRef, checkError); if (di != null) { // Check the eligibility of the action - if (checkEligibility(actionedUponNodeRef) == false || + if (checkEligibility(actionedUponNodeRef) == false || dispositionService.isNextDispositionActionEligible(actionedUponNodeRef) == true) { if (di.isRecordLevelDisposition() == true) @@ -128,17 +128,17 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx if (recordService.isDeclared(actionedUponNodeRef) == true) { // Indicate that the disposition action is underway - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); - + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); + // Execute record level disposition executeRecordLevelDisposition(action, actionedUponNodeRef); - - if (this.nodeService.exists(nextDispositionActionNodeRef) == true && + + if (nodeService.exists(nextDispositionActionNodeRef) == true && getSetDispositionActionComplete() == true) { - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); } } else @@ -153,24 +153,24 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx } else { - if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) + if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true) { - if (this.recordsManagementService.isRecordFolderDeclared(actionedUponNodeRef) == true) + if (recordFolderService.isRecordFolderDeclared(actionedUponNodeRef) == true) { // Indicate that the disposition action is underway - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); - + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY, AuthenticationUtil.getRunAsUser()); + executeRecordFolderLevelDisposition(action, actionedUponNodeRef); - + // Indicate that the disposition action is compelte - if (this.nodeService.exists(nextDispositionActionNodeRef) == true && + if (nodeService.exists(nextDispositionActionNodeRef) == true && getSetDispositionActionComplete() == true) { - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); - this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); + nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); } - + } else { @@ -181,10 +181,10 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD_FOLDER, getName(), actionedUponNodeRef.toString())); } - + } - - if (this.nodeService.exists(actionedUponNodeRef) == true && getSetDispositionActionComplete() == true) + + if (nodeService.exists(actionedUponNodeRef) == true && getSetDispositionActionComplete() == true) { // Update the disposition schedule updateNextDispositionAction(actionedUponNodeRef); @@ -217,7 +217,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx * @param recordFolder */ protected abstract void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder); - + /** * @param nodeRef * @return @@ -225,7 +225,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx protected DispositionSchedule checkDispositionActionExecutionValidity(NodeRef nodeRef, NodeRef nextDispositionActionNodeRef, boolean throwError) { // Check the node has associated disposition instructions - DispositionSchedule di = this.dispositionService.getDispositionSchedule(nodeRef); + DispositionSchedule di = dispositionService.getDispositionSchedule(nodeRef); if (di == null) { if (throwError) @@ -239,7 +239,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx } // Check the node has the disposition schedule aspect applied - if (this.nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) == false) + if (nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE) == false) { if (throwError) { @@ -253,7 +253,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx if (checkNextDispositionAction(nodeRef) == true) { - // Check this the next disposition action + // Check this the next disposition action NodeRef nextDispositionAction = nextDispositionActionNodeRef; if (nextDispositionAction == null) { @@ -266,7 +266,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx return null; } } - String actionName = (String) this.nodeService.getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION); + String actionName = (String) nodeService.getProperty(nextDispositionAction, PROP_DISPOSITION_ACTION); if (actionName == null || actionName.equals(getName()) == false) { if (throwError) @@ -285,7 +285,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx /** * Get the next disposition action node. Null if none present. - * + * * @param nodeRef * the disposable node reference * @return NodeRef the next disposition action, null if none @@ -293,7 +293,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx private NodeRef getNextDispostionAction(NodeRef nodeRef) { NodeRef result = null; - List assocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL); + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, RegexQNamePattern.MATCH_ALL); if (assocs.size() != 0) { result = assocs.get(0).getChildRef(); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java index b879e35d2a..3c72e53b86 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CloseRecordFolderAction.java @@ -28,7 +28,7 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * Action to close the records folder - * + * * @author Roy Wetherall */ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase @@ -49,7 +49,7 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase @Override protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { - if (nodeService.exists(actionedUponNodeRef) == true && + if (nodeService.exists(actionedUponNodeRef) == true && freezeService.isFrozen(actionedUponNodeRef) == false) { if (recordService.isRecord(actionedUponNodeRef)) @@ -61,12 +61,12 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase } } - if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) + if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true) { - Boolean isClosed = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED); + Boolean isClosed = (Boolean) nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED); if (Boolean.FALSE.equals(isClosed) == true) { - this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, true); + nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, true); } } else diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java index dbeb81e091..12234e62b5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CreateDispositionScheduleAction.java @@ -23,31 +23,25 @@ import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstrac import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Create disposition schedule action - * + * * @author Roy Wetherall */ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBase { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(CreateDispositionScheduleAction.class); - /** file plan service */ private FilePlanService filePlanService; - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -63,5 +57,5 @@ public class CreateDispositionScheduleAction extends RMActionExecuterAbstractBas { throw new AlfrescoRuntimeException("The disposition schedule could not be created, because the actioned upon node was not a record category."); } - } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java index 613c8c840f..60cea916a3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CutOffAction.java @@ -31,14 +31,14 @@ import org.alfresco.service.namespace.QName; /** * Cut off disposition action - * + * * @author Roy Wetherall */ public class CutOffAction extends RMDispositionActionExecuterAbstractBase { /** Action name */ public static final String NAME = "cutoff"; - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -46,17 +46,17 @@ public class CutOffAction extends RMDispositionActionExecuterAbstractBase protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) { // Close folder - Boolean isClosed = (Boolean)this.nodeService.getProperty(recordFolder, PROP_IS_CLOSED); + Boolean isClosed = (Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED); if (Boolean.FALSE.equals(isClosed) == true) { - this.nodeService.setProperty(recordFolder, PROP_IS_CLOSED, true); + nodeService.setProperty(recordFolder, PROP_IS_CLOSED, true); } - + // Mark the folder as cut off doCutOff(recordFolder); - + // Mark all the declared children of the folder as cut off - List records = this.recordsManagementService.getRecords(recordFolder); + List records = recordService.getRecords(recordFolder); for (NodeRef record : records) { doCutOff(record); @@ -70,22 +70,22 @@ public class CutOffAction extends RMDispositionActionExecuterAbstractBase protected void executeRecordLevelDisposition(Action action, NodeRef record) { // Mark the record as cut off - doCutOff(record); + doCutOff(record); } - + /** * Marks the record or record folder as cut off, calculating the cut off date. - * + * * @param nodeRef node reference */ private void doCutOff(NodeRef nodeRef) { - if (this.nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF) == false) + if (nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF) == false) { // Apply the cut off aspect and set cut off date Map cutOffProps = new HashMap(1); cutOffProps.put(PROP_CUT_OFF_DATE, new Date()); - this.nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps); + nodeService.addAspect(nodeRef, ASPECT_CUT_OFF, cutOffProps); } } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java index e2a99bb205..586afa2f79 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/DestroyAction.java @@ -44,28 +44,28 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * Destroy action. - * + * * @author Roy Wetherall */ -public class DestroyAction extends RMDispositionActionExecuterAbstractBase - implements ContentServicePolicies.OnContentUpdatePolicy, +public class DestroyAction extends RMDispositionActionExecuterAbstractBase + implements ContentServicePolicies.OnContentUpdatePolicy, InitializingBean { /** Action name */ public static final String NAME = "destroy"; - + /** I18N */ private static final String MSG_GHOSTED_PROP_UPDATE = "rm.action.ghosted-prop-update"; - + /** Policy component */ private PolicyComponent policyComponent; - + /** Eager content store cleaner */ private EagerContentStoreCleaner eagerContentStoreCleaner; - + /** Capability service */ private CapabilityService capabilityService; - + /** Indicates if ghosting is enabled or not */ private boolean ghostingEnabled = true; @@ -76,7 +76,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { this.policyComponent = policyComponent; } - + /** * @param eagerContentStoreCleaner eager content store cleaner */ @@ -92,7 +92,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { this.capabilityService = capabilityService; } - + /** * @param ghostingEnabled true if ghosting is enabled, false otherwise */ @@ -100,7 +100,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { this.ghostingEnabled = ghostingEnabled; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkNextDispositionAction() */ @@ -109,7 +109,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { return checkForDestroyRecordsCapability(actionedUponNodeRef); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#checkEligibility(org.alfresco.service.cmr.repository.NodeRef) */ @@ -118,9 +118,9 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { return checkForDestroyRecordsCapability(actionedUponNodeRef); } - + /** - * + * * @param actionedUponNodeRef * @return */ @@ -131,7 +131,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { result = false; } - return result; + return result; } /** @@ -140,15 +140,15 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase @Override protected void executeRecordFolderLevelDisposition(Action action, NodeRef recordFolder) { - List records = this.recordsManagementService.getRecords(recordFolder); + List records = recordService.getRecords(recordFolder); for (NodeRef record : records) { executeRecordLevelDisposition(action, record); } - + if (ghostingEnabled == true) { - nodeService.addAspect(recordFolder, ASPECT_GHOSTED, Collections. emptyMap()); + nodeService.addAspect(recordFolder, ASPECT_GHOSTED, Collections. emptyMap()); } else { @@ -164,20 +164,20 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { doDestroy(record); } - + /** * Do the content destroy - * + * * @param nodeRef */ private void doDestroy(NodeRef nodeRef) { // Clear the content clearAllContent(nodeRef); - + // Clear thumbnail content clearThumbnails(nodeRef); - + if (ghostingEnabled == true) { // Add the ghosted aspect @@ -186,13 +186,13 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase else { // If ghosting is not enabled, delete the node - nodeService.deleteNode(nodeRef); + nodeService.deleteNode(nodeRef); } } - + /** * Clear all the content properties - * + * * @param nodeRef */ private void clearAllContent(NodeRef nodeRef) @@ -203,15 +203,15 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase { // Clear the content clearContent(nodeRef, prop); - + // Remove the property this.nodeService.removeProperty(nodeRef, prop); - } + } } - + /** * Clear all the thumbnail information - * + * * @param nodeRef */ @SuppressWarnings("deprecation") @@ -226,7 +226,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase // We want to remove the rn:renditioned aspect, but due to the possibility // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect // applied, we must consider removing it too. - if (nodeService.hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || + if (nodeService.hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || nodeService.hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) { // Add the ghosted aspect to all the renditioned children, so that they will not be archived when the @@ -241,12 +241,12 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase nodeService.deleteNode(child.getChildRef()); } } - } + } } - + /** * Clear a content property - * + * * @param nodeRef * @param contentProperty */ @@ -257,7 +257,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase if (contentData != null && contentData.getContentUrl() != null) { eagerContentStoreCleaner.registerOrphanedContentUrl(contentData.getContentUrl(), true); - } + } } /** @@ -276,7 +276,7 @@ public class DestroyAction extends RMDispositionActionExecuterAbstractBase // Register interest in the onContentUpdate policy policyComponent.bindClassBehaviour( ContentServicePolicies.OnContentUpdatePolicy.QNAME, - ASPECT_GHOSTED, + ASPECT_GHOSTED, new JavaBehaviour(this, "onContentUpdate")); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java index b9a2b8f6b1..9dba95a060 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditDispositionActionAsOfDateAction.java @@ -25,13 +25,11 @@ import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstrac import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** * Edit review as of date action. - * + * * @author Roy Wetherall */ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstractBase @@ -39,11 +37,7 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac /** I18N */ private static final String MSG_VALID_DATE_DISP_ASOF = "rm.action.valid-date-disp-asof"; private static final String MSG_DISP_ASOF_LIFECYCLE_APPLIED = "rm.action.disp-asof-lifecycle-applied"; - - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(EditDispositionActionAsOfDateAction.class); - + /** Action parameters */ public static final String PARAM_AS_OF_DATE = "asOfDate"; @@ -62,11 +56,11 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_VALID_DATE_DISP_ASOF)); } - + // Set the dispostion action as of date DispositionAction da = dispositionService.getNextDispositionAction(actionedUponNodeRef); if (da != null) - { + { nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java index b3a2464e4d..bea0bea7e0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/EditReviewAsOfDateAction.java @@ -24,14 +24,12 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** - * + * * Edit review as of date action - * + * * @author Roy Wetherall */ public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase @@ -39,10 +37,7 @@ public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase /** I18N */ private static final String MSG_SPECIFY_VALID_DATE = "rm.action.specify-avlid-date"; private static final String MSG_REVIEW_DETAILS_ONLY = "rm.action.review-details-only"; - - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(EditReviewAsOfDateAction.class); - + public static final String PARAM_AS_OF_DATE = "asOfDate"; /** @@ -61,14 +56,14 @@ public class EditReviewAsOfDateAction extends RMActionExecuterAbstractBase { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SPECIFY_VALID_DATE)); } - - // Set the as of date + + // Set the as of date this.nodeService.setProperty(actionedUponNodeRef, PROP_REVIEW_AS_OF, reviewAsOf); - + } else { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY)); + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_REVIEW_DETAILS_ONLY)); } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java index ff313f5269..e2ccffcc00 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FileToAction.java @@ -20,7 +20,7 @@ import org.springframework.util.StringUtils; /** * File To action implementation. - * + * * @author Roy Wetherall * @since 2.1 */ @@ -28,18 +28,18 @@ public class FileToAction extends RMActionExecuterAbstractBase { /** action name */ public static final String NAME = "fileTo"; - + /** action parameters */ public static final String PARAM_DESTINATION_RECORD_FOLDER = "destinationRecordFolder"; public static final String PARAM_PATH = "path"; public static final String PARAM_CREATE_RECORD_FOLDER = "createRecordFolder"; - + /** file folder service */ private FileFolderService fileFolderService; - + /** file plan service */ private FilePlanService filePlanService; - + /** * @param fileFolderService file folder service */ @@ -47,7 +47,7 @@ public class FileToAction extends RMActionExecuterAbstractBase { this.fileFolderService = fileFolderService; } - + /** * @param filePlanService file plan service */ @@ -55,7 +55,7 @@ public class FileToAction extends RMActionExecuterAbstractBase { this.filePlanService = filePlanService; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) */ @@ -65,7 +65,7 @@ public class FileToAction extends RMActionExecuterAbstractBase paramList.add(new ParameterDefinitionImpl(PARAM_PATH, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_PATH))); paramList.add(new ParameterDefinitionImpl(PARAM_CREATE_RECORD_FOLDER, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_CREATE_RECORD_FOLDER))); } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -84,15 +84,15 @@ public class FileToAction extends RMActionExecuterAbstractBase // get the reference to the record folder based on the relative path recordFolder = createOrResolveRecordFolder(action, actionedUponNodeRef); } - + if (recordFolder == null) { throw new AlfrescoRuntimeException("Unable to execute file to action, because the destination record folder could not be determined."); } - - if (recordsManagementService.isRecordFolder(recordFolder) == true) + + if (recordFolderService.isRecordFolder(recordFolder) == true) { - final NodeRef finalRecordFolder = recordFolder; + final NodeRef finalRecordFolder = recordFolder; try { fileFolderService.move(actionedUponNodeRef, finalRecordFolder, null); @@ -109,9 +109,9 @@ public class FileToAction extends RMActionExecuterAbstractBase } } } - + /** - * + * * @param action * @param actionedUponNodeRef * @return @@ -119,8 +119,8 @@ public class FileToAction extends RMActionExecuterAbstractBase private NodeRef createOrResolveRecordFolder(Action action, NodeRef actionedUponNodeRef) { // TODO check the action for a context node reference - // the file plan node always provides the context - NodeRef context = filePlanService.getFilePlan(actionedUponNodeRef); + // the file plan node always provides the context + NodeRef context = filePlanService.getFilePlan(actionedUponNodeRef); if (context == null) { throw new AlfrescoRuntimeException("Unable to execute fileTo action, because the path resolution context could not be found."); @@ -129,16 +129,16 @@ public class FileToAction extends RMActionExecuterAbstractBase { throw new AlfrescoRuntimeException("Unable to execute fileTo action, because the context for the relative path does not exist."); } - + // look for the path parameter String path = (String)action.getParameterValue(PARAM_PATH); String[] pathValues = ArrayUtils.EMPTY_STRING_ARRAY; - + if (path != null && path.isEmpty() == false) { pathValues = StringUtils.tokenizeToStringArray(path, "/", false, true); } - + // look for the creation strategy boolean create = false; Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_FOLDER); @@ -146,10 +146,10 @@ public class FileToAction extends RMActionExecuterAbstractBase { create = createValue.booleanValue(); } - + // try and get child NodeRef recordFolder = resolvePath(context, pathValues); - + if (recordFolder == null) { if (create == true) @@ -160,28 +160,28 @@ public class FileToAction extends RMActionExecuterAbstractBase { throw new AlfrescoRuntimeException("Unable to create new record folder, because destination parent could not be found."); } - + // ensure we are trying to create a record folder in a record category if (filePlanService.isRecordCategory(parent) == false) { throw new AlfrescoRuntimeException("Unable to create nre record folder, beacuse the parent is not a record category."); } - + // get the new record folders name String recordFolderName = pathValues[pathValues.length-1]; - recordFolder = recordsManagementService.createRecordFolder(parent, recordFolderName); + recordFolder = recordFolderService.createRecordFolder(parent, recordFolderName); } else { throw new AlfrescoRuntimeException("Unable to execute FileTo action, because the destination record folder does not exist."); - } + } } - - return recordFolder; + + return recordFolder; } - + /** - * + * * @param context * @param pathValues * @return @@ -197,16 +197,16 @@ public class FileToAction extends RMActionExecuterAbstractBase catch (FileNotFoundException e) { // ignore, checking for null - } + } if (fileInfo != null) { result = fileInfo.getNodeRef(); } return result; } - + /** - * + * * @param context * @param pathValues * @return @@ -214,10 +214,10 @@ public class FileToAction extends RMActionExecuterAbstractBase private NodeRef resolveParent(NodeRef context, String[] pathValues) { NodeRef result = null; - + if (ArrayUtils.isEmpty(pathValues) == true) { - // this should never occur since if the path is empty then the context it the resolution of the + // this should never occur since if the path is empty then the context it the resolution of the // path .. the context must already exist throw new AlfrescoRuntimeException("Unable to resolve the parent, because no valid path was specified."); } @@ -231,9 +231,9 @@ public class FileToAction extends RMActionExecuterAbstractBase pathValues = (String[])ArrayUtils.remove(pathValues, pathValues.length-1); result = resolvePath(context, pathValues); } - + return result; } - + } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java index 9648d2a4cc..36ee27dda1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/FreezeAction.java @@ -30,14 +30,14 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Freeze Action - * + * * @author Roy Wetherall */ public class FreezeAction extends RMActionExecuterAbstractBase { /** Parameter names */ public static final String PARAM_REASON = "reason"; - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List) */ @@ -46,7 +46,7 @@ public class FreezeAction extends RMActionExecuterAbstractBase { paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REASON))); } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -57,7 +57,7 @@ public class FreezeAction extends RMActionExecuterAbstractBase if (nodeService.exists(actionedUponNodeRef) == true && nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_PENDING_DELETE) == false && (recordService.isRecord(actionedUponNodeRef) == true || - recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) && + recordFolderService.isRecordFolder(actionedUponNodeRef) == true) && freezeService.isFrozen(actionedUponNodeRef) == false) { freezeService.freeze((String) action.getParameterValue(PARAM_REASON), actionedUponNodeRef); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java index 3dcd4e3692..fd1f612530 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/OpenRecordFolderAction.java @@ -28,7 +28,7 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * Action to re-open the records folder - * + * * @author Roy Wetherall */ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase @@ -38,7 +38,7 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase /** I18N */ private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder"; - + /** Parameter names */ public static final String PARAM_OPEN_PARENT = "openParent"; @@ -54,7 +54,7 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase { // TODO move re-open logic into a service method // TODO check that the user in question has the correct permission to re-open a records folder - + if (recordService.isRecord(actionedUponNodeRef)) { ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef); @@ -63,13 +63,13 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase actionedUponNodeRef = assocRef.getParentRef(); } } - - if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) + + if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true) { - Boolean isClosed = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED); + Boolean isClosed = (Boolean) nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED); if (Boolean.TRUE.equals(isClosed) == true) { - this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false); + nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false); } } else diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java index 81c8fb97c6..92d923ce5d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferAction.java @@ -43,23 +43,23 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * Transfer action - * + * * @author Roy Wetherall */ public class TransferAction extends RMDispositionActionExecuterAbstractBase -{ +{ /** Transfer node reference key */ public static final String KEY_TRANSFER_NODEREF = "transferNodeRef"; - + /** I18N */ private static final String MSG_NODE_ALREADY_TRANSFER = "rm.action.node-already-transfer"; - + /** Indicates whether the transfer is an accession or not */ private boolean isAccession = false; - + /** File plan service */ private FilePlanService filePlanService; - + /** * @param filePlanService file plan service */ @@ -67,20 +67,20 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase { this.filePlanService = filePlanService; } - + /** * Indicates whether this transfer is an accession or not - * + * * @param isAccession */ public void setIsAccession(boolean isAccession) { this.isAccession = isAccession; } - + /** * Do not set the transfer action to auto-complete - * + * * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#getSetDispositionActionComplete() */ @Override @@ -88,7 +88,7 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase { return false; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase#executeRecordFolderLevelDisposition(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -106,31 +106,31 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase { doTransfer(action, record); } - + /** * Create the transfer node and link the disposition lifecycle node beneath it - * + * * @param dispositionLifeCycleNodeRef disposition lifecycle node */ private void doTransfer(Action action, NodeRef dispositionLifeCycleNodeRef) { // Get the root rm node NodeRef root = filePlanService.getFilePlan(dispositionLifeCycleNodeRef); - + // Get the transfer object - NodeRef transferNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); + NodeRef transferNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF); if (transferNodeRef == null) { // Calculate a transfer name QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid"); Long dbId = (Long)this.nodeService.getProperty(dispositionLifeCycleNodeRef, nodeDbid); String transferName = StringUtils.leftPad(dbId.toString(), 10, "0"); - + // Create the transfer object Map transferProps = new HashMap(2); transferProps.put(ContentModel.PROP_NAME, transferName); transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, this.isAccession); - + // setup location property from disposition schedule DispositionAction da = dispositionService.getNextDispositionAction(dispositionLifeCycleNodeRef); if (da != null) @@ -141,57 +141,57 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation()); } } - + NodeRef transferContainer = filePlanService.getTransferContainer(root); - transferNodeRef = this.nodeService.createNode(transferContainer, - ContentModel.ASSOC_CONTAINS, - QName.createQName(RM_URI, transferName), + transferNodeRef = this.nodeService.createNode(transferContainer, + ContentModel.ASSOC_CONTAINS, + QName.createQName(RM_URI, transferName), TYPE_TRANSFER, transferProps).getChildRef(); - + // Bind the hold node reference to the transaction AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef); } else { - // ensure this node has not already in the process of being transferred + // ensure this node has not already in the process of being transferred List transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED); for(ChildAssociationRef car : transferredAlready) { if(car.getChildRef().equals(dispositionLifeCycleNodeRef) == true) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, dispositionLifeCycleNodeRef.toString())); - + } } } - + // Link the record to the trasnfer object - this.nodeService.addChild(transferNodeRef, - dispositionLifeCycleNodeRef, - ASSOC_TRANSFERRED, + this.nodeService.addChild(transferNodeRef, + dispositionLifeCycleNodeRef, + ASSOC_TRANSFERRED, ASSOC_TRANSFERRED); - + // Set PDF indicator flag setPDFIndicationFlag(transferNodeRef, dispositionLifeCycleNodeRef); - + // Set the transferring indicator aspect nodeService.addAspect(dispositionLifeCycleNodeRef, ASPECT_TRANSFERRING, null); - + // Set the return value of the action action.setParameterValue(ActionExecuter.PARAM_RESULT, transferNodeRef); } - + /** - * + * * @param transferNodeRef * @param dispositionLifeCycleNodeRef */ private void setPDFIndicationFlag(NodeRef transferNodeRef, NodeRef dispositionLifeCycleNodeRef) { - if (recordsManagementService.isRecordFolder(dispositionLifeCycleNodeRef) == true) + if (recordFolderService.isRecordFolder(dispositionLifeCycleNodeRef) == true) { - List records = recordsManagementService.getRecords(dispositionLifeCycleNodeRef); + List records = recordService.getRecords(dispositionLifeCycleNodeRef); for (NodeRef record : records) { setPDFIndicationFlag(transferNodeRef, record); @@ -205,7 +205,7 @@ public class TransferAction extends RMDispositionActionExecuterAbstractBase { // Set the property indicator nodeService.setProperty(transferNodeRef, PROP_TRANSFER_PDF_INDICATOR, true); - } + } } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java index ddbf9b0975..5b72524dbb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/TransferCompleteAction.java @@ -35,7 +35,7 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * Transfer complete action - * + * * @author Roy Wetherall */ public class TransferCompleteAction extends RMActionExecuterAbstractBase @@ -55,7 +55,7 @@ public class TransferCompleteAction extends RMActionExecuterAbstractBase { boolean accessionIndicator = ((Boolean)nodeService.getProperty(actionedUponNodeRef, PROP_TRANSFER_ACCESSION_INDICATOR)).booleanValue(); String transferLocation = nodeService.getProperty(actionedUponNodeRef, PROP_TRANSFER_LOCATION).toString(); - + List assocs = this.nodeService.getChildAssocs(actionedUponNodeRef, ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : assocs) { @@ -82,7 +82,7 @@ public class TransferCompleteAction extends RMActionExecuterAbstractBase /** * Marks the node complete - * + * * @param nodeRef * disposition lifecycle node reference */ @@ -95,11 +95,11 @@ public class TransferCompleteAction extends RMActionExecuterAbstractBase nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date()); nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser()); } - + // Remove the transferring indicator aspect nodeService.removeAspect(nodeRef, ASPECT_TRANSFERRING); nodeService.setProperty(nodeRef, PROP_LOCATION, transferLocation); - + // Determine which marker aspect to use QName markerAspectQName = null; if (accessionIndicator == true) @@ -110,12 +110,12 @@ public class TransferCompleteAction extends RMActionExecuterAbstractBase { markerAspectQName = ASPECT_TRANSFERRED; } - + // Mark the object and children accordingly nodeService.addAspect(nodeRef, markerAspectQName, null); - if (recordsManagementService.isRecordFolder(nodeRef) == true) + if (recordFolderService.isRecordFolder(nodeRef) == true) { - List records = recordsManagementService.getRecords(nodeRef); + List records = recordService.getRecords(nodeRef); for (NodeRef record : records) { nodeService.addAspect(record, markerAspectQName, null); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java index de8cb0c283..1db93650dc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/UnCutoffAction.java @@ -58,9 +58,9 @@ public class UnCutoffAction extends RMActionExecuterAbstractBase // Remove the cutoff aspect nodeService.removeAspect(actionedUponNodeRef, ASPECT_CUT_OFF); - if (recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) + if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true) { - List records = this.recordsManagementService.getRecords(actionedUponNodeRef); + List records = recordService.getRecords(actionedUponNodeRef); for (NodeRef record : records) { nodeService.removeAspect(record, ASPECT_CUT_OFF); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index b8dc7410a3..0aeace6f76 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -36,7 +36,6 @@ 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.action.RecordsManagementAction; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent; @@ -97,10 +96,10 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean private static Log logger = LogFactory.getLog(RecordsManagementAuditServiceImpl.class); private static final String KEY_RM_AUDIT_NODE_RECORDS = "RMAUditNodeRecords"; - + protected static final String RM_AUDIT_EVENT_LOGIN_SUCCESS = "Login.Success"; protected static final String RM_AUDIT_EVENT_LOGIN_FAILURE = "Login.Failure"; - + protected static final String RM_AUDIT_APPLICATION_NAME = "RM"; protected static final String RM_AUDIT_PATH_ROOT = "/RM"; protected static final String RM_AUDIT_SNIPPET_EVENT = "/event"; @@ -125,7 +124,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean protected static final String RM_AUDIT_DATA_LOGIN_USERNAME = "/RM/login/args/userName/value"; protected static final String RM_AUDIT_DATA_LOGIN_FULLNAME = "/RM/login/no-error/fullName"; protected static final String RM_AUDIT_DATA_LOGIN_ERROR = "/RM/login/error/value"; - + /* Provide Backward compatibility with DOD5015 Audit Events RM-904*/ protected static final String DOD5015_AUDIT_APPLICATION_NAME = "DOD5015"; protected static final String DOD5015_AUDIT_PATH_ROOT = "/DOD5015"; @@ -156,7 +155,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean protected static final String AUDIT_TRAIL_FILE_PREFIX = "audit_"; protected static final String AUDIT_TRAIL_JSON_FILE_SUFFIX = ".json"; protected static final String AUDIT_TRAIL_HTML_FILE_SUFFIX = ".html"; - + /** Audit auditing events */ private static final String AUDIT_EVENT_START = "audit.start"; private static final String MSG_AUDIT_START = "rm.audit.audit-start"; @@ -174,7 +173,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean private ContentService contentService; private AuditComponent auditComponent; private AuditService auditService; - private RecordsManagementService rmService; private RecordsManagementActionService rmActionService; private FilePlanService filePlanService; private NamespaceService namespaceService; @@ -246,14 +244,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean this.auditService = auditService; } - /** - * Set the RecordsManagementService - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * Sets the RecordsManagementActionService instance */ @@ -294,7 +284,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { registerAuditEvent(new AuditEvent(name, label)); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#registerAuditEvent(org.alfresco.module.org_alfresco_module_rm.audit.event.AuditEvent) */ @@ -305,7 +295,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { logger.debug("Registering audit event " + auditEvent.getName()); } - + this.auditEvents.put(auditEvent.getName(), auditEvent); } @@ -320,11 +310,10 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean PropertyCheck.mandatory(this, "contentService", contentService); PropertyCheck.mandatory(this, "auditComponent", auditComponent); PropertyCheck.mandatory(this, "auditService", auditService); - PropertyCheck.mandatory(this, "rmService", rmService); PropertyCheck.mandatory(this, "rmActionService", rmActionService); PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); PropertyCheck.mandatory(this, "filePlanService", filePlanService); - + // register audit auditing events registerAuditEvent(AUDIT_EVENT_CLEAR, MSG_AUDIT_CLEAR); registerAuditEvent(AUDIT_EVENT_START, MSG_AUDIT_START); @@ -385,7 +374,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { logger.info("Started Records Management auditing"); } - + auditEvent(filePlan, AUDIT_EVENT_START, null, null, true); } @@ -396,18 +385,18 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { ParameterCheck.mandatory("filePlan", filePlan); // TODO use file plan to scope audit log - + auditEvent(filePlan, AUDIT_EVENT_STOP, null, null, true); auditService.disableAudit( RM_AUDIT_APPLICATION_NAME, RM_AUDIT_PATH_ROOT); - + if (logger.isInfoEnabled()) { logger.info("Stopped Records Management auditing"); } - } + } /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#clearAuditLog(org.alfresco.service.cmr.repository.NodeRef) @@ -423,9 +412,9 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { logger.debug("Records Management audit log has been cleared"); } - + auditEvent(filePlan, AUDIT_EVENT_CLEAR, null, null, true); - } + } /** * {@inheritDoc} @@ -451,7 +440,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean // TODO: return proper date, for now it's today's date return getEndOfDay(new Date()); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) */ @@ -460,7 +449,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { auditEvent(nodeRef, eventName, null, null, false, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map) */ @@ -469,16 +458,16 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { auditEvent(nodeRef, eventName, before, after, false, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) */ @Override - public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate) + public void auditEvent(NodeRef nodeRef, String eventName, Map before, Map after, boolean immediate) { auditEvent(nodeRef, eventName, before, after, immediate, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService#auditEvent(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map, java.util.Map, boolean) */ @@ -495,7 +484,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { Set auditDetails = TransactionalResourceHelper.getSet(KEY_RM_AUDIT_NODE_RECORDS); AlfrescoTransactionSupport.bindListener(txnListener); - + // RM-936: Eliminate multiple audit maps from being generated when events with the same name are required to be fired multiple times in the same transaction. // Check if auditDetails already contains an auditedNode with the same combination of nodeRef and eventName. boolean auditNodeAlreadyExists = false; @@ -543,14 +532,14 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean RM_AUDIT_SNIPPET_EVENT, RM_AUDIT_SNIPPET_NAME), eventName); - + if (nodeRef != null) { auditMap.put( AuditApplication.buildPath( RM_AUDIT_SNIPPET_EVENT, RM_AUDIT_SNIPPET_NODE), - nodeRef); + nodeRef); } // Filter out any properties to be audited if specified in the Spring configuration. @@ -558,7 +547,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { removeAuditProperties(ignoredAuditProperties, propertiesBefore, propertiesAfter); } - + // Property changes Pair, Map> deltaPair = PropertyMap.getBeforeAndAfterMapsForChanges(propertiesBefore, propertiesAfter); @@ -566,8 +555,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean if (deltaPair.getFirst().isEmpty() && deltaPair.getSecond().isEmpty() && removeOnNoPropertyChange == true) { auditMap.clear(); - } - else + } + else { auditMap.put( AuditApplication.buildPath( @@ -583,13 +572,13 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean RM_AUDIT_SNIPPET_CHANGES, RM_AUDIT_SNIPPET_AFTER), (Serializable) deltaPair.getSecond()); - } + } return auditMap; } /** * Helper method to remove system properties from maps - * + * * @param properties */ private void removeAuditProperties(List ignoredAuditProperties, Map before, Map after) @@ -608,7 +597,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean * A stateless transaction listener for RM auditing. This component picks up the data of modified nodes and generates the audit information. *

* This class is not static so that the instances will have access to the action's implementation. - * + * * @author Derek Hulley * @since 3.2 */ @@ -649,7 +638,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean private void auditInTxn(Set auditedNodes) throws Throwable { // Go through all the audit information and audit it - boolean auditedSomething = false; + boolean auditedSomething = false; for (RMAuditNode auditedNode : auditedNodes) { NodeRef nodeRef = auditedNode.getNodeRef(); @@ -661,9 +650,9 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean } // build the audit map - Map auditMap = buildAuditMap(nodeRef, - auditedNode.getEventName(), - auditedNode.getNodePropertiesBefore(), + Map auditMap = buildAuditMap(nodeRef, + auditedNode.getEventName(), + auditedNode.getNodePropertiesBefore(), auditedNode.getNodePropertiesAfter(), auditedNode.getRemoveIfNoPropertyChanged()); // Audit it @@ -770,7 +759,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { logger.debug("Retrieving audit trail in '" + reportFormat + "' format using parameters: " + params); } - + // define the callback AuditQueryCallback callback = new AuditQueryCallback() { @@ -853,7 +842,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean namePath = (String) values.get(DOD5015_AUDIT_DATA_NODE_NAMEPATH); beforeProperties = (Map) values.get( DOD5015_AUDIT_DATA_NODE_CHANGES_BEFORE); afterProperties = (Map) values.get(DOD5015_AUDIT_DATA_NODE_CHANGES_AFTER); - + // Convert some of the values to recognizable forms nodeType = null; if (nodeTypeQname != null) @@ -998,7 +987,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { dod5015AuditQueryParams.addSearchKey(DOD5015_AUDIT_DATA_NODE_NODEREF, nodeRef); } - + // AuditQueryParameters auditQueryParams = new AuditQueryParameters(); auditQueryParams.setForward(forward); @@ -1021,7 +1010,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean // finish off the audit trail report writeAuditTrailFooter(writer, reportFormat); - + // audit that the audit has been view'ed if (nodeRef == null) { @@ -1177,7 +1166,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { List listAuditEvents = new ArrayList(this.auditEvents.size()); listAuditEvents.addAll(this.auditEvents.values()); - Collections.sort(listAuditEvents, new AuditEvent()); + Collections.sort(listAuditEvents, new AuditEvent()); return listAuditEvents; } @@ -1497,7 +1486,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean return label; } - + /** * A class to carry audit information through the transaction. * @@ -1516,12 +1505,12 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { return nodeRef; } - + public void setNodeRef(NodeRef nodeRef) { this.nodeRef = nodeRef; } - + public String getEventName() { return eventName; @@ -1561,13 +1550,13 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { this.removeIfNoPropertyChanged = removeIfNoPropertyChanged; } - } - + } + /** Deprecated Method Implementations **/ - + /** * Helper method to get the default file plan - * + * * @return NodRef default file plan */ private NodeRef getDefaultFilePlan() @@ -1607,7 +1596,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean { stopAuditLog(getDefaultFilePlan()); } - + /** * {@inheritDoc} */ @@ -1633,8 +1622,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean public void clear() { clearAuditLog(getDefaultFilePlan()); - } - + } + /** * {@inheritDoc} * @since 3.2 diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java index 1f8a97f3a1..e62ea702ef 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNamePathDataExtractor.java @@ -22,7 +22,6 @@ import java.io.Serializable; import java.util.List; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.audit.extractor.AbstractDataExtractor; @@ -33,9 +32,9 @@ import org.alfresco.service.cmr.repository.NodeService; * An extractor that extracts the cm:name path from the RM root down to * - and including - the node's own name. This will only extract data if the * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. - * - * @see RecordsManagementService#getNodeRefPath(NodeRef) - * + * + * @see FilePlanService#getNodeRefPath(NodeRef) + * * @author Derek Hulley * @since 3.2 */ @@ -55,7 +54,7 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } @@ -79,17 +78,17 @@ public final class FilePlanNamePathDataExtractor extends AbstractDataExtractor public Serializable extractData(Serializable value) throws Throwable { NodeRef nodeRef = (NodeRef) value; - + // Get path from the RM root List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - + StringBuilder sb = new StringBuilder(128); for (NodeRef pathNodeRef : nodeRefPath) { String name = (String)nodeService.getProperty(pathNodeRef, ContentModel.PROP_NAME); sb.append("/").append(name); } - + // Done return sb.toString(); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java index 121d1d0876..f6a428ffab 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/FilePlanNodeRefPathDataExtractor.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.audit.extractor; import java.io.Serializable; import java.util.List; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.audit.extractor.AbstractDataExtractor; @@ -32,9 +31,9 @@ import org.alfresco.service.cmr.repository.NodeService; * An extractor that extracts the NodeRef path from the RM root down to * - and including - the node itself. This will only extract data if the * node is a {@link RecordsManagementModel#ASPECT_FILE_PLAN_COMPONENT fileplan component}. - * - * @see RecordsManagementService#getNodeRefPath(NodeRef) - * + * + * @see FilePlanService#getNodeRefPath(NodeRef) + * * @author Derek Hulley * @since 1.0 */ @@ -51,7 +50,7 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto this.nodeService = nodeService; } - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } @@ -72,10 +71,10 @@ public final class FilePlanNodeRefPathDataExtractor extends AbstractDataExtracto public Serializable extractData(Serializable value) throws Throwable { NodeRef nodeRef = (NodeRef) value; - + // Get path from the RM root List nodeRefPath = filePlanService.getNodeRefPath(nodeRef); - + // Done return (Serializable) nodeRefPath; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java index 685ad74f41..9cb8eff44d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/AbstractCapability.java @@ -24,8 +24,6 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** @@ -37,10 +35,6 @@ import org.springframework.extensions.surf.util.I18NUtil; public abstract class AbstractCapability extends RMSecurityCommon implements Capability, RecordsManagementModel, RMPermissionModel { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(AbstractCapability.class); - /** Capability service */ protected CapabilityService capabilityService; @@ -115,7 +109,7 @@ public abstract class AbstractCapability extends RMSecurityCommon { title = getName(); } - + } return title; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java index fc90081c1d..a09d665b82 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMSecurityCommon.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.capability; import net.sf.acegisecurity.vote.AccessDecisionVoter; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; @@ -41,27 +40,26 @@ import org.apache.commons.logging.LogFactory; /** * Common security functions. - * + * * TODO move methods to the appropriate services - * + * * @author Roy Wetherall * @since 2.0 */ public class RMSecurityCommon -{ +{ /** No set value */ protected int NOSET_VALUE = -100; - + /** Logger */ private static Log logger = LogFactory.getLog(RMSecurityCommon.class); - + /** Services */ protected NodeService nodeService; //This is the internal NodeService -- no permission checks protected PermissionService permissionService; - protected RecordsManagementService rmService; protected RMCaveatConfigComponent caveatConfigComponent; protected FilePlanService filePlanService; - + /** * @param nodeService node service */ @@ -69,7 +67,7 @@ public class RMSecurityCommon { this.nodeService = nodeService; } - + /** * @param permissionService permission service */ @@ -77,15 +75,7 @@ public class RMSecurityCommon { this.permissionService = permissionService; } - - /** - * @param rmService records management service - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - + /** * @param caveatConfigComponent caveat config service */ @@ -93,7 +83,7 @@ public class RMSecurityCommon { this.caveatConfigComponent = caveatConfigComponent; } - + /** * @param filePlanService file plan service */ @@ -101,10 +91,10 @@ public class RMSecurityCommon { this.filePlanService = filePlanService; } - + /** * Sets a value into the transaction cache - * + * * @param prefix * @param nodeRef * @param value @@ -114,12 +104,12 @@ public class RMSecurityCommon { String user = AuthenticationUtil.getRunAsUser(); AlfrescoTransactionSupport.bindResource(prefix + nodeRef.toString() + user, Integer.valueOf(value)); - return value; + return value; } - + /** * Gets a value from the transaction cache - * + * * @param prefix * @param nodeRef * @return @@ -135,10 +125,10 @@ public class RMSecurityCommon } return result; } - + /** * Check for RM read - * + * * @param nodeRef * @return */ @@ -153,10 +143,10 @@ public class RMSecurityCommon return result; } - + /** * Check for RM read - * + * * @param nodeRef * @param allowDMRead * @return @@ -164,7 +154,7 @@ public class RMSecurityCommon public int checkRead(NodeRef nodeRef, boolean allowDMRead) { int result = AccessDecisionVoter.ACCESS_ABSTAIN; - + if (nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT)== true) { result = checkRmRead(nodeRef); @@ -187,26 +177,26 @@ public class RMSecurityCommon result = AccessDecisionVoter.ACCESS_GRANTED; } } - - return result; - } - + + return result; + } + /** - * + * * @param nodeRef * @return */ public int checkRmRead(NodeRef nodeRef) - { + { int result = getTransactionCache("checkRmRead", nodeRef); if (result != NOSET_VALUE) { return result; } - + // Get the file plan for the node NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - + // Admin role //if (permissionService.hasPermission(filePlan, RMPermissionModel.ROLE_ADMINISTRATOR) == AccessStatus.ALLOWED) //{ @@ -214,7 +204,7 @@ public class RMSecurityCommon // { // logger.debug("\t\tAdmin user, access granted. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); // } - // return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED); + // return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED); // } if (permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS) == AccessStatus.DENIED) @@ -223,7 +213,7 @@ public class RMSecurityCommon { logger.debug("\t\tUser does not have read record permission on node, access denied. (nodeRef=" + nodeRef.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); } - return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); + return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); } if (permissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS) == AccessStatus.DENIED) @@ -232,36 +222,36 @@ public class RMSecurityCommon { logger.debug("\t\tUser does not have view records capability permission on node, access denied. (filePlan=" + filePlan.toString() + ", user=" + AuthenticationUtil.getRunAsUser() + ")"); } - return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); + return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); } if (caveatConfigComponent.hasAccess(nodeRef)) { - return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED); + return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_GRANTED); } else { - return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); + return setTransactionCache("checkRmRead", nodeRef, AccessDecisionVoter.ACCESS_DENIED); } } - + @SuppressWarnings("rawtypes") protected NodeRef getTestNode(MethodInvocation invocation, Class[] params, int position, boolean parent) { NodeRef testNodeRef = null; if (position < 0) { - testNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); + testNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); if (testNodeRef == null) { throw new AlfrescoRuntimeException("Unable to find default file plan node."); } - + if (logger.isDebugEnabled()) { logger.debug("\tPermission test against the file plan node " + nodeService.getPath(testNodeRef)); - } + } } else if (StoreRef.class.isAssignableFrom(params[position])) { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java index 1f6eb5dc23..408055bb2e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/AbstractCapabilityCondition.java @@ -18,43 +18,37 @@ */ package org.alfresco.module.org_alfresco_module_rm.capability.declarative; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; 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.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.security.PermissionService; import org.springframework.beans.factory.BeanNameAware; /** * Abstract capability condition. - * + * * @author Roy Wetherall */ -public abstract class AbstractCapabilityCondition implements CapabilityCondition, +public abstract class AbstractCapabilityCondition implements CapabilityCondition, BeanNameAware, RecordsManagementModel { /** Capability condition name */ protected String name; - + /** Services */ - protected RecordsManagementService rmService; protected RecordService recordService; protected PermissionService permissionService; protected NodeService nodeService; protected FreezeService freezeService; protected FilePlanService filePlanService; - - /** - * @param rmService records management service - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - + protected DispositionService dispositionService; + protected RecordFolderService recordFolderService; + /** * @param recordService record service */ @@ -62,7 +56,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition { this.recordService = recordService; } - + /** * @param permissionService permission service */ @@ -70,7 +64,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition { this.permissionService = permissionService; } - + /** * @param nodeService node service */ @@ -78,7 +72,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition { this.nodeService = nodeService; } - + /** * @param freezeService freeze service */ @@ -86,15 +80,31 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition { this.freezeService = freezeService; } - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#getName() */ @@ -103,7 +113,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition { return name; } - + /** * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String) */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java index 80f81730c6..4d2f77723c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/ClosedCapabilityCondition.java @@ -38,9 +38,9 @@ public class ClosedCapabilityCondition extends AbstractCapabilityCondition public boolean evaluate(NodeRef nodeRef) { boolean result = false; - if (rmService.isRecordFolder(nodeRef) == true) + if (recordFolderService.isRecordFolder(nodeRef) == true) { - result = rmService.isRecordFolderClosed(nodeRef); + result = recordFolderService.isRecordFolderClosed(nodeRef); } else if (recordService.isRecord(nodeRef) == true) { @@ -48,14 +48,14 @@ public class ClosedCapabilityCondition extends AbstractCapabilityCondition for (ChildAssociationRef assoc : assocs) { NodeRef parent = assoc.getParentRef(); - if (rmService.isRecordFolder(parent) == true && - rmService.isRecordFolderClosed(parent) == true) + if (recordFolderService.isRecordFolder(parent) == true && + recordFolderService.isRecordFolderClosed(parent) == true) { result = true; break; - } + } } - } + } return result; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java index 37eb259e98..0b647ea23b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/CutoffCapabilityCondition.java @@ -32,7 +32,7 @@ public class CutoffCapabilityCondition extends AbstractCapabilityCondition @Override public boolean evaluate(NodeRef nodeRef) { - return rmService.isCutoff(nodeRef); + return dispositionService.isCutoff(nodeRef); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java index cda0bbf8ea..2d78cc3bc1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/IsRecordFolderCondition.java @@ -38,7 +38,7 @@ public class IsRecordFolderCondition extends AbstractCapabilityCondition { ParameterCheck.mandatory("nodeRef", nodeRef); - return rmService.isRecordFolder(nodeRef); + return recordFolderService.isRecordFolder(nodeRef); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java index a3d5de7236..a35ac33ebb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/MayBeScheduledCapabilityCondition.java @@ -26,17 +26,17 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Indicates whether the given disposition action 'may' be scheduled in the future - * + * * @author Roy Wetherall */ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityCondition { /** Disposition action */ private String dispositionAction; - + /** Disposition service */ private DispositionService dispositionService; - + /** * @param dispositionAction disposition action */ @@ -44,7 +44,7 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi { this.dispositionAction = dispositionAction; } - + /** * @param dispositionService disposition service */ @@ -52,20 +52,20 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi { this.dispositionService = dispositionService; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef) */ @Override public boolean evaluate(NodeRef nodeRef) { - boolean result = false; - + boolean result = false; + DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef); if (dispositionSchedule != null) - { + { if (checkDispositionLevel(nodeRef, dispositionSchedule) == true) - { + { for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions()) { if (dispositionActionDefinition.getName().equals(dispositionAction) == true) @@ -79,10 +79,10 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi } return result; } - + /** * Checks the disposition level - * + * * @param nodeRef * @param dispositionSchedule * @return @@ -95,8 +95,8 @@ public class MayBeScheduledCapabilityCondition extends AbstractCapabilityConditi { result = true; } - else if (rmService.isRecordFolder(nodeRef) == true && isRecordLevelDisposition == false) - + else if (recordFolderService.isRecordFolder(nodeRef) == true && isRecordLevelDisposition == false) + { result = true; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java index 26d1342e50..b8c21b8606 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/declarative/condition/VitalRecordOrFolderCapabilityCondition.java @@ -30,14 +30,14 @@ public class VitalRecordOrFolderCapabilityCondition extends AbstractCapabilityCo @Override public boolean evaluate(NodeRef nodeRef) { - boolean result = false; - + boolean result = false; + if (recordService.isRecord(nodeRef) == true) { // Check the record for the vital record aspect result = nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD); } - else if (rmService.isRecordFolder(nodeRef) == true) + else if (recordFolderService.isRecordFolder(nodeRef) == true) { // Check the folder for the vital record indicator Boolean value = (Boolean)nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_VITAL_RECORD_INDICATOR); @@ -45,8 +45,8 @@ public class VitalRecordOrFolderCapabilityCondition extends AbstractCapabilityCo { result = value.booleanValue(); } - } - + } + return result; } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java index 7304d8b16c..98e05c8e31 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/impl/CreateCapability.java @@ -27,24 +27,31 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.capability.declarative.DeclarativeCapability; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.AccessStatus; import org.alfresco.service.namespace.QName; /** * Create group capability implementation - * + * * @author Andy Hind */ public class CreateCapability extends DeclarativeCapability { private RecordService recordService; - + private RecordFolderService recordFolderService; + public void setRecordService(RecordService recordService) { this.recordService = recordService; } - + + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef) */ @@ -55,7 +62,7 @@ public class CreateCapability extends DeclarativeCapability } /** - * + * * @param destination * @param linkee * @param type @@ -66,7 +73,7 @@ public class CreateCapability extends DeclarativeCapability { if (linkee != null) { - int state = checkRead(linkee, true); + int state = checkRead(linkee, true); if (state != AccessDecisionVoter.ACCESS_GRANTED) { return AccessDecisionVoter.ACCESS_DENIED; @@ -84,7 +91,7 @@ public class CreateCapability extends DeclarativeCapability { return AccessDecisionVoter.ACCESS_GRANTED; } - } + } } else { @@ -96,31 +103,31 @@ public class CreateCapability extends DeclarativeCapability } } } - + } - + // Build the conditions map Map conditions = new HashMap(5); conditions.put("capabilityCondition.filling", Boolean.TRUE); - conditions.put("capabilityCondition.frozen", Boolean.FALSE); + conditions.put("capabilityCondition.frozen", Boolean.FALSE); conditions.put("capabilityCondition.closed", Boolean.FALSE); - conditions.put("capabilityCondition.cutoff", Boolean.FALSE); - + conditions.put("capabilityCondition.cutoff", Boolean.FALSE); + if (checkConditions(destination, conditions) == true) { - if (rmService.isRecordFolder(destination)) + if (recordFolderService.isRecordFolder(destination)) { if (permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED) { return AccessDecisionVoter.ACCESS_GRANTED; } } - } - - conditions.put("capabilityCondition.closed", Boolean.TRUE); + } + + conditions.put("capabilityCondition.closed", Boolean.TRUE); if (checkConditions(destination, conditions) == true) { - if (rmService.isRecordFolder(destination)) + if (recordFolderService.isRecordFolder(destination)) { if (permissionService.hasPermission(filePlanService.getFilePlan(destination), RMPermissionModel.DECLARE_RECORDS_IN_CLOSED_FOLDERS) == AccessStatus.ALLOWED) { @@ -128,12 +135,12 @@ public class CreateCapability extends DeclarativeCapability } } } - + conditions.remove("capabilityCondition.closed"); conditions.put("capabilityCondition.cutoff", Boolean.TRUE); if (checkConditions(destination, conditions) == true) { - if (rmService.isRecordFolder(destination)) + if (recordFolderService.isRecordFolder(destination)) { if (permissionService.hasPermission(filePlanService.getFilePlan(destination), RMPermissionModel.CREATE_MODIFY_RECORDS_IN_CUTOFF_FOLDERS) == AccessStatus.ALLOWED) { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java index 03c4f61460..2d2cb23a1d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/dataset/DataSetServiceImpl.java @@ -22,7 +22,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService 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.model.behaviour.RecordsManagementSearchBehaviour; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServiceImpl; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -41,11 +41,8 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.ParameterCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -public class DataSetServiceImpl implements DataSetService, RecordsManagementModel, ApplicationContextAware +public class DataSetServiceImpl implements DataSetService, RecordsManagementModel { /** Logger */ @@ -87,17 +84,8 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode /** Disposition service */ private DispositionService dispositionService; - /** Application context */ - private ApplicationContext applicationContext; - - /** - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - this.applicationContext = applicationContext; - } + /** Record folder service */ + private RecordFolderService recordFolderService; /** * Set importer service @@ -188,6 +176,16 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode this.dispositionService = dispositionService; } + /** + * Set record folder service + * + * @param recordFolderService the record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.dataset.DataSetService#register(org.alfresco.module.org_alfresco_module_rm.dataset.DataSet) */ @@ -346,11 +344,6 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode /** * Temp method to patch AMP'ed data - * - * @param searchService - * @param nodeService - * @param recordsManagementService - * @param recordsManagementActionService */ private void patchLoadedData() { @@ -445,8 +438,7 @@ public class DataSetServiceImpl implements DataSetService, RecordsManagementMode { // Fire action to "set-up" the folder correctly logger.info("Setting up bootstraped record folder: " + folderName); - RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService"); - recordService.initialiseRecordFolder(recordFolder); + recordFolderService.initialiseRecordFolder(recordFolder); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java index 2885e00fa2..d7a742fd5a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionService.java @@ -29,126 +29,126 @@ import org.alfresco.service.namespace.QName; /** * Disposition service interface. - * + * * @author Roy Wetherall * @since 2.0 */ public interface DispositionService { /** ========= Disposition Property Methods ========= */ - + /** * Register a disposition property. - * + * * @param dispositionProperty disposition property */ void registerDispositionProperty(DispositionProperty dispositionProperty); - + /** * Returns the list of disposition period properties that apply given the context provided. - * + * * @return filtered list of disposition period properties */ Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction); Collection getDispositionProperties(); - - + + /** ========= Disposition Schedule Methods ========= */ - + /** - * Get the disposition schedule for a given record management node. Traverses the hierarchy to + * Get the disposition schedule for a given record management node. Traverses the hierarchy to * find the first disposition schedule in the primary hierarchy. - * + * * @param nodeRef node reference to record category, record folder or record * @return {@link DispositionSchedule} disposition schedule */ DispositionSchedule getDispositionSchedule(NodeRef nodeRef); - + // Gets all the disposition schedules, not just the first in the primary parent path. // TODO List getAllDispositionSchedules(NodeRef nodeRef); - + /** * Get the disposition schedule directly associated with the node specified. Returns * null if none. - * + * * @param nodeRef node reference * @return {@link DispositionSchedule} disposition schedule directly associated with the node reference, null if none */ DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef); - + /** * Gets the records management container that is directly associated with the disposition schedule. - * + * * @param dispositionSchedule disposition schedule * @return {@link NodeRef} node reference of the associated container */ NodeRef getAssociatedRecordsManagementContainer(DispositionSchedule dispositionSchedule); - + /** * Indicates whether a disposition schedule has any disposable items under its management - * + * * @param dispositionSchdule disposition schedule * @return boolean true if there are disposable items being managed by, false otherwise */ boolean hasDisposableItems(DispositionSchedule dispositionSchdule); - + /** - * Gets a list of all the disposable items (records, record folders) that are under the control of + * Gets a list of all the disposable items (records, record folders) that are under the control of * the disposition schedule. - * + * * @param dispositionSchedule disposition schedule * @return {@link List}<{@link NodeRef}> list of disposable items */ List getDisposableItems(DispositionSchedule dispositionSchedule); - + /** * Indicates whether the node is a disposable item or not (ie is under the control of a disposition schedule) - * + * * @param nodeRef node reference * @return boolean true if node is a disposable item, false otherwise */ boolean isDisposableItem(NodeRef nodeRef); - + /** * Creates a disposition schedule on the given record category. - * + * * @param recordCategory * @param props * @return {@link DispositionSchedule} */ DispositionSchedule createDispositionSchedule(NodeRef recordCategory, Map props); - + // TODO DispositionSchedule updateDispositionSchedule(DispositionScedule, Map props) // TODO void removeDispositionSchedule(NodeRef nodeRef); - can only remove if no disposition items - + /** ========= Disposition Action Definition Methods ========= */ - + /** * Adds a new disposition action definition to the given disposition schedule. - * + * * @param schedule The DispositionSchedule to add to * @param actionDefinitionParams Map of parameters to use to create the action definition */ DispositionActionDefinition addDispositionActionDefinition( - DispositionSchedule schedule, + DispositionSchedule schedule, Map actionDefinitionParams); - + /** * Removes the given disposition action definition from the given disposition * schedule. - * + * * @param schedule The DispositionSchedule to remove from * @param actionDefinition The DispositionActionDefinition to remove */ void removeDispositionActionDefinition( - DispositionSchedule schedule, + DispositionSchedule schedule, DispositionActionDefinition actionDefinition); - + /** * Updates the given disposition action definition belonging to the given disposition * schedule. - * + * * @param actionDefinition The DispositionActionDefinition to update * @param actionDefinitionParams Map of parameters to use to update the action definition * @return The updated DispositionActionDefinition @@ -156,48 +156,57 @@ public interface DispositionService DispositionActionDefinition updateDispositionActionDefinition( DispositionActionDefinition actionDefinition, Map actionDefinitionParams); - - + + /** ========= Disposition Action Methods ========= */ - + /** * Indicates whether the next disposition action is eligible or not. - * + * * @param nodeRef node reference to disposable item * @return boolean true if next disposition action is eligible, false otherwise - */ + */ boolean isNextDispositionActionEligible(NodeRef nodeRef); - + /** * Gets the next disposition action for a given node - * + * * @param nodeRef node reference to disposable item * @return DispositionAction next disposition action, null if none */ DispositionAction getNextDispositionAction(NodeRef nodeRef); - + // TODO void startNextDispositionAction(NodeRef nodeRef); - + // TODO void completeNextDispositionAction(NodeRef nodeRef); - - + + /** ========= Disposition Action History Methods ========= */ - + /** * Gets a list of all the completed disposition action in the order they occured. - * - * @param nodeRef record/record folder + * + * @param nodeRef record/record folder * @return List list of completed disposition actions */ List getCompletedDispositionActions(NodeRef nodeRef); - + /** - * Helper method to get the last completed disposition action. Returns null + * Helper method to get the last completed disposition action. Returns null * if there is none. - * + * * @param nodeRef record/record folder * @return DispositionAction last completed disposition action, null if none */ DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); + /** + * Indicates whether the item is cutoff or not. + * + * @param nodeRef node reference + * @return boolean true if the item is cutoff, false otherwise + * + * @since 2.0 + */ + boolean isCutoff(NodeRef nodeRef); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index a3e8882f82..6c1f1391a6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -27,18 +27,19 @@ import java.util.List; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType; 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.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; @@ -56,91 +57,95 @@ import org.springframework.context.ApplicationContextAware; /** * Disposition service implementation. - * + * * @author Roy Wetherall */ -public class DispositionServiceImpl implements - DispositionService, - RecordsManagementModel, +public class DispositionServiceImpl implements + DispositionService, + RecordsManagementModel, ApplicationContextAware, NodeServicePolicies.OnAddAspectPolicy { /** Logger */ private static Log logger = LogFactory.getLog(DispositionServiceImpl.class); - + /** Node service */ private NodeService nodeService; - + /** Dictionary service */ private DictionaryService dictionaryService; - + /** Behaviour filter */ private BehaviourFilter behaviourFilter; - - /** Records management service */ - private RecordsManagementService rmService; - + /** Records management service registry */ private RecordsManagementServiceRegistry serviceRegistry; - + /** Disposition selection strategy */ private DispositionSelectionStrategy dispositionSelectionStrategy; - + /** File plan service */ private FilePlanService filePlanService; - + /** Application context */ private ApplicationContext applicationContext; + /** Record Folder Service */ + // FIXME + //private RecordFolderService recordFolderService; + + /** Record Service */ + private RecordService recordService; + /** Policy component */ private PolicyComponent policyComponent; - + /** Disposition properties */ private Map dispositionProperties = new HashMap(4); - + /** Behaviours */ private JavaBehaviour onAddAspect; - + /** * Set node service - * + * * @param nodeService the node service */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } - + /** * Set the dictionary service - * + * * @param dictionaryServic the dictionary service */ public void setDictionaryService(DictionaryService dictionaryService) { this.dictionaryService = dictionaryService; } - + /** * Set the behaviour filter. - * + * * @param behaviourFilter the behaviour filter */ public void setBehaviourFilter(BehaviourFilter behaviourFilter) { this.behaviourFilter = behaviourFilter; } - + /** * Set the records management service registry - * + * * @param serviceRegistry records management registry service */ public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; } - + /** * @param policyComponent policy component */ @@ -148,30 +153,31 @@ public class DispositionServiceImpl implements { this.policyComponent = policyComponent; } - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + /** - * Get the records management service - * NOTE: have to pull it out of the app context manually to prevent Spring circular dependancy issue - * - * @return + * @param recordFolderService record folder service */ - public RecordsManagementService getRmService() +// public void setRecordFolderService(RecordFolderService recordFolderService) +// { +// this.recordFolderService = recordFolderService; +// } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) { - if (rmService == null) - { - rmService = (RecordsManagementService)applicationContext.getBean("recordsManagementService"); - } - return rmService; + this.recordService = recordService; } - + /** * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ @@ -180,17 +186,17 @@ public class DispositionServiceImpl implements { this.applicationContext = applicationContext; } - + /** * Set the dispositionSelectionStrategy bean. - * + * * @param dispositionSelectionStrategy */ public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy) { this.dispositionSelectionStrategy = dispositionSelectionStrategy; } - + /** * Bean initialisation */ @@ -199,7 +205,7 @@ public class DispositionServiceImpl implements onAddAspect = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT); policyComponent.bindClassBehaviour(NodeServicePolicies.OnAddAspectPolicy.QNAME, ASPECT_DISPOSITION_LIFECYCLE, onAddAspect); } - + /** * Initialises the details of the disposition life cycle */ @@ -211,35 +217,35 @@ public class DispositionServiceImpl implements refreshDispositionAction(nodeRef); } } - + /** * Helper method used to refresh the dispostion action details of the given node. - * + * * @param nodeRef node reference */ public void refreshDispositionAction(NodeRef nodeRef) { ParameterCheck.mandatory("nodeRef", nodeRef); - + // get this disposition instructions for the node DispositionSchedule di = getDispositionSchedule(nodeRef); if (di != null) - { - List dispositionActionDefinitions = di.getDispositionActionDefinitions(); + { + List dispositionActionDefinitions = di.getDispositionActionDefinitions(); if (dispositionActionDefinitions.isEmpty() == false) { // get the first disposition action definition DispositionActionDefinition nextDispositionActionDefinition = dispositionActionDefinitions.get(0); - + // initialise the details of the next disposition action initialiseDispositionAction(nodeRef, nextDispositionActionDefinition); } } - + } - + /** ========= Disposition Property Methods ========= */ - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#registerDispositionProperty(org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty) */ @@ -248,14 +254,14 @@ public class DispositionServiceImpl implements { dispositionProperties.put(dispositionProperty.getQName(), dispositionProperty); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties(boolean, java.lang.String) */ @Override public Collection getDispositionProperties(boolean isRecordLevel, String dispositionAction) { - Collection values = dispositionProperties.values(); + Collection values = dispositionProperties.values(); List result = new ArrayList(values.size()); for (DispositionProperty dispositionProperty : values) { @@ -267,7 +273,7 @@ public class DispositionServiceImpl implements } return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties() */ @@ -276,20 +282,22 @@ public class DispositionServiceImpl implements { return dispositionProperties.values(); } - + /** ========= Disposition Schedule Methods ========= */ - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) */ public DispositionSchedule getDispositionSchedule(NodeRef nodeRef) - { + { DispositionSchedule di = null; NodeRef diNodeRef = null; if (serviceRegistry.getRecordService().isRecord(nodeRef) == true) { // Get the record folders for the record - List recordFolders = getRmService().getRecordFolders(nodeRef); + // FIXME + RecordFolderService recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); + List recordFolders = recordFolderService.getRecordFolders(nodeRef); // At this point, we may have disposition instruction objects from 1..n folders. diNodeRef = dispositionSelectionStrategy.selectDispositionScheduleFrom(recordFolders); } @@ -298,26 +306,26 @@ public class DispositionServiceImpl implements // Get the disposition instructions for the node reference provided diNodeRef = getDispositionScheduleImpl(nodeRef); } - + if (diNodeRef != null) { di = new DispositionScheduleImpl(serviceRegistry, nodeService, diNodeRef); } - + return di; } - + /** * This method returns a NodeRef - * Gets the disposition instructions - * + * Gets the disposition instructions + * * @param nodeRef * @return */ private NodeRef getDispositionScheduleImpl(NodeRef nodeRef) { NodeRef result = getAssociatedDispositionScheduleImpl(nodeRef); - + if (result == null) { NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef(); @@ -328,18 +336,18 @@ public class DispositionServiceImpl implements } return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) */ public DispositionSchedule getAssociatedDispositionSchedule(NodeRef nodeRef) { DispositionSchedule ds = null; - + // Check the noderef parameter ParameterCheck.mandatory("nodeRef", nodeRef); if (nodeService.exists(nodeRef) == true) - { + { // Get the associated disposition schedule node reference NodeRef dsNodeRef = getAssociatedDispositionScheduleImpl(nodeRef); if (dsNodeRef != null) @@ -348,21 +356,21 @@ public class DispositionServiceImpl implements ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); } } - + return ds; } - + /** * Gets the node reference of the disposition schedule associated with the container. - * + * * @param nodeRef node reference of the container * @return {@link NodeRef} node reference of the disposition schedule, null if none */ private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) { - NodeRef result = null; + NodeRef result = null; ParameterCheck.mandatory("nodeRef", nodeRef); - + // Make sure we are dealing with an RM node if (filePlanService.isFilePlanComponent(nodeRef) == false) { @@ -378,10 +386,10 @@ public class DispositionServiceImpl implements result = firstChildAssocRef.getChildRef(); } } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedRecordsManagementContainer(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) */ @@ -390,7 +398,7 @@ public class DispositionServiceImpl implements { ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); NodeRef result = null; - + NodeRef dsNodeRef = dispositionSchedule.getNodeRef(); if (nodeService.exists(dsNodeRef) == true) { @@ -408,39 +416,39 @@ public class DispositionServiceImpl implements "(dispositionScheduleNodeRef=" + dispositionSchedule.getNodeRef().toString() + ")"); } } - + // Get the container reference ChildAssociationRef assoc = assocs.get(0); result = assoc.getParentRef(); } } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#hasDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) - */ + */ @Override - public boolean hasDisposableItems(DispositionSchedule dispositionSchdule) + public boolean hasDisposableItems(DispositionSchedule dispositionSchdule) { return !getDisposableItems(dispositionSchdule).isEmpty(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDisposableItems(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule) */ public List getDisposableItems(DispositionSchedule dispositionSchedule) { ParameterCheck.mandatory("dispositionSchedule", dispositionSchedule); - + // Get the associated container NodeRef rmContainer = getAssociatedRecordsManagementContainer(dispositionSchedule); - + // Return the disposable items return getDisposableItemsImpl(dispositionSchedule.isRecordLevelDisposition(), rmContainer); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isDisposableItem(org.alfresco.service.cmr.repository.NodeRef) */ @@ -449,9 +457,9 @@ public class DispositionServiceImpl implements { return nodeService.hasAspect(nodeRef, ASPECT_DISPOSITION_LIFECYCLE); } - + /** - * + * * @param isRecordLevelDisposition * @param rmContainer * @param root @@ -461,13 +469,15 @@ public class DispositionServiceImpl implements { List items = filePlanService.getAllContained(rmContainer); List result = new ArrayList(items.size()); + // FIXME + RecordFolderService recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); for (NodeRef item : items) { - if (getRmService().isRecordFolder(item) == true) - { + if (recordFolderService.isRecordFolder(item) == true) + { if (isRecordLevelDisposition == true) { - result.addAll(getRmService().getRecords(item)); + result.addAll(recordService.getRecords(item)); } else { @@ -484,7 +494,7 @@ public class DispositionServiceImpl implements } return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#createDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef, java.util.Map) */ @@ -492,16 +502,16 @@ public class DispositionServiceImpl implements public DispositionSchedule createDispositionSchedule(NodeRef nodeRef, Map props) { NodeRef dsNodeRef = null; - + // Check mandatory parameters ParameterCheck.mandatory("nodeRef", nodeRef); - + // Check exists if (nodeService.exists(nodeRef) == false) { throw new AlfrescoRuntimeException("Unable to create disposition schedule, because node does not exist. (nodeRef=" + nodeRef.toString() + ")"); } - + // Check is sub-type of rm:recordCategory QName nodeRefType = nodeService.getType(nodeRef); if (TYPE_RECORD_CATEGORY.equals(nodeRefType) == false && @@ -509,18 +519,18 @@ public class DispositionServiceImpl implements { throw new AlfrescoRuntimeException("Unable to create disposition schedule on a node that is not a records management container."); } - + behaviourFilter.disableBehaviour(nodeRef, ASPECT_SCHEDULED); try - { + { // Add the schedules aspect if required if (nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED) == false) { nodeService.addAspect(nodeRef, ASPECT_SCHEDULED, null); } - - // Check whether there is already a disposition schedule object present - List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); + + // Check whether there is already a disposition schedule object present + List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL); if (assocs.size() == 0) { DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef); @@ -532,15 +542,15 @@ public class DispositionServiceImpl implements throw new AlfrescoRuntimeException("Can not create a disposition schedule if there are disposable items already under the control of an other disposition schedule"); } } - + // Create the disposition schedule object dsNodeRef = nodeService.createNode( - nodeRef, - ASSOC_DISPOSITION_SCHEDULE, + nodeRef, + ASSOC_DISPOSITION_SCHEDULE, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("dispositionSchedule")), TYPE_DISPOSITION_SCHEDULE, props).getChildRef(); - } + } else { // Error since the node already has a disposition schedule set @@ -551,15 +561,15 @@ public class DispositionServiceImpl implements { behaviourFilter.enableBehaviour(nodeRef, ASPECT_SCHEDULED); } - - // Create the return object + + // Create the return object return new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef); } - + /** ========= Disposition Action Definition Methods ========= */ - + /** - * + * */ public DispositionActionDefinition addDispositionActionDefinition( DispositionSchedule schedule, @@ -571,22 +581,22 @@ public class DispositionServiceImpl implements { throw new IllegalArgumentException("'name' parameter is mandatory when creating a disposition action definition"); } - + // TODO: also check the action name is valid? - + // create the child association from the schedule to the action definition - NodeRef actionNodeRef = this.nodeService.createNode(schedule.getNodeRef(), - RecordsManagementModel.ASSOC_DISPOSITION_ACTION_DEFINITIONS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, + NodeRef actionNodeRef = this.nodeService.createNode(schedule.getNodeRef(), + RecordsManagementModel.ASSOC_DISPOSITION_ACTION_DEFINITIONS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name)), RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION, actionDefinitionParams).getChildRef(); - + // get the updated disposition schedule and retrieve the new action definition NodeRef scheduleParent = this.nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); DispositionSchedule updatedSchedule = this.getDispositionSchedule(scheduleParent); return updatedSchedule.getDispositionActionDefinition(actionNodeRef.getId()); - } - + } + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#removeDispositionActionDefinition(org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule, org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition) */ @@ -595,79 +605,79 @@ public class DispositionServiceImpl implements // check first whether action definitions can be removed if (hasDisposableItems(schedule) == true) { - throw new AlfrescoRuntimeException("Can not remove action definitions from schedule '" + + throw new AlfrescoRuntimeException("Can not remove action definitions from schedule '" + schedule.getNodeRef() + "' as one or more record or record folders are present."); } - + // remove the child node representing the action definition this.nodeService.removeChild(schedule.getNodeRef(), actionDefinition.getNodeRef()); } - + /** * Updates the given disposition action definition belonging to the given disposition * schedule. - * + * * @param schedule The DispositionSchedule the action belongs to * @param actionDefinition The DispositionActionDefinition to update * @param actionDefinitionParams Map of parameters to use to update the action definition * @return The updated DispositionActionDefinition */ public DispositionActionDefinition updateDispositionActionDefinition( - DispositionActionDefinition actionDefinition, + DispositionActionDefinition actionDefinition, Map actionDefinitionParams) { // update the node with properties this.nodeService.addProperties(actionDefinition.getNodeRef(), actionDefinitionParams); - + // get the updated disposition schedule and retrieve the updated action definition NodeRef ds = this.nodeService.getPrimaryParent(actionDefinition.getNodeRef()).getParentRef(); DispositionSchedule updatedSchedule = new DispositionScheduleImpl(serviceRegistry, nodeService, ds); - return updatedSchedule.getDispositionActionDefinition(actionDefinition.getId()); - } - + return updatedSchedule.getDispositionActionDefinition(actionDefinition.getId()); + } + /** ========= Disposition Action Methods ========= */ - + /** * Initialises the details of the next disposition action based on the details of a disposition * action definition. - * + * * @param nodeRef node reference * @param dispositionActionDefinition disposition action definition */ private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition) - { + { // Create the properties Map props = new HashMap(10); - + // Calculate the asOf date Date asOfDate = null; Period period = dispositionActionDefinition.getPeriod(); if (period != null) { Date contextDate = null; - + // Get the period properties value QName periodProperty = dispositionActionDefinition.getPeriodProperty(); if (periodProperty != null) { // doesn't matter if the period property isn't set ... the asOfDate will get updated later // when the value of the period property is set - contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); + contextDate = (Date)this.nodeService.getProperty(nodeRef, periodProperty); } else { - // for now use 'NOW' as the default context date + // for now use 'NOW' as the default context date // TODO set the default period property ... cut off date or last disposition date depending on context contextDate = new Date(); } - + // Calculate the as of date if (contextDate != null) { asOfDate = period.getNextDate(contextDate); } - } - + } + // Set the property values props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId()); props.put(PROP_DISPOSITION_ACTION, dispositionActionDefinition.getName()); @@ -675,27 +685,27 @@ public class DispositionServiceImpl implements { props.put(PROP_DISPOSITION_AS_OF, asOfDate); } - + // Create a new disposition action object NodeRef dispositionActionNodeRef = this.nodeService.createNode( - nodeRef, - ASSOC_NEXT_DISPOSITION_ACTION, - ASSOC_NEXT_DISPOSITION_ACTION, + nodeRef, + ASSOC_NEXT_DISPOSITION_ACTION, + ASSOC_NEXT_DISPOSITION_ACTION, TYPE_DISPOSITION_ACTION, - props).getChildRef(); - + props).getChildRef(); + // Create the events List events = dispositionActionDefinition.getEvents(); for (RecordsManagementEvent event : events) { // For every event create an entry on the action createEvent(event, dispositionActionNodeRef); - } + } } - + /** * Creates the given records management event for the given 'next action'. - * + * * @param event The event to create * @param nextActionNodeRef The next action node * @return The created event NodeRef @@ -703,31 +713,31 @@ public class DispositionServiceImpl implements private NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef) { NodeRef eventNodeRef = null; - + Map eventProps = new HashMap(7); eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName()); // TODO display label RecordsManagementEventType eventType = serviceRegistry.getRecordsManagementEventService().getEventType(event.getType()); eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent()); eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false); - + // Create the event execution object - this.nodeService.createNode(nextActionNodeRef, + this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS, - ASSOC_EVENT_EXECUTIONS, - TYPE_EVENT_EXECUTION, + ASSOC_EVENT_EXECUTIONS, + TYPE_EVENT_EXECUTION, eventProps); - + return eventNodeRef; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isNextDispositionActionEligible(org.alfresco.service.cmr.repository.NodeRef) */ public boolean isNextDispositionActionEligible(NodeRef nodeRef) { boolean result = false; - + // Get the disposition instructions DispositionSchedule di = getDispositionSchedule(nodeRef); NodeRef nextDa = getNextDispositionActionNodeRef(nodeRef); @@ -742,7 +752,7 @@ public class DispositionServiceImpl implements { result = true; } - + if (result == false) { DispositionAction da = new DispositionActionImpl(serviceRegistry, nextDa); @@ -750,7 +760,7 @@ public class DispositionServiceImpl implements if (dad != null) { boolean firstComplete = dad.eligibleOnFirstCompleteEvent(); - + List assocs = this.nodeService.getChildAssocs(nextDa, ASSOC_EVENT_EXECUTIONS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : assocs) { @@ -760,7 +770,7 @@ public class DispositionServiceImpl implements if (isCompleteValue != null) { isComplete = isCompleteValue.booleanValue(); - + // implement AND and OR combination of event completions if (isComplete == true) { @@ -783,13 +793,13 @@ public class DispositionServiceImpl implements } } } - + return result; } - + /** * Get the next disposition action node. Null if none present. - * + * * @param nodeRef the disposable node reference * @return NodeRef the next disposition action, null if none */ @@ -803,7 +813,7 @@ public class DispositionServiceImpl implements } return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getNextDispositionAction(org.alfresco.service.cmr.repository.NodeRef) */ @@ -818,23 +828,23 @@ public class DispositionServiceImpl implements } return result; } - - + + /** ========= Disposition Action History Methods ========= */ - - + + public List getCompletedDispositionActions(NodeRef nodeRef) { List assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_ACTION_HISTORY, RegexQNamePattern.MATCH_ALL); - List result = new ArrayList(assocs.size()); + List result = new ArrayList(assocs.size()); for (ChildAssociationRef assoc : assocs) { NodeRef dispositionActionNodeRef = assoc.getChildRef(); result.add(new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef)); - } + } return result; } - + public DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef) { DispositionAction result = null; @@ -843,7 +853,17 @@ public class DispositionServiceImpl implements { // Get the last disposition action in the list result = list.get(list.size()-1); - } + } return result; } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isCutoff(NodeRef) + */ + @Override + public boolean isCutoff(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return nodeService.hasAspect(nodeRef, ASPECT_CUT_OFF); + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java index ba1c8aab66..778d5666b0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/CustomEmailMappingServiceImpl.java @@ -30,7 +30,6 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.metadata.RFC822MetadataExtracter; -import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; @@ -86,8 +85,6 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme /** Services */ private NodeService nodeService; private NamespacePrefixResolver nspr; - @SuppressWarnings("unused") - private PolicyComponent policyComponent; private ContentService contentService; private TransactionService transactionService; @@ -97,14 +94,6 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme /** List of email mapping keys */ private List emailMappingKeys; - /** - * @param policyComponent policy component - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - /** * @param nspr namespace service */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java index 58f37ef1a1..c46837f325 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferenceCreateEventType.java @@ -25,53 +25,40 @@ import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; /** * On reference create event type - * + * * @author Roy Wetherall */ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventTypeImpl implements RecordsManagementModel, OnCreateReference { - /** Records management service */ - @SuppressWarnings("unused") - private RecordsManagementService recordsManagementService; - /** Records management action service */ private RecordsManagementActionService recordsManagementActionService; - + /** Disposition service */ private DispositionService dispositionService; - + /** Policy component */ private PolicyComponent policyComponent; - + /** Reference */ private QName reference; - - /** - * @param recordsManagementService the records management service to set - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - + /** * @param dispositionService the disposition service to set */ @@ -79,7 +66,7 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType { this.dispositionService = dispositionService; } - + /** * @param recordsManagementActionService the recordsManagementActionService to set */ @@ -87,37 +74,37 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType { this.recordsManagementActionService = recordsManagementActionService; } - + /** * Set policy components - * + * * @param policyComponent policy component */ public void setPolicyComponent(PolicyComponent policyComponent) { this.policyComponent = policyComponent; } - + /** * Set the reference - * + * * @param reference */ public void setReferenceName(String reference) { this.reference = QName.createQName(reference); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#init() */ public void init() { super.init(); - + // Register interest in the on create reference policy - policyComponent.bindClassBehaviour(RecordsManagementPolicies.ON_CREATE_REFERENCE, - ASPECT_RECORD, + policyComponent.bindClassBehaviour(RecordsManagementPolicies.ON_CREATE_REFERENCE, + ASPECT_RECORD, new JavaBehaviour(this, "onCreateReference", NotificationFrequency.TRANSACTION_COMMIT)); } @@ -129,7 +116,7 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType { return true; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference#onCreateReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) */ @@ -158,18 +145,18 @@ public class OnReferenceCreateEventType extends SimpleRecordsManagementEventType params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); recordsManagementActionService.executeRecordsManagementAction(toNodeRef, "completeEvent", params); - + break; } } } } - + return null; - } + } }; - + AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); - + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java index f845ff55b5..24a5298f32 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java @@ -24,18 +24,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies; -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.action.impl.CompleteEventAction; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -46,48 +46,40 @@ import org.alfresco.service.namespace.RegexQNamePattern; /** * Behaviour executed when a references record is actioned upon. - * + * * @author Roy Wetherall */ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEventTypeImpl implements RecordsManagementModel - + { - /** Records management service */ - private RecordsManagementService recordsManagementService; - /** Disposition service */ private DispositionService dispositionService; - + /** Records management action service */ private RecordsManagementActionService recordsManagementActionService; - + /** Records management admin service */ private RecordsManagementAdminService recordsManagementAdminService; - + /** Node service */ private NodeService nodeService; - + /** Policy component */ private PolicyComponent policyComponent; - + /** Record service */ private RecordService recordService; + /** Record folder service */ + private RecordFolderService recordFolderService; + /** Action name */ private String actionName; - + /** Reference */ private QName reference; - - /** - * @param recordsManagementService the records management service to set - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - + /** * @param dispositionService the disposition service */ @@ -95,7 +87,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.dispositionService = dispositionService; } - + /** * @param recordsManagementActionService the recordsManagementActionService to set */ @@ -103,7 +95,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.recordsManagementActionService = recordsManagementActionService; } - + /** * @param recordsManagementAdminService record management admin service */ @@ -111,7 +103,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.recordsManagementAdminService = recordsManagementAdminService; } - + /** * @param nodeService node service */ @@ -119,7 +111,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.nodeService = nodeService; } - + /** * @param recordService record service */ @@ -127,7 +119,15 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.recordService = recordService; } - + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @param policyComponent policy component */ @@ -135,7 +135,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.policyComponent = policyComponent; } - + /** * @param reference reference name */ @@ -143,7 +143,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.reference = QName.createQName(reference); } - + /** * @param actionName action name */ @@ -151,17 +151,17 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { this.actionName = actionName; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.SimpleRecordsManagementEventTypeImpl#init() */ public void init() { super.init(); - + // Register interest in the on create reference policy - policyComponent.bindClassBehaviour(RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION, - ASPECT_FILE_PLAN_COMPONENT, + policyComponent.bindClassBehaviour(RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION, + ASPECT_FILE_PLAN_COMPONENT, new JavaBehaviour(this, "beforeActionExecution", NotificationFrequency.FIRST_EVENT)); } @@ -173,10 +173,10 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent { return true; } - + /** * Before action exeuction behaviour. - * + * * @param nodeRef * @param name * @param parameters @@ -206,32 +206,32 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent } } } - + return null; - } + } }; - + AuthenticationUtil.runAs(work, AuthenticationUtil.getAdminUserName()); - + } - + private void processRecordFolder(NodeRef recordFolder) { if (recordService.isRecord(recordFolder) == true) { processRecord(recordFolder); } - else if (recordsManagementService.isRecordFolder(recordFolder) == true) + else if (recordFolderService.isRecordFolder(recordFolder) == true) { - for (NodeRef record : recordsManagementService.getRecords(recordFolder)) + for (NodeRef record : recordService.getRecords(recordFolder)) { processRecord(record); } } } - + private void processRecord(NodeRef record) - { + { List fromAssocs = recordsManagementAdminService.getCustomReferencesFrom(record); for (AssociationRef fromAssoc : fromAssocs) { @@ -241,7 +241,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent doEventComplete(nodeRef); } } - + List toAssocs = recordsManagementAdminService.getCustomReferencesTo(record); for (AssociationRef toAssoc : toAssocs) { @@ -250,9 +250,9 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent NodeRef nodeRef = toAssoc.getSourceRef(); doEventComplete(nodeRef); } - } + } } - + private void doEventComplete(NodeRef nodeRef) { DispositionAction da = dispositionService.getNextDispositionAction(nodeRef); @@ -271,7 +271,7 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_BY, AuthenticationUtil.getFullyAuthenticatedUser()); params.put(CompleteEventAction.PARAM_EVENT_COMPLETED_AT, new Date()); recordsManagementActionService.executeRecordsManagementAction(nodeRef, "completeEvent", params); - + break; } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java index 1eef409477..4cf7132b9e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/SimpleRecordsManagementEventTypeImpl.java @@ -18,44 +18,38 @@ */ package org.alfresco.module.org_alfresco_module_rm.event; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.extensions.surf.util.I18NUtil; /** * Simple records management event type implementation - * + * * @author Roy Wetherall */ public class SimpleRecordsManagementEventTypeImpl implements RecordsManagementEventType, BeanNameAware { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(SimpleRecordsManagementEventTypeImpl.class); - /** Display label lookup prefix */ protected static final String LOOKUP_PREFIX = "rmeventservice."; - + /** Name */ public static final String NAME = "rmEventType.simple"; - + /** Records management event service */ protected RecordsManagementEventService recordsManagementEventService; - + /** Name */ protected String name; - + /** * Set the records management event service - * + * * @param recordsManagementEventService records management service */ public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService) { this.recordsManagementEventService = recordsManagementEventService; } - + /** * Initialisation method */ @@ -63,7 +57,7 @@ public class SimpleRecordsManagementEventTypeImpl implements RecordsManagementEv { recordsManagementEventService.registerEventType(this); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#isAutomaticEvent() */ @@ -87,7 +81,7 @@ public class SimpleRecordsManagementEventTypeImpl implements RecordsManagementEv { this.name = name; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType#getDisplayLabel() */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index 53942f7171..f51b577abe 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; @@ -32,26 +31,26 @@ import com.hazelcast.impl.Node; /** * File plan service interface. - * + * * @author Roy Wetherall * @since 2.1 */ public interface FilePlanService { - /** - * Default RM site id. - * Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node. + /** + * Default RM site id. + * Can be used with {@link FilePlanService#getFilePlanBySiteId(String)} to get the file plan node. * */ public static final String DEFAULT_RM_SITE_ID = "rm"; - + /** * Indicates whether the given node is a file plan component or not. - * + * * @param nodeRef node reference * @return boolean true if a file plan component, false otherwise */ boolean isFilePlanComponent(NodeRef nodeRef); - + /** * Returns the 'kind' of file plan component the node reference is. *

@@ -62,260 +61,254 @@ public interface FilePlanService * @return FilePlanComponentKind the kind of file plan component the node is */ FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef); - + /** - * Returns the file plan component 'kind' that relates to the passed + * Returns the file plan component 'kind' that relates to the passed * content type. *

* Returns null if the type does not relate to a file plan component. - * - * @param type qualified name of content type + * + * @param type qualified name of content type * @return FilePlanComponentKind the kind relating to the passed type */ FilePlanComponentKind getFilePlanComponentKindFromType(QName type); - + /** * Indicates whether the given node is file plan node or not. - * + * * @param nodeRef node reference * @return boolean true if node is a file plan node */ boolean isFilePlan(NodeRef nodeRef); - + /** * Gets all the file plan nodes. - * Looks in the SpacesStore by default. - * + * Looks in the SpacesStore by default. + * * @return Set set of file plan nodes */ Set getFilePlans(); - + /** * Getse all the file plan nodes in a store. - * + * * @param storeRef store reference * @return Set set of file plan nodes */ Set getFilePlans(StoreRef storeRef); - + /** * Gets the file plan the node is in. - * - * @return {@link NodeRef} file node reference, null if none + * + * @return {@link NodeRef} file node reference, null if none */ NodeRef getFilePlan(NodeRef nodeRef); - + /** * Gets a file plan by site id. Assumes the site is a RM site and that the file plan node, ie * the document library container, has been already created. Otherwise returns null. - * + * * @param siteId records management site id * @return NodeRef file plan, null if can't be found */ NodeRef getFilePlanBySiteId(String siteId); - + /** * Indicates whether the unfiled container exists for a given file plan or not. - * + * * @param filePlan file plan * @return boolean true if unfiled container exists, false otherwise */ boolean existsUnfiledContainer(NodeRef filePlan); - + /** * Gets the unfiled container for a given file plan. Returns null if * none. - * + * * @param filePlan file plan * @return {@link NodeRef} unfiled container, null if none */ NodeRef getUnfiledContainer(NodeRef filePlan); - + /** * Creates, and returns, a unfiled container for a given file plan. - * + * * @param filePlan file plan * @return {@link Node} unfiled container */ NodeRef createUnfiledContainer(NodeRef filePlan); - + /** - * + * * @param filePlan * @return */ NodeRef getHoldContainer(NodeRef filePlan); - + /** - * + * * @param filePlan * @return */ NodeRef createHoldContainer(NodeRef filePlan); - + /** - * + * * @param filePlan * @return */ NodeRef getTransferContainer(NodeRef filePlan); - + /** - * + * * @param filePlan * @return */ NodeRef createTransferContainer(NodeRef filePlan); - + /** * Creates a file plan as a child of the given parent node, with the name * provided. - * + * * @param parent parent node reference - * @param name file plan name + * @param name file plan name * @param type type, must be rma:filePlan or sub-type of * @return NodeRef file plan node reference */ NodeRef createFilePlan(NodeRef parent, String name, QName type); - + /** * Specifies the properties to be set on the created file plan. - * + * * @see #createFilePlan(NodeRef, String, QName) - * + * * @param parent parent node reference - * @param name file plan name + * @param name file plan name * @param type type, must be rma:filePlan or sub-type of * @param properties file plan properties * @return NodeRef file plan node reference */ NodeRef createFilePlan(NodeRef parent, String name, QName type, Map properties); - + /** * Creates a file plan with the default type. - * + * * @see #createFilePlan(NodeRef, String, QName) - * + * * @param parent parent node reference * @param name file plan name * @return NodeRef file plan node reference */ NodeRef createFilePlan(NodeRef parent, String name); - + /** * Creates a file plan with the default type, specifying properties. - * + * * @see #createFilePlan(NodeRef, String, QName) - * + * * @param parent parent node reference * @param name file plan name * @param properties file plan properties * @return NodeRef file plan node reference */ NodeRef createFilePlan(NodeRef parent, String name, Map properties); - + // TODO deleteFilePlan - + /** * Gets the NodeRef sequence from the {@link #getFilePlan(NodeRef) root} * down to the fileplan component given. The array will start with the NodeRef of the root * and end with the name of the fileplan component node given. - * + * * @param nodeRef a fileplan component * @return Returns a NodeRef path starting with the file plan */ List getNodeRefPath(NodeRef nodeRef); - + /** * Indicates whether the given node is a file plan container or not. *

* This includes file plan and record category nodes. - * + * * @param nodeRef node reference * @return boolean true if node is a file plan container, false otherwise. */ boolean isFilePlanContainer(NodeRef nodeRef); - + /** * Indicates whether the given node is a record category or not. - * + * * @param nodeRef node reference * @return boolean true if records category, false otherwise */ boolean isRecordCategory(NodeRef nodeRef); - + /** * Get all the items contained within a container. This will include record folders and other record categories. - * + * * @param recordCategory record category node reference * @param deep if true then return all children including sub-categories and their children in turn, if false then just * return the immediate children * @return {@link List}<{@link NodeRef>} list of contained node references */ List getAllContained(NodeRef recordCategory, boolean deep); - + /** * Only return the immediate children. - * - * @see RecordsManagementService#getAllContained(NodeRef, boolean) - * + * * @param recordCategory record category node reference * @return {@link List}<{@link NodeRef>} list of contained node references */ - List getAllContained(NodeRef recordCategory); - + List getAllContained(NodeRef recordCategory); + /** * Get all the record categories within a record category. - * + * * @param recordCategory record category node reference * @param deep if true then return all children including sub-categories and their children in turn, if false then just * return the immediate children * @return {@link List}<{@link NodeRef>} list of container node references */ List getContainedRecordCategories(NodeRef recordCategory, boolean deep); - + /** * Only return immediate children. - * - * @see RecordsManagementService#getContainedRecordCategories(NodeRef, boolean) - * + * * @param recordCategory container node reference * @return {@link List}<{@link NodeRef>} list of container node references */ List getContainedRecordCategories(NodeRef recordCategory); - + /** * Get all the record folders contained within a container - * + * * @param container container node reference * @param deep if true then return all children including sub-containers and their children in turn, if false then just * return the immediate children * @return {@link List}<{@link NodeRef>} list of record folder node references */ List getContainedRecordFolders(NodeRef container, boolean deep); - + /** * Only return immediate children. - * - * @see RecordsManagementService#getContainedRecordFolders(NodeRef, boolean) - * + * * @param container container node reference * @return {@link List}<{@link NodeRef>} list of record folder node references */ List getContainedRecordFolders(NodeRef container); - + /** * Create a record category. - * + * * @param parent parent node reference, must be a record category or file plan. * @param name name of the new record category * @param type type of container to create, must be a sub-type of rm:recordCategory * @return NodeRef node reference of the created record category */ NodeRef createRecordCategory(NodeRef parent, String name, QName type); - + /** - * + * * @param parent * @param name * @param type @@ -323,20 +316,18 @@ public interface FilePlanService * @return */ NodeRef createRecordCategory(NodeRef parent, String name, QName type, Map properties); - + /** * Creates a record category of type rma:recordCategory - * - * @see RecordsManagementService#createRecordCategory(NodeRef, String, QName) - * + * * @param parent parent node reference, must be a record category or file plan. * @param name name of the record category * @return NodeRef node reference of the created record category */ NodeRef createRecordCategory(NodeRef parent, String name); - + /** - * + * * @param parent * @param name * @param properties diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 28942f6497..da8ea1a261 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -59,12 +59,12 @@ import org.springframework.extensions.surf.util.I18NUtil; /** * File plan service implementation. - * + * * @author Roy Wetherall * @since 2.1 */ public class FilePlanServiceImpl extends ServiceBaseImpl - implements FilePlanService, + implements FilePlanService, RecordsManagementModel, ApplicationContextAware { @@ -77,18 +77,18 @@ public class FilePlanServiceImpl extends ServiceBaseImpl private final static String MSG_CONTAINER_PARENT_TYPE= "rm.service.container-parent-type"; private final static String MSG_CONTAINER_TYPE = "rm.service.container-type"; private final static String MSG_CONTAINER_EXPECTED = "rm.service.container-expected"; - + /** File plan containers */ private static final String NAME_UNFILED_CONTAINER = "Unfiled Records"; private static final String NAME_HOLD_CONTAINER = "Holds"; private static final String NAME_TRANSFER_CONTAINER = "Transfers"; - + /** RM site file plan container */ private static final String FILE_PLAN_CONTAINER = "documentLibrary"; - + /** Application context */ private ApplicationContext applicationContext; - + /** * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ @@ -97,50 +97,50 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { this.applicationContext = applicationContext; } - + /** - * NOTE: for some reason spring couldn't cope with the circular references between these two + * NOTE: for some reason spring couldn't cope with the circular references between these two * beans so we need to grab this one manually. - * + * * @return file plan role service */ protected FilePlanRoleService getFilePlanRoleService() { - return (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); + return (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); } - + /** * @return permission service */ protected PermissionService getPermissionService() { - return (PermissionService)applicationContext.getBean("permissionService"); + return (PermissionService)applicationContext.getBean("permissionService"); } - + /** * @return node DAO */ protected NodeDAO getNodeDAO() { - return (NodeDAO)applicationContext.getBean("nodeDAO"); + return (NodeDAO)applicationContext.getBean("nodeDAO"); } - + /** * @return internal node service */ protected NodeService getInternalNodeService() { - return (NodeService)applicationContext.getBean("nodeService"); + return (NodeService)applicationContext.getBean("nodeService"); } - + /** * @return site service */ protected SiteService getSiteService() { - return (SiteService)applicationContext.getBean("SiteService"); + return (SiteService)applicationContext.getBean("SiteService"); } - + /** * @return record service */ @@ -148,7 +148,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return (RecordService)applicationContext.getBean("RecordService"); } - + /** * @return record folder service */ @@ -156,7 +156,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return (RecordFolderService)applicationContext.getBean("RecordFolderService"); } - + /** * @return freeze service */ @@ -164,7 +164,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return (FreezeService)applicationContext.getBean("FreezeService"); } - + /** * @return records management service */ @@ -172,7 +172,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return (RecordsManagementService)applicationContext.getBean("RecordsManagementService"); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) */ @@ -186,18 +186,18 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanComponentKind(org.alfresco.service.cmr.repository.NodeRef) */ public FilePlanComponentKind getFilePlanComponentKind(NodeRef nodeRef) { FilePlanComponentKind result = null; - + if (isFilePlanComponent(nodeRef) == true) { result = FilePlanComponentKind.FILE_PLAN_COMPONENT; - + if (isFilePlan(nodeRef) == true) { result = FilePlanComponentKind.FILE_PLAN; @@ -206,7 +206,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result = FilePlanComponentKind.RECORD_CATEGORY; } - else if (getRecordsManagementService().isRecordFolder(nodeRef) == true) + else if (getRecordFolderService().isRecordFolder(nodeRef) == true) { result = FilePlanComponentKind.RECORD_FOLDER; } @@ -231,18 +231,18 @@ public class FilePlanServiceImpl extends ServiceBaseImpl result = FilePlanComponentKind.UNFILED_RECORD_CONTAINER; } } - + return result; } - + /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getFilePlanComponentKindFromType(org.alfresco.service.namespace.QName) + * @see FilePlanService#getFilePlanComponentKindFromType(QName) */ @Override public FilePlanComponentKind getFilePlanComponentKindFromType(QName type) { FilePlanComponentKind result = null; - + if (ASPECT_FILE_PLAN_COMPONENT.equals(type) == true) { result = FilePlanComponentKind.FILE_PLAN_COMPONENT; @@ -271,15 +271,15 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result = FilePlanComponentKind.TRANSFER; } - else if (dictionaryService.isSubClass(type, TYPE_DISPOSITION_SCHEDULE) == true || + else if (dictionaryService.isSubClass(type, TYPE_DISPOSITION_SCHEDULE) == true || dictionaryService.isSubClass(type, TYPE_DISPOSITION_ACTION_DEFINITION) == true) { result = FilePlanComponentKind.DISPOSITION_SCHEDULE; } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef) */ @@ -287,7 +287,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return instanceOf(nodeRef, TYPE_FILE_PLAN); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans() */ @@ -296,7 +296,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getFilePlans(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef) */ @@ -304,34 +304,34 @@ public class FilePlanServiceImpl extends ServiceBaseImpl public Set getFilePlans(final StoreRef storeRef) { ParameterCheck.mandatory("storeRef", storeRef); - + final Set results = new HashSet(); Set aspects = new HashSet(1); aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() - { + { @Override public boolean handle(Pair nodePair) { NodeRef nodeRef = nodePair.getSecond(); if (storeRef.equals(nodeRef.getStoreRef()) == true) - { + { results.add(nodeRef); } - + return true; } }); return results; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef) */ @Override public NodeRef getFilePlan(NodeRef nodeRef) { - NodeRef result = null; + NodeRef result = null; if (nodeRef != null) { result = (NodeRef)getInternalNodeService().getProperty(nodeRef, PROP_ROOT_NODEREF); @@ -350,19 +350,19 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } } } - } - + } + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanBySiteId(java.lang.String) */ @Override public NodeRef getFilePlanBySiteId(String siteId) { - NodeRef filePlan = null; - + NodeRef filePlan = null; + SiteInfo siteInfo = getSiteService().getSite(siteId); if (siteInfo != null) { @@ -375,10 +375,10 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } } } - + return filePlan; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#existsUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -386,8 +386,8 @@ public class FilePlanServiceImpl extends ServiceBaseImpl public boolean existsUnfiledContainer(NodeRef filePlan) { return (getUnfiledContainer(filePlan) != null); - } - + } + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -396,7 +396,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getFilePlanRootContainer(filePlan, NAME_UNFILED_CONTAINER); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getHoldContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -405,7 +405,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getFilePlanRootContainer(filePlan, NAME_HOLD_CONTAINER); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getTransferContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -414,9 +414,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getFilePlanRootContainer(filePlan, NAME_TRANSFER_CONTAINER); } - + /** - * + * * @param filePlan * @param containerName * @return @@ -430,7 +430,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } NodeRef result = null; - + // try and get the unfiled record container List assocs = nodeService.getChildAssocs(filePlan, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, containerName)); if (assocs.size() > 1) @@ -441,18 +441,18 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result = assocs.get(0).getChildRef(); } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createUnfiledContainer(org.alfresco.service.cmr.repository.NodeRef) */ public NodeRef createUnfiledContainer(NodeRef filePlan) - { + { return createFilePlanRootContainer(filePlan, TYPE_UNFILED_RECORD_CONTAINER, NAME_UNFILED_CONTAINER); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createHoldContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -461,7 +461,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createFilePlanRootContainer(filePlan, TYPE_HOLD_CONTAINER, NAME_HOLD_CONTAINER); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createTransferContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -470,9 +470,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createFilePlanRootContainer(filePlan, TYPE_TRANSFER_CONTAINER, NAME_TRANSFER_CONTAINER); } - + /** - * + * * @param filePlan * @param containerType * @param containerName @@ -486,9 +486,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { throw new AlfrescoRuntimeException("Unable to create file plan root container, because passed node is not a file plan."); } - + String allRoles = getFilePlanRoleService().getAllRolesContainerGroup(filePlan); - + // create the properties map Map properties = new HashMap(1); properties.put(ContentModel.PROP_NAME, containerName); @@ -501,7 +501,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl containerType, properties).getChildRef(); - + // if (inheritPermissions == false) // { // set inheritance to false @@ -510,7 +510,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl getPermissionService().setPermission(container, ExtendedReaderDynamicAuthority.EXTENDED_READER, RMPermissionModel.READ_RECORDS, true); getPermissionService().setPermission(container, ExtendedWriterDynamicAuthority.EXTENDED_WRITER, RMPermissionModel.FILING, true); getPermissionService().setPermission(container, "Administrator", RMPermissionModel.FILING, true); - + // TODO set the admin users to have filing permissions on the unfiled container!!! // TODO we will need to be able to get a list of the admin roles from the service // } @@ -523,7 +523,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl return container; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) */ @@ -532,21 +532,21 @@ public class FilePlanServiceImpl extends ServiceBaseImpl ParameterCheck.mandatory("parent", parent); ParameterCheck.mandatory("name", name); ParameterCheck.mandatory("type", type); - + // Check the parent is not already an RM component node // ie: you can't create a rm root in an existing rm hierarchy if (isFilePlanComponent(parent) == true) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_DUP_ROOT)); } - + // Check that the passed type is a sub-type of rma:filePlan if (TYPE_FILE_PLAN.equals(type) == false && dictionaryService.isSubClass(type, TYPE_FILE_PLAN) == false) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ROOT_TYPE, type.toString())); } - + // Build map of properties Map rmRootProps = new HashMap(1); if (properties != null && properties.size() != 0) @@ -554,7 +554,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl rmRootProps.putAll(properties); } rmRootProps.put(ContentModel.PROP_NAME, name); - + // Create the root ChildAssociationRef assocRef = nodeService.createNode( parent, @@ -562,12 +562,12 @@ public class FilePlanServiceImpl extends ServiceBaseImpl QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), type, rmRootProps); - + // TODO do we need to create role and security groups or is this done automatically? - + return assocRef.getChildRef(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) */ @@ -575,7 +575,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createFilePlan(parent, name, TYPE_FILE_PLAN, properties); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) */ @@ -583,7 +583,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createFilePlan(parent, name, TYPE_FILE_PLAN, null); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) */ @@ -592,7 +592,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createFilePlan(parent, name, type, null); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getNodeRefPath(org.alfresco.service.cmr.repository.NodeRef) */ @@ -609,7 +609,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } return nodeRefPath; } - + /** * Helper method to build a NodeRef path from the node to the RM root */ @@ -639,7 +639,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl getNodeRefPathRecursive(nodeRef, nodeRefPath); } } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isFilePlanContainer(org.alfresco.service.cmr.repository.NodeRef) */ @@ -648,7 +648,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return instanceOf(nodeRef, TYPE_RECORDS_MANAGEMENT_CONTAINER); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#isRecordCategory(org.alfresco.service.cmr.repository.NodeRef) */ @@ -656,7 +656,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return instanceOf(nodeRef, TYPE_RECORD_CATEGORY); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map) */ @@ -665,7 +665,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl ParameterCheck.mandatory("parent", parent); ParameterCheck.mandatory("name", name); ParameterCheck.mandatory("type", type); - + // Check that the parent is a container QName parentType = nodeService.getType(parent); if (TYPE_RECORDS_MANAGEMENT_CONTAINER.equals(parentType) == false && @@ -673,14 +673,14 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_PARENT_TYPE, parentType.toString())); } - + // Check that the the provided type is a sub-type of rm:recordCategory if (TYPE_RECORD_CATEGORY.equals(type) == false && dictionaryService.isSubClass(type, TYPE_RECORD_CATEGORY) == false) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_TYPE, type.toString())); } - + // Set the properties for the record category Map props = new HashMap(1); if (properties != null && properties.size() != 0) @@ -688,7 +688,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl props.putAll(properties); } props.put(ContentModel.PROP_NAME, name); - + return nodeService.createNode( parent, ContentModel.ASSOC_CONTAINS, @@ -696,7 +696,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl type, props).getChildRef(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) */ @@ -704,7 +704,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.util.Map) */ @@ -712,7 +712,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createRecordCategory(parent, name, TYPE_RECORD_CATEGORY, properties); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#createRecordCategory(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName) */ @@ -720,7 +720,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return createRecordCategory(parent, name, type, null); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef) */ @@ -729,7 +729,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getAllContained(container, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getAllContained(org.alfresco.service.cmr.repository.NodeRef, boolean) */ @@ -738,25 +738,25 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getContained(container, null, deep); } - + /** * Get contained nodes of a particular type. If null return all. - * + * * @param container container node reference * @param typeFilter type filter, null if none * @return {@link List}<{@link NodeRef> list of contained node references */ private List getContained(NodeRef container, QName typeFilter, boolean deep) - { + { // Parameter check ParameterCheck.mandatory("container", container); - + // Check we have a container in our hands if (isRecordCategory(container) == false) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED)); } - + List result = new ArrayList(1); List assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : assocs) @@ -769,7 +769,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result.add(child); } - + // Inspect the containers and add children if deep if (deep == true && (TYPE_RECORD_CATEGORY.equals(childType) == true || @@ -778,10 +778,10 @@ public class FilePlanServiceImpl extends ServiceBaseImpl result.addAll(getContained(child, typeFilter, deep)); } } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef) */ @@ -790,7 +790,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getContainedRecordCategories(container, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordCategories(org.alfresco.service.cmr.repository.NodeRef, boolean) */ @@ -799,7 +799,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getContained(container, TYPE_RECORD_CATEGORY, deep); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef) */ @@ -808,7 +808,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { return getContainedRecordFolders(container, false); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getContainedRecordFolders(org.alfresco.service.cmr.repository.NodeRef, boolean) */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java index c9be23c7ac..733da7320d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java @@ -22,9 +22,8 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; +import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldGroup; @@ -58,7 +57,6 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt protected NamespaceService namespaceService; protected NodeService nodeService; protected RecordsManagementServiceRegistry rmServiceRegistry; - protected RecordsManagementService rmService; protected RecordsManagementAdminService rmAdminService; protected RecordService recordService; protected DictionaryService dictionaryService; @@ -93,16 +91,6 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt this.rmServiceRegistry = rmServiceRegistry; } - /** - * Sets the RecordsManagementService instance - * - * @param rmService The RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * Sets the RecordsManagementAdminService instance * 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 5c65630f02..10175c1fe1 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 @@ -28,10 +28,10 @@ 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.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.node.NodeServicePolicies; @@ -78,21 +78,21 @@ public class FreezeServiceImpl extends ServiceBaseImpl /** Policy Component */ protected PolicyComponent policyComponent; - /** Records Management Service */ - protected RecordsManagementService recordsManagementService; - /** Record service */ protected RecordService recordService; - + /** File Plan Service */ protected FilePlanService filePlanService; - + /** Permission service */ protected PermissionService permissionService; - - /** file plan role service */ + + /** File plan role service */ protected FilePlanRoleService filePlanRoleService; + /** Record folder service */ + protected RecordFolderService recordFolderService; + /** * @param policyComponent policy component */ @@ -101,14 +101,6 @@ public class FreezeServiceImpl extends ServiceBaseImpl this.policyComponent = policyComponent; } - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - /** * @param recordService record service */ @@ -116,7 +108,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl { this.recordService = recordService; } - + /** * @param filePlanService file plan service */ @@ -124,31 +116,39 @@ public class FreezeServiceImpl extends ServiceBaseImpl { this.filePlanService = filePlanService; } - + /** * @param permissionService permission service */ - public void setPermissionService(PermissionService permissionService) + public void setPermissionService(PermissionService permissionService) { this.permissionService = permissionService; } - + /** * @param filePlanRoleService file plan role service */ - public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) + public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService) { this.filePlanRoleService = filePlanRoleService; } + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * Init service */ public void init() { policyComponent.bindClassBehaviour( - NodeServicePolicies.BeforeDeleteNodePolicy.QNAME, - this, + NodeServicePolicies.BeforeDeleteNodePolicy.QNAME, + this, new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT)); } @@ -271,11 +271,11 @@ public class FreezeServiceImpl extends ServiceBaseImpl // node references // Check if the actionedUponNodeRef is a valid file plan component boolean isRecord = recordService.isRecord(nodeRef); - boolean isFolder = recordsManagementService.isRecordFolder(nodeRef); + boolean isFolder = recordFolderService.isRecordFolder(nodeRef); - if (!(isRecord || isFolder)) - { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_FREEZE_ONLY_RECORDS_FOLDERS)); + if (!(isRecord || isFolder)) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_FREEZE_ONLY_RECORDS_FOLDERS)); } // Log a message about freezing the node with the reason @@ -328,9 +328,9 @@ public class FreezeServiceImpl extends ServiceBaseImpl } // Mark all the folders contents as frozen - if (recordsManagementService.isRecordFolder(nodeRef)) + if (recordFolderService.isRecordFolder(nodeRef)) { - List records = recordsManagementService.getRecords(nodeRef); + List records = recordService.getRecords(nodeRef); for (NodeRef record : records) { // no need to freeze if already frozen! @@ -394,7 +394,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl if (nodeService.hasAspect(nodeRef, ASPECT_FROZEN)) { - boolean isRecordFolder = recordsManagementService.isRecordFolder(nodeRef); + boolean isRecordFolder = recordFolderService.isRecordFolder(nodeRef); if (logger.isDebugEnabled()) { @@ -414,7 +414,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl // Remove freeze from records if a record folder if (isRecordFolder) { - List records = recordsManagementService.getRecords(nodeRef); + List records = recordService.getRecords(nodeRef); for (NodeRef record : records) { removeFreeze(record); @@ -608,7 +608,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl holdProps.put(ContentModel.PROP_NAME, holdName); holdProps.put(PROP_HOLD_REASON, reason); - // create the hold object + // create the hold object QName holdQName = QName.createQName(RM_URI, holdName); final NodeRef holdNodeRef = nodeService.createNode(holdContainer, ContentModel.ASSOC_CONTAINS, holdQName, TYPE_HOLD, holdProps).getChildRef(); @@ -618,7 +618,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl msg.append("Created hold object '").append(holdNodeRef).append("' with name '").append(holdQName).append("'."); logger.debug(msg.toString()); } - + // Bind the hold node reference to the transaction AlfrescoTransactionSupport.bindResource(KEY_HOLD_NODEREF, holdNodeRef); @@ -713,7 +713,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl // parents of the folder(s). if (recordService.isRecord(nodeRef)) { - List parentFolders = recordsManagementService.getRecordFolders(nodeRef); + List parentFolders = recordFolderService.getRecordFolders(nodeRef); for (NodeRef folder : parentFolders) { List moreAssocs = nodeService.getParentAssocs(folder, ASSOC_FROZEN_RECORDS, @@ -755,7 +755,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl // Remove the freezes on the child records as long as there is no other // hold referencing them - if (recordsManagementService.isRecordFolder(nodeRef) == true) + if (recordFolderService.isRecordFolder(nodeRef) == true) { if (logger.isDebugEnabled()) { @@ -763,7 +763,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl msg.append(nodeRef).append(" is a record folder"); logger.debug(msg.toString()); } - for (NodeRef record : recordsManagementService.getRecords(nodeRef)) + for (NodeRef record : recordService.getRecords(nodeRef)) { removeFreeze(record, hold); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java index 79a0c3abfa..3bd99c376d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/job/publish/DispositionActionDefinitionPublishExecutor.java @@ -26,28 +26,23 @@ import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.action.impl.BroadcastDispositionActionDefinitionUpdateAction; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; /** * Disposition action definition publish executor - * + * * @author Roy Wetherall */ public class DispositionActionDefinitionPublishExecutor extends BasePublishExecutor { /** Node service */ private NodeService nodeService; - + /** Records management action service */ private RecordsManagementActionService rmActionService; - /** Behaviour filter */ - @SuppressWarnings("unused") - private BehaviourFilter behaviourFilter; - /** * Set node service * @param nodeService node service @@ -56,7 +51,7 @@ public class DispositionActionDefinitionPublishExecutor extends BasePublishExecu { this.nodeService = nodeService; } - + /** * Set records management service * @param rmActionService records management service @@ -65,16 +60,7 @@ public class DispositionActionDefinitionPublishExecutor extends BasePublishExecu { this.rmActionService = rmActionService; } - - /** - * Set behaviour filter - * @param behaviourFilter behaviour filter - */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } - + /** * @see org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor#getName() */ @@ -96,7 +82,7 @@ public class DispositionActionDefinitionPublishExecutor extends BasePublishExecu { Map params = new HashMap(); params.put(BroadcastDispositionActionDefinitionUpdateAction.CHANGED_PROPERTIES, (Serializable)updatedProps); - rmActionService.executeRecordsManagementAction(nodeRef, BroadcastDispositionActionDefinitionUpdateAction.NAME, params); + rmActionService.executeRecordsManagementAction(nodeRef, BroadcastDispositionActionDefinitionUpdateAction.NAME, params); } } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java index f9bfbe9960..affc7a709d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/BaseEvaluator.java @@ -23,14 +23,15 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; 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.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; 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.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.security.AccessStatus; @@ -38,60 +39,55 @@ import org.alfresco.service.namespace.NamespaceService; /** * Base evaluator. - * + * * @author Roy Wetherall */ public abstract class BaseEvaluator implements RecordsManagementModel { /** Name */ protected String name; - + /** JSON conversion component */ protected JSONConversionComponent jsonConversionComponent; - - /** Records management service */ - protected RecordsManagementService recordsManagementService; - + /** Record service */ protected RecordService recordService; - + /** Node service */ protected NodeService nodeService; - + /** Namespace service */ protected NamespaceService namespaceService; - + /** Capability service */ protected CapabilityService capabilityService; - + /** Freeze service */ protected FreezeService freezeService; - + /** File plan component kinds */ - protected Set kinds; - + protected Set kinds; + /** Capabilities */ protected List capabilities; - + /** File plan service */ protected FilePlanService filePlanService; - + + /** Disposition service */ + protected DispositionService dispositionService; + + /** Record folder service */ + protected RecordFolderService recordFolderService; + /** * @param jsonConversionComponent json conversion component */ public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) { this.jsonConversionComponent = jsonConversionComponent; - } - - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; } - + /** * @param recordService record service */ @@ -99,7 +95,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.recordService = recordService; } - + /** * @param nodeService node service */ @@ -107,7 +103,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.nodeService = nodeService; } - + /** * @param namespaceService namespace service */ @@ -115,7 +111,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.namespaceService = namespaceService; } - + /** * @param capabilityService capability service */ @@ -123,7 +119,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.capabilityService = capabilityService; } - + /** * @param freezeService freeze service */ @@ -131,15 +127,31 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.freezeService = freezeService; } - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + + /** + * @param dispositionService disposition service + */ + public void setDispositionService(DispositionService dispositionService) + { + this.dispositionService = dispositionService; + } + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @param name */ @@ -147,7 +159,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.name = name; } - + /** * @return */ @@ -155,7 +167,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { return this.name; } - + /** * @param kinds */ @@ -163,7 +175,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.kinds = kinds; } - + /** * @param capabilties */ @@ -171,10 +183,10 @@ public abstract class BaseEvaluator implements RecordsManagementModel { this.capabilities = capabilties; } - + /** * Helper method which sets on capability. - * + * * @param capability capability name */ public void setCapability(String capability) @@ -183,7 +195,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel list.add(capability); this.capabilities = list; } - + /** * Registers this instance as an indicator (evaluator) */ @@ -191,7 +203,7 @@ public abstract class BaseEvaluator implements RecordsManagementModel { jsonConversionComponent.registerIndicator(this); } - + /** * Registers this instance as an action (evaluator) */ @@ -199,17 +211,17 @@ public abstract class BaseEvaluator implements RecordsManagementModel { jsonConversionComponent.registerAction(this); } - + /** * Executes the evaluation. - * + * * @param nodeRef * @return */ public boolean evaluate(NodeRef nodeRef) { boolean result = false; - + // Check that we are dealing with the correct kind of RM object if (kinds == null || checkKinds(nodeRef) == true) { @@ -219,13 +231,13 @@ public abstract class BaseEvaluator implements RecordsManagementModel result = evaluateImpl(nodeRef); } } - + return result; } - - /** + + /** * Checks the file plan component kind. - * + * * @param nodeRef * @return */ @@ -234,10 +246,10 @@ public abstract class BaseEvaluator implements RecordsManagementModel FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); return kinds.contains(kind); } - + /** * Checks the capabilities. - * + * * @param nodeRef * @return */ @@ -258,10 +270,10 @@ public abstract class BaseEvaluator implements RecordsManagementModel } return result; } - + /** * Evaluation execution implementation. - * + * * @param nodeRef * @return */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index b2847f5364..d64dfdf2c3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.jscript.app; import java.util.ArrayList; import java.util.List; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; 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.fileplan.FilePlanComponentKind; @@ -41,9 +40,6 @@ import org.json.simple.JSONObject; */ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent { - /** Records management service */ - private RecordsManagementService recordsManagementService; - /** Record service */ private RecordService recordService; @@ -59,14 +55,6 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC /** Actions */ private List actions = new ArrayList(); - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - /** * @param recordService record service */ @@ -238,7 +226,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC } case RECORD_FOLDER: { - if (recordsManagementService.isMetadataStub(nodeRef) == true) + if (recordService.isMetadataStub(nodeRef) == true) { result = "metadata-stub-folder"; } @@ -250,7 +238,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC } case RECORD: { - if (recordsManagementService.isMetadataStub(nodeRef) == true) + if (recordService.isMetadataStub(nodeRef) == true) { result = "metadata-stub"; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java index 0733bf7e16..c07f01e133 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/CutoffEvaluator.java @@ -23,21 +23,21 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Cutoff indicator - * + * * @author Roy Wetherall */ public class CutoffEvaluator extends BaseEvaluator -{ +{ private boolean isCutoff = true; - + public void setCutoff(boolean isCutoff) { this.isCutoff = isCutoff; } - + @Override protected boolean evaluateImpl(NodeRef nodeRef) { - return (recordsManagementService.isCutoff(nodeRef) == isCutoff); + return (dispositionService.isCutoff(nodeRef) == isCutoff); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java index 7855ee3b89..cece91b143 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/evaluator/FolderOpenClosedEvaluator.java @@ -27,15 +27,15 @@ import org.alfresco.service.cmr.repository.NodeRef; public class FolderOpenClosedEvaluator extends BaseEvaluator { private boolean expected = true; - + public void setExpected(boolean expected) { this.expected = expected; } - + @Override protected boolean evaluateImpl(NodeRef nodeRef) { - return (recordsManagementService.isRecordFolderClosed(nodeRef) == expected); + return (recordFolderService.isRecordFolderClosed(nodeRef) == expected); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordCopyBehaviours.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordCopyBehaviours.java index 6b4202992f..3708580746 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordCopyBehaviours.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordCopyBehaviours.java @@ -23,13 +23,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl; 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.record.RecordService; -import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServiceImpl; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.repo.copy.CopyBehaviourCallback; import org.alfresco.repo.copy.CopyDetails; import org.alfresco.repo.copy.DefaultCopyBehaviourCallback; @@ -50,7 +49,7 @@ import org.springframework.context.ApplicationContextAware; /** * Class containing behaviour for the vitalRecordDefinition aspect. - * + * * @author neilm */ public class RecordCopyBehaviours implements RecordsManagementModel, @@ -58,16 +57,16 @@ public class RecordCopyBehaviours implements RecordsManagementModel, { /** The policy component */ private PolicyComponent policyComponent; - + /** The Behaviour Filter */ private BehaviourFilter behaviourFilter; - + /** The rm service registry */ private RecordsManagementServiceRegistry rmServiceRegistry; - + /** List of aspects to remove during move and copy */ private List unwantedAspects = new ArrayList(5); - + /** Application context */ private ApplicationContext applicationContext; @@ -77,32 +76,32 @@ public class RecordCopyBehaviours implements RecordsManagementModel, @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - + this.applicationContext = applicationContext; + } + /** * Set the policy component - * + * * @param policyComponent the policy component */ public void setPolicyComponent(PolicyComponent policyComponent) { this.policyComponent = policyComponent; } - + /** * Set the behaviour Filter - * + * * @param behaviourFilter */ public void setBehaviourFilter(BehaviourFilter behaviourFilter) { this.behaviourFilter = behaviourFilter; } - + /** * Set the rm service registry. - * + * * @param recordsManagementServiceRegistry the rm service registry. */ public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry recordsManagementServiceRegistry) @@ -119,7 +118,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel, unwantedAspects.add(ASPECT_VITAL_RECORD); unwantedAspects.add(ASPECT_DISPOSITION_LIFECYCLE); unwantedAspects.add(RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH); - + // Do not copy any of the Alfresco-internal 'state' aspects for (QName aspect : unwantedAspects) { @@ -132,43 +131,43 @@ public class RecordCopyBehaviours implements RecordsManagementModel, QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), ASPECT_RECORD_COMPONENT_ID, new JavaBehaviour(this, "getDoNothingCopyCallback")); - + //On Copy we need a new ID this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyComplete"), ASPECT_RECORD_COMPONENT_ID, new JavaBehaviour(this, "generateId", NotificationFrequency.TRANSACTION_COMMIT)); - + //Don't copy the Aspect Record -- it should be regenerated this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), - ASPECT_RECORD, + ASPECT_RECORD, new JavaBehaviour(this, "onCopyRecord")); - - // Move behaviour + + // Move behaviour this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), - RecordsManagementModel.ASPECT_RECORD, + RecordsManagementModel.ASPECT_RECORD, new JavaBehaviour(this, "onMoveRecordNode", NotificationFrequency.FIRST_EVENT)); this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), - RecordsManagementModel.TYPE_RECORD_FOLDER, + RecordsManagementModel.TYPE_RECORD_FOLDER, new JavaBehaviour(this, "onMoveRecordFolderNode", NotificationFrequency.FIRST_EVENT)); - + //Copy Behaviour this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), - RecordsManagementModel.TYPE_RECORD_FOLDER, + QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), + RecordsManagementModel.TYPE_RECORD_FOLDER, new JavaBehaviour(this, "onCopyRecordFolderNode")); this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), - RecordsManagementModel.TYPE_RECORD_CATEGORY, + QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), + RecordsManagementModel.TYPE_RECORD_CATEGORY, new JavaBehaviour(this, "onCopyRecordCategoryNode")); } - + /** * onMove record behaviour - * + * * @param oldChildAssocRef * @param newChildAssocRef */ @@ -179,7 +178,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel, { final NodeRef newNodeRef = newChildAssocRef.getChildRef(); final NodeService nodeService = rmServiceRegistry.getNodeService(); - + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { public Object doWork() throws Exception @@ -189,57 +188,56 @@ public class RecordCopyBehaviours implements RecordsManagementModel, // only remove the search details .. the rest will be resolved automatically nodeService.removeAspect(newNodeRef, RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH); } - + return null; } }, AuthenticationUtil.getAdminUserName()); } } - + /** * onMove record folder behaviour - * + * * @param oldChildAssocRef * @param newChildAssocRef */ public void onMoveRecordFolderNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) { final NodeService nodeService = rmServiceRegistry.getNodeService(); - + if (!nodeService.getType(newChildAssocRef.getParentRef()).equals(TYPE_RECORD_FOLDER)) - { + { if (!oldChildAssocRef.getParentRef().equals(newChildAssocRef.getParentRef())) { //final NodeRef oldNodeRef = oldChildAssocRef.getChildRef(); final NodeRef newNodeRef = newChildAssocRef.getChildRef(); - + AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { public Object doWork() throws Exception { - final RecordsManagementService rmService = rmServiceRegistry.getRecordsManagementService(); final RecordService rmRecordService = rmServiceRegistry.getRecordService(); - final RecordFolderServiceImpl recordFolderService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService"); + final RecordFolderService recordFolderService = rmServiceRegistry.getRecordFolderService(); final DispositionServiceImpl dispositionService = (DispositionServiceImpl)applicationContext.getBean("dispositionService"); - + behaviourFilter.disableBehaviour(); try { // Remove unwanted aspects removeUnwantedAspects(nodeService, newNodeRef); - + // reinitialise the record folder recordFolderService.initialiseRecordFolder(newNodeRef); - + // reinitialise the record folder disposition action details dispositionService.refreshDispositionAction(newNodeRef); - + // Sort out the child records - for (NodeRef record : rmService.getRecords(newNodeRef)) + for (NodeRef record : rmRecordService.getRecords(newNodeRef)) { // Remove unwanted aspects removeUnwantedAspects(nodeService, record); - + // Re-initiate the records in the new folder. rmRecordService.file(record); } @@ -259,11 +257,11 @@ public class RecordCopyBehaviours implements RecordsManagementModel, throw new UnsupportedOperationException("Cannot move record folder into another record folder."); } } - + /** * Handle the copying of the record aspect. * Excludes the Date Filed property. The Date Filed will be generated on copy. - * + * * @param classRef * @param copyDetails * @return @@ -278,7 +276,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel, Map properties) { Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); - + // Remove the Date Filed property from record properties on copy. // It will be generated for the copy if (sourceProperties.containsKey(PROP_DATE_FILED)) @@ -288,15 +286,15 @@ public class RecordCopyBehaviours implements RecordsManagementModel, return sourceProperties; } - + }; } - + /** * Record Folder Copy Behaviour - * + * *
  • Do not allow copy of record folder into another record folder
  • - * + * * @param classRef * @param copyDetails * @return @@ -306,12 +304,12 @@ public class RecordCopyBehaviours implements RecordsManagementModel, return new DefaultCopyBehaviourCallback() { final NodeService nodeService = rmServiceRegistry.getNodeService(); - + @Override public Map getCopyProperties(QName classRef, CopyDetails copyDetails, Map properties) { Map sourceProperties = super.getCopyProperties(classRef, copyDetails, properties); - + // ensure that the 'closed' status of the record folder is not copied if (sourceProperties.containsKey(PROP_IS_CLOSED)) { @@ -320,11 +318,11 @@ public class RecordCopyBehaviours implements RecordsManagementModel, return sourceProperties; } - - + + /** * If the targets parent is a Record Folder -- Do Not Allow Copy - * + * * @param classQName * @param copyDetails * @return boolean @@ -333,7 +331,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel, public boolean getMustCopy(QName classQName, CopyDetails copyDetails) { boolean result = true; - + if (nodeService.getType(copyDetails.getTargetParentNodeRef()).equals(TYPE_RECORD_FOLDER) == true) { result = false; @@ -342,17 +340,17 @@ public class RecordCopyBehaviours implements RecordsManagementModel, { result = false; } - + return result; } }; } - + /** * Record Category Copy Behaviour - * + * *
  • Do not allow copy of record category into a record folder
  • - * + * * @param classRef * @param copyDetails * @return @@ -362,10 +360,10 @@ public class RecordCopyBehaviours implements RecordsManagementModel, return new DefaultCopyBehaviourCallback() { final NodeService nodeService = rmServiceRegistry.getNodeService(); - + /** * If the targets parent is a Record Folder -- Do Not Allow Copy - * + * * @param classQName * @param copyDetails * @return boolean @@ -377,10 +375,10 @@ public class RecordCopyBehaviours implements RecordsManagementModel, } }; } - + /** * Removes unwanted aspects - * + * * @param nodeService * @param nodeRef */ @@ -395,10 +393,10 @@ public class RecordCopyBehaviours implements RecordsManagementModel, } } } - + /** * Get the "do nothing" call back behaviour - * + * * @param classRef * @param copyDetails * @return @@ -407,10 +405,10 @@ public class RecordCopyBehaviours implements RecordsManagementModel, { return new DoNothingCopyBehaviourCallback(); } - + /** * Generate and set a new ID for copy of a record - * + * * @param classRef * @param sourceNodeRef * @param targetNodeRef @@ -422,12 +420,12 @@ public class RecordCopyBehaviours implements RecordsManagementModel, { final IdentifierService rmIdentifierService = rmServiceRegistry.getIdentifierService(); final NodeService nodeService = rmServiceRegistry.getNodeService(); - + //Generate the id for the copy String id = rmIdentifierService.generateIdentifier( - nodeService.getType(nodeService.getPrimaryParent(targetNodeRef).getParentRef()), + nodeService.getType(nodeService.getPrimaryParent(targetNodeRef).getParentRef()), (nodeService.getPrimaryParent(targetNodeRef).getParentRef())); - + //We need to allow the id to be overwritten disable the policy protecting changes to the id behaviourFilter.disableBehaviour(); try @@ -439,14 +437,14 @@ public class RecordCopyBehaviours implements RecordsManagementModel, behaviourFilter.enableBehaviour(); } } - + /** * Function to pad a string with zero '0' characters to the required length - * + * * @param s String to pad with leading zero '0' characters * @param len Length to pad to - * - * @return padded string or the original if already at >=len characters + * + * @return padded string or the original if already at >=len characters */ protected String padString(String s, int len) { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 7a375b4f01..e344ef46e8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Set; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition; @@ -37,11 +36,13 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedul import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -56,33 +57,36 @@ import org.apache.commons.logging.LogFactory; /** * Search Behaviour class. - * + * * Manages the collapse of data onto the supporting aspect on the record/record folder - * + * * @author Roy Wetherall */ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { - private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class); - + private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class); + /** Policy component */ private PolicyComponent policyComponent; - + /** Node service */ private NodeService nodeService; - - /** Records management service */ - private RecordsManagementService recordsManagementService; - + /** Disposition service */ private DispositionService dispositionService; - + /** Records management service registry */ private RecordsManagementServiceRegistry recordsManagementServiceRegistry; - + /** Vital record service */ private VitalRecordService vitalRecordService; + /** Record folder service */ + private RecordFolderService recordFolderService; + + /** Record service*/ + private RecordService recordService; + /** * @param nodeService the nodeService to set */ @@ -90,7 +94,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { this.nodeService = nodeService; } - + /** * @param dispositionService the disposition service */ @@ -98,7 +102,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { this.dispositionService = dispositionService; } - + /** * @param policyComponent the policyComponent to set */ @@ -106,15 +110,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { this.policyComponent = policyComponent; } - - /** - * @param recordsManagementService the records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - + /** * @param recordsManagementServiceRegistry the records management service registry */ @@ -122,7 +118,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { this.recordsManagementServiceRegistry = recordsManagementServiceRegistry; } - + /** * @param vitalRecordService vital record service */ @@ -130,17 +126,33 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { this.vitalRecordService = vitalRecordService; } - + + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + /** Java behaviour */ - private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT); + private JavaBehaviour onAddSearchAspect = new JavaBehaviour(this, "rmSearchAspectAdd", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionActionCreate = new JavaBehaviour(this, "dispositionActionCreate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionActionPropertiesUpdate = new JavaBehaviour(this, "dispositionActionPropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbDispositionSchedulePropertiesUpdate = new JavaBehaviour(this, "dispositionSchedulePropertiesUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbEventExecutionUpdate = new JavaBehaviour(this, "eventExecutionUpdate", NotificationFrequency.TRANSACTION_COMMIT); private JavaBehaviour jbEventExecutionDelete = new JavaBehaviour(this, "eventExecutionDelete", NotificationFrequency.TRANSACTION_COMMIT); - + /** Array of behaviours related to disposition schedule artifacts */ - private JavaBehaviour[] jbDispositionBehaviours = + private JavaBehaviour[] jbDispositionBehaviours = { jbDispositionActionCreate, jbDispositionActionPropertiesUpdate, @@ -148,72 +160,72 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel jbEventExecutionUpdate, jbEventExecutionDelete }; - + /** * Initialisation method */ public void init() { this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - TYPE_DISPOSITION_ACTION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + TYPE_DISPOSITION_ACTION, jbDispositionActionCreate); - + this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - TYPE_DISPOSITION_ACTION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + TYPE_DISPOSITION_ACTION, jbDispositionActionPropertiesUpdate); this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - TYPE_DISPOSITION_SCHEDULE, + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + TYPE_DISPOSITION_SCHEDULE, jbDispositionSchedulePropertiesUpdate); - + this.policyComponent.bindAssociationBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), - TYPE_DISPOSITION_ACTION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), + TYPE_DISPOSITION_ACTION, ASSOC_EVENT_EXECUTIONS, jbEventExecutionUpdate); this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), - TYPE_EVENT_EXECUTION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), + TYPE_EVENT_EXECUTION, jbEventExecutionDelete); - + this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_RM_SEARCH, - onAddSearchAspect); - + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_RM_SEARCH, + onAddSearchAspect); + this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_RECORD, - new JavaBehaviour(this, "onAddRecordAspect", NotificationFrequency.TRANSACTION_COMMIT)); - + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_RECORD, + new JavaBehaviour(this, "onAddRecordAspect", NotificationFrequency.TRANSACTION_COMMIT)); + this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - TYPE_RECORD_FOLDER, + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + TYPE_RECORD_FOLDER, new JavaBehaviour(this, "recordFolderCreate", NotificationFrequency.TRANSACTION_COMMIT)); - + // Vital Records Review Details Rollup this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - ASPECT_VITAL_RECORD_DEFINITION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + ASPECT_VITAL_RECORD_DEFINITION, new JavaBehaviour(this, "vitalRecordDefintionAddAspect", NotificationFrequency.TRANSACTION_COMMIT)); this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - ASPECT_VITAL_RECORD_DEFINITION, + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + ASPECT_VITAL_RECORD_DEFINITION, new JavaBehaviour(this, "vitalRecordDefintionUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT)); - + // Hold reason rollup this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"), - ASPECT_FROZEN, + QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"), + ASPECT_FROZEN, new JavaBehaviour(this, "onRemoveFrozenAspect", NotificationFrequency.TRANSACTION_COMMIT)); - + this.policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), - TYPE_HOLD, + QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), + TYPE_HOLD, new JavaBehaviour(this, "frozenAspectUpdateProperties", NotificationFrequency.TRANSACTION_COMMIT)); } @@ -224,7 +236,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel jb.disable(); } } - + public void enableDispositionScheduleBehaviour() { for (JavaBehaviour jb : jbDispositionBehaviours) @@ -232,23 +244,23 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel jb.enable(); } } - + /** * Ensures the search aspect for the given node is present, complete and correct. - * + * * @param recordOrFolder */ public void fixupSearchAspect(NodeRef recordOrFolder) { // for now only deal with record folders - if (recordsManagementService.isRecordFolder(recordOrFolder)) + if (recordFolderService.isRecordFolder(recordOrFolder)) { // ensure the search aspect is applied applySearchAspect(recordOrFolder); - + // setup the properties relating to the disposition schedule setupDispositionScheduleProperties(recordOrFolder); - + // setup the properties relating to the disposition lifecycle DispositionAction da = dispositionService.getNextDispositionAction(recordOrFolder); if (da != null) @@ -256,24 +268,24 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel updateDispositionActionProperties(recordOrFolder, da.getNodeRef()); setupDispositionActionEvents(recordOrFolder, da); } - + // setup the properties relating to the vital record indicator setVitalRecordDefintionDetails(recordOrFolder); } } - + /** * Updates the disposition action properties - * + * * @param nodeRef * @param before * @param after */ public void dispositionActionPropertiesUpdate(final NodeRef nodeRef, final Map before, final Map after) { - if (this.nodeService.exists(nodeRef) == true) + if (nodeService.exists(nodeRef) == true) { - AuthenticationUtil.runAs(new RunAsWork() + AuthenticationUtil.runAs(new RunAsWork() { @Override public Void doWork() throws Exception @@ -283,29 +295,29 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { // Get the record (or record folder) NodeRef record = assoc.getParentRef(); - + // Apply the search aspect applySearchAspect(record); - + // Update disposition properties updateDispositionActionProperties(record, nodeRef); } - + return null; - - }}, AuthenticationUtil.getSystemUserName()); + + }}, AuthenticationUtil.getSystemUserName()); } } - + private void applySearchAspect(NodeRef nodeRef) { onAddSearchAspect.disable(); try { - if (this.nodeService.hasAspect(nodeRef, ASPECT_RM_SEARCH) == false) + if (nodeService.hasAspect(nodeRef, ASPECT_RM_SEARCH) == false) { - this.nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null); - + nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null); + if (logger.isDebugEnabled()) logger.debug("Added search aspect to node: " + nodeRef); } @@ -315,7 +327,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel onAddSearchAspect.enable(); } } - + public void onAddRecordAspect(final NodeRef nodeRef, final QName aspectTypeQName) { AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() @@ -328,31 +340,31 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel applySearchAspect(nodeRef); setupDispositionScheduleProperties(nodeRef); } - + return null; } }); } - + public void recordFolderCreate(final ChildAssociationRef childAssocRef) { AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() { @Override public Void doWork() throws Exception - { + { NodeRef nodeRef = childAssocRef.getChildRef(); if (nodeService.exists(nodeRef) == true) { applySearchAspect(nodeRef); setupDispositionScheduleProperties(nodeRef); } - + return null; } }); } - + private void setupDispositionScheduleProperties(NodeRef recordOrFolder) { DispositionSchedule ds = dispositionService.getDispositionSchedule(recordOrFolder); @@ -365,14 +377,14 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel nodeService.setProperty(recordOrFolder, PROP_RS_HAS_DISPOITION_SCHEDULE, true); setDispositionScheduleProperties(recordOrFolder, ds); } - + if (logger.isDebugEnabled()) { - logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder + + logger.debug("Set rma:recordSearchHasDispositionSchedule for node " + recordOrFolder + " to: " + (ds != null)); } } - + public void dispositionActionCreate(ChildAssociationRef childAssocRef) { NodeRef child = childAssocRef.getChildRef(); @@ -381,41 +393,41 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { // Get the record (or record folder) NodeRef record = childAssocRef.getParentRef(); - + // Apply the search aspect applySearchAspect(record); - + // Update disposition properties updateDispositionActionProperties(record, childAssocRef.getChildRef()); - + // Clear the events - this.nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null); - } + nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null); + } } - + /** - * + * * @param record * @param dispositionAction */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { Map props = nodeService.getProperties(record); - + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); - props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); - props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, this.nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + + props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); + props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); + props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); if (daDefinition != null) { Period period = daDefinition.getPeriod(); if (period != null) { props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); } else { @@ -423,16 +435,16 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); } } - + nodeService.setProperties(record, props); - + if (logger.isDebugEnabled()) { - logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + + logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_ACTION_NAME)); logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + + logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + props.get(PROP_RS_DISPOSITION_PERIOD)); @@ -446,11 +458,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { NodeRef dispositionAction = childAssocRef.getParentRef(); NodeRef eventExecution = childAssocRef.getChildRef(); - - if (this.nodeService.exists(dispositionAction) == true && - this.nodeService.exists(eventExecution) == true) - { - ChildAssociationRef assoc = this.nodeService.getPrimaryParent(dispositionAction); + + if (nodeService.exists(dispositionAction) == true && + nodeService.exists(eventExecution) == true) + { + ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionAction); if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION) == true) { // Get the record (or record folder) @@ -458,25 +470,25 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel // Apply the search aspect applySearchAspect(record); - - Collection events = (List)this.nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS); + + Collection events = (List)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS); if (events == null) { events = new ArrayList(1); } - events.add((String)this.nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); - this.nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); + events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); + nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); } } } - + public void eventExecutionDelete(ChildAssociationRef childAssocRef, boolean isNodeArchived) { NodeRef dispositionActionNode = childAssocRef.getParentRef(); - - if (this.nodeService.exists(dispositionActionNode)) + + if (nodeService.exists(dispositionActionNode)) { - ChildAssociationRef assoc = this.nodeService.getPrimaryParent(dispositionActionNode); + ChildAssociationRef assoc = nodeService.getPrimaryParent(dispositionActionNode); if (assoc.getTypeQName().equals(ASSOC_NEXT_DISPOSITION_ACTION) == true) { // Get the record (or record folder) @@ -484,13 +496,13 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel // Apply the search aspect applySearchAspect(record); - + // make sure the list of events match the action definition setupDispositionActionEvents(record, dispositionService.getNextDispositionAction(record)); } } } - + private void setupDispositionActionEvents(NodeRef nodeRef, DispositionAction da) { if (da != null) @@ -505,19 +517,19 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel eventNames.add(event.getEventName()); } } - + // set the property - this.nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames); - + nodeService.setProperty(nodeRef, PROP_RS_DISPOSITION_EVENTS, (Serializable)eventNames); + if (logger.isDebugEnabled()) { logger.debug("Set rma:recordSearchDispositionEvents for node " + nodeRef + " to: " + eventNames); } } } - + public void rmSearchAspectAdd(final NodeRef nodeRef, final QName aspectTypeQName) - { + { AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() { @Override @@ -527,8 +539,8 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { // Initialise the search parameteres as required setVitalRecordDefintionDetails(nodeRef); - } - + } + return null; } }); @@ -537,16 +549,16 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel public void vitalRecordDefintionAddAspect(NodeRef nodeRef, QName aspectTypeQName) { // Only care about record folders - if (recordsManagementService.isRecordFolder(nodeRef) == true) + if (recordFolderService.isRecordFolder(nodeRef) == true) { - updateVitalRecordDefinitionValues(nodeRef); + updateVitalRecordDefinitionValues(nodeRef); } } - + public void vitalRecordDefintionUpdateProperties(NodeRef nodeRef, Map before, Map after) { // Only care about record folders - if (recordsManagementService.isRecordFolder(nodeRef) == true) + if (recordFolderService.isRecordFolder(nodeRef) == true) { Set props = new HashSet(1); props.add(PROP_REVIEW_PERIOD); @@ -556,37 +568,37 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { updateVitalRecordDefinitionValues(nodeRef); } - + } } - + private void updateVitalRecordDefinitionValues(NodeRef nodeRef) { // ensure the folder itself reflects the correct details applySearchAspect(nodeRef); setVitalRecordDefintionDetails(nodeRef); - - List records = recordsManagementService.getRecords(nodeRef); + + List records = recordService.getRecords(nodeRef); for (NodeRef record : records) { // Apply the search aspect applySearchAspect(record); - + // Set the vital record definition details setVitalRecordDefintionDetails(record); } } - + private void setVitalRecordDefintionDetails(NodeRef nodeRef) { VitalRecordDefinition vrd = vitalRecordService.getVitalRecordDefinition(nodeRef); - + if (vrd != null && vrd.isEnabled() == true && vrd.getReviewPeriod() != null) { // Set the property values nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD, vrd.getReviewPeriod().getPeriodType()); nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, vrd.getReviewPeriod().getExpression()); - + if (logger.isDebugEnabled()) { logger.debug("Set rma:recordSearchVitalRecordReviewPeriod for node " + nodeRef + " to: " + @@ -602,7 +614,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel nodeService.setProperty(nodeRef, PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION, null); } } - + public void onRemoveFrozenAspect(NodeRef nodeRef, QName aspectTypeQName) { if (nodeService.exists(nodeRef) == true && @@ -611,7 +623,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel nodeService.setProperty(nodeRef, PROP_RS_HOLD_REASON, null); } } - + public void frozenAspectUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) { AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() @@ -623,46 +635,46 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel { // get the changed hold reason String holdReason = (String)nodeService.getProperty(nodeRef, PROP_HOLD_REASON); - + // get all the frozen items the hold node has and change the hold reason List holdAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : holdAssocs) { NodeRef frozenItem = assoc.getChildRef(); - + // ensure the search aspect is applied and set the hold reason applySearchAspect(frozenItem); nodeService.setProperty(frozenItem, PROP_RS_HOLD_REASON, holdReason); } } - + return null; } }; - + AuthenticationUtil.runAs(work, AuthenticationUtil.getSystemUserName()); } - + /** * Updates the disposition schedule properties - * + * * @param nodeRef * @param before * @param after */ public void dispositionSchedulePropertiesUpdate(NodeRef nodeRef, Map before, Map after) { - if (this.nodeService.exists(nodeRef) == true) + if (nodeService.exists(nodeRef) == true) { // create the schedule object and get the record category for it - DispositionSchedule schedule = new DispositionScheduleImpl(this.recordsManagementServiceRegistry, this.nodeService, nodeRef); - NodeRef recordCategoryNode = this.nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); - + DispositionSchedule schedule = new DispositionScheduleImpl(recordsManagementServiceRegistry, nodeService, nodeRef); + NodeRef recordCategoryNode = nodeService.getPrimaryParent(schedule.getNodeRef()).getParentRef(); + if (schedule.isRecordLevelDisposition()) { - for (NodeRef recordFolder : this.getRecordFolders(recordCategoryNode)) + for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) { - for (NodeRef record : this.recordsManagementService.getRecords(recordFolder)) + for (NodeRef record : recordService.getRecords(recordFolder)) { applySearchAspect(record); setDispositionScheduleProperties(record, schedule); @@ -671,7 +683,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } else { - for (NodeRef recordFolder : this.getRecordFolders(recordCategoryNode)) + for (NodeRef recordFolder : getRecordFolders(recordCategoryNode)) { applySearchAspect(recordFolder); setDispositionScheduleProperties(recordFolder, schedule); @@ -679,14 +691,14 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } } } - + private void setDispositionScheduleProperties(NodeRef recordOrFolder, DispositionSchedule schedule) { if (schedule != null) { - this.nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_AUTHORITY, schedule.getDispositionAuthority()); - this.nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_INSTRUCTIONS, schedule.getDispositionInstructions()); - + nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_AUTHORITY, schedule.getDispositionAuthority()); + nodeService.setProperty(recordOrFolder, PROP_RS_DISPOITION_INSTRUCTIONS, schedule.getDispositionInstructions()); + if (logger.isDebugEnabled()) { logger.debug("Set rma:recordSearchDispositionAuthority for node " + recordOrFolder + " to: " + schedule.getDispositionAuthority()); @@ -694,7 +706,7 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } } } - + /** * This method compares the oldProps map against the newProps map and returns * a set of QNames of the properties that have changed. Changed here means one of @@ -722,25 +734,25 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel result.add(qn); } } - + return result; } - + private List getRecordFolders(NodeRef recordCategoryNode) { List results = new ArrayList(8); - - List folderAssocs = nodeService.getChildAssocs(recordCategoryNode, + + List folderAssocs = nodeService.getChildAssocs(recordCategoryNode, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef folderAssoc : folderAssocs) { NodeRef folder = folderAssoc.getChildRef(); - if (this.recordsManagementService.isRecordFolder(folder)) + if (recordFolderService.isRecordFolder(folder)) { results.add(folder); } } - + return results; } } 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 bf8073236c..5ca63618e3 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 @@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.record; import java.io.Serializable; +import java.util.List; import java.util.Map; import java.util.Set; @@ -39,12 +40,12 @@ public interface RecordService * Disables the property editable check. */ void disablePropertyEditableCheck(); - + /** * Enables the property editable check. By default this is always enabled. */ void enablePropertyEditableCheck(); - + /** * Gets a list of all the record meta-data aspects * @@ -86,10 +87,10 @@ public interface RecordService * @see #createRecord(NodeRef, NodeRef, boolean) */ void createRecord(NodeRef filePlan, NodeRef nodeRef); - + /** * Creates a new document as a unfiled record. - * + * * @param filePlan * @param name * @param type @@ -107,11 +108,11 @@ public interface RecordService /** * 'File' a new document that arrived in the file plan structure. - * + * * @param nodeRef record */ void file(NodeRef record); - + /** * Hides a record within a collaboration site * @@ -126,13 +127,29 @@ public interface RecordService * @param reason The reason for rejection */ void rejectRecord(NodeRef nodeRef, String reason); - + /** * Indicates whether a property of a record is editable for the current user or not. - * + * * @param record record * @param property property * @return boolean true if editable, false otherwise. */ boolean isPropertyEditable(NodeRef record, QName property); + + /** + * Indicates whether the given node (record or record folder) is a metadata stub or not. + * + * @param nodeRef node reference + * @return boolean true if a metadata stub, false otherwise + */ + boolean isMetadataStub(NodeRef nodeRef); + + /** + * Gets a list of all the records within a record folder + * + * @param recordFolder record folder + * @return List list of records in the record folder + */ + List getRecords(NodeRef recordFolder); } 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 491c3248a7..b0ad020889 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 @@ -19,6 +19,7 @@ package org.alfresco.module.org_alfresco_module_rm.record; import java.io.Serializable; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; @@ -30,7 +31,6 @@ 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.capability.Capability; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; @@ -43,13 +43,13 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomM import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.security.ModelAccessDeniedException; import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; -import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -78,6 +78,7 @@ import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.util.EqualsHelper; import org.alfresco.util.ParameterCheck; import org.apache.commons.lang.ArrayUtils; @@ -105,13 +106,13 @@ public class RecordServiceImpl implements RecordService, { /** Logger */ private static Log logger = LogFactory.getLog(RecordServiceImpl.class); - + /** Always edit property array */ private static final QName[] ALWAYS_EDIT_PROPERTIES = new QName[] { ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA }; - + private static final String[] ALWAYS_EDIT_URIS = new String[] { NamespaceService.SECURITY_MODEL_1_0_URI, @@ -122,15 +123,15 @@ public class RecordServiceImpl implements RecordService, NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.BPM_MODEL_1_0_URI, NamespaceService.RENDITION_MODEL_1_0_URI - }; - + }; + private static final String[] RECORD_MODEL_URIS = new String[] { RM_URI, RM_CUSTOM_URI, DOD5015Model.DOD_URI }; - + private static final String[] NON_RECORD_MODEL_URIS = new String[] { NamespaceService.AUDIO_MODEL_1_0_URI, @@ -142,7 +143,7 @@ public class RecordServiceImpl implements RecordService, NamespaceService.REPOSITORY_VIEW_1_0_URI }; - + /** Application context */ private ApplicationContext applicationContext; @@ -161,11 +162,9 @@ public class RecordServiceImpl implements RecordService, /** Extended security service */ private ExtendedSecurityService extendedSecurityService; - /** Records management service */ - private RecordsManagementService recordsManagementService; - /** Disposition service */ - private DispositionService dispositionService; + // FIXME + //private DispositionService dispositionService; /** File plan service */ private FilePlanService filePlanService; @@ -178,22 +177,22 @@ public class RecordServiceImpl implements RecordService, /** Ownable service */ private OwnableService ownableService; - + /** Capability service */ private CapabilityService capabilityService; - + /** Rule service */ private RuleService ruleService; - + /** File folder service */ private FileFolderService fileFolderService; - - /** Behaviour filter */ - @SuppressWarnings("unused") - private BehaviourFilter behaviourFilter; + + /** Record folder service */ + // FIXME + //private RecordFolderService recordFolderService; /** List of available record meta-data aspects */ - private Set recordMetaDataAspects; + private Set recordMetaDataAspects; /** Behaviours */ private JavaBehaviour onCreateChildAssociation = new JavaBehaviour( @@ -255,21 +254,13 @@ public class RecordServiceImpl implements RecordService, this.extendedSecurityService = extendedSecurityService; } - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - /** * @param dispositionService disposition service */ - public void setDispositionService(DispositionService dispositionService) - { - this.dispositionService = dispositionService; - } +// public void setDispositionService(DispositionService dispositionService) +// { +// this.dispositionService = dispositionService; +// } /** * @param filePlanService file plan service @@ -302,7 +293,7 @@ public class RecordServiceImpl implements RecordService, { this.ownableService = ownableService; } - + /** * @param capabilityService capability service */ @@ -310,7 +301,7 @@ public class RecordServiceImpl implements RecordService, { this.capabilityService = capabilityService; } - + /** * @param ruleService rule service */ @@ -318,7 +309,7 @@ public class RecordServiceImpl implements RecordService, { this.ruleService = ruleService; } - + /** * @param fileFolderService file folder service */ @@ -326,14 +317,14 @@ public class RecordServiceImpl implements RecordService, { this.fileFolderService = fileFolderService; } - + /** - * @param behaviourFilter behaviour filter + * @param recordFolderService record folder service */ - public void setBehaviourFilter(BehaviourFilter behaviourFilter) - { - this.behaviourFilter = behaviourFilter; - } +// public void setRecordFolderService(RecordFolderService recordFolderService) +// { +// this.recordFolderService = recordFolderService; +// } /** * Init method @@ -346,26 +337,26 @@ public class RecordServiceImpl implements RecordService, ContentModel.ASSOC_CONTAINS, onCreateChildAssociation); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, - ASPECT_RECORD, + NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, + ASPECT_RECORD, onUpdateProperties); policyComponent.bindAssociationBehaviour( NodeServicePolicies.BeforeDeleteChildAssociationPolicy.QNAME, ContentModel.TYPE_FOLDER, - ContentModel.ASSOC_CONTAINS, + ContentModel.ASSOC_CONTAINS, onDeleteDeclaredRecordLink); - + // Handle the special case when we are dealing with new records that are being added via a file protocol policyComponent.bindClassBehaviour( - NodeServicePolicies.OnAddAspectPolicy.QNAME, - ContentModel.ASPECT_NO_CONTENT, + NodeServicePolicies.OnAddAspectPolicy.QNAME, + ContentModel.ASPECT_NO_CONTENT, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnRemoveAspectPolicy.QNAME, - ContentModel.ASPECT_NO_CONTENT, + NodeServicePolicies.OnRemoveAspectPolicy.QNAME, + ContentModel.ASPECT_NO_CONTENT, new JavaBehaviour(this, "onRemoveAspect", NotificationFrequency.EVERY_EVENT)); } - + /** * @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) */ @@ -402,16 +393,16 @@ public class RecordServiceImpl implements RecordService, { switchNames(nodeRef); } - + /** * Helper method to switch the name of the record around. Used to support record creation via * file protocols. - * + * * @param nodeRef node reference (record) */ private void switchNames(NodeRef nodeRef) { - try + try { if (nodeService.hasAspect(nodeRef, ASPECT_RECORD) == true) { @@ -423,22 +414,22 @@ public class RecordServiceImpl implements RecordService, nodeService.setProperty(nodeRef, PROP_ORIGIONAL_NAME, name); } } - } - catch (FileExistsException e) + } + catch (FileExistsException e) { if (logger.isDebugEnabled() == true) { logger.debug(e.getMessage()); } } - catch (InvalidNodeRefException e) + catch (InvalidNodeRefException e) { if (logger.isDebugEnabled() == true) { logger.debug(e.getMessage()); } - } - catch (FileNotFoundException e) + } + catch (FileNotFoundException e) { if (logger.isDebugEnabled() == true) { @@ -464,9 +455,9 @@ public class RecordServiceImpl implements RecordService, try { NodeRef nodeRef = childAssocRef.getChildRef(); - if (nodeService.exists(nodeRef) == true && + if (nodeService.exists(nodeRef) == true && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) == false && - nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) == false && + nodeService.getType(nodeRef).equals(TYPE_RECORD_FOLDER) == false && nodeService.getType(nodeRef).equals(TYPE_RECORD_CATEGORY) == false) { if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT) == true) @@ -490,15 +481,15 @@ public class RecordServiceImpl implements RecordService, { onCreateChildAssociation.enable(); } - + return null; } }, AuthenticationUtil.getSystemUserName()); } - + /** * Ensure that the user only updates record properties that they have permission to. - * + * * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) */ @Override @@ -520,15 +511,15 @@ public class RecordServiceImpl implements RecordService, { beforeValue = before.get(property); } - + Serializable afterValue = null; if (after != null) { afterValue = after.get(property); } - + boolean propertyUnchanged = false; - if (beforeValue != null && afterValue != null && + if (beforeValue != null && afterValue != null && beforeValue instanceof Date && afterValue instanceof Date) { // deal with date values @@ -539,7 +530,7 @@ public class RecordServiceImpl implements RecordService, // otherwise propertyUnchanged = EqualsHelper.nullSafeEquals(beforeValue, afterValue); } - + if (propertyUnchanged == false && isPropertyEditable(nodeRef, property) == false) { @@ -558,12 +549,12 @@ public class RecordServiceImpl implements RecordService, onUpdateProperties.enable(); } } - + /** * 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 + * 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) @@ -571,15 +562,15 @@ public class RecordServiceImpl implements RecordService, // 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) && + 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.removeExtendedSecurity(childAssocRef.getChildRef(), extendedSecurityService.getExtendedReaders(childAssocRef.getChildRef()), extendedSecurityService.getExtendedWriters(childAssocRef.getChildRef()), true); } } - + /** * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck() */ @@ -588,7 +579,7 @@ public class RecordServiceImpl implements RecordService, { onUpdateProperties.disable(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#enablePropertyEditableCheck() */ @@ -663,7 +654,7 @@ public class RecordServiceImpl implements RecordService, ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("isLinked", isLinked); - + // first we do a sanity check to ensure that the user has at least write permissions on the document if (permissionService.hasPermission(nodeRef, PermissionService.WRITE) != AccessStatus.ALLOWED) { @@ -683,7 +674,7 @@ public class RecordServiceImpl implements RecordService, public Void doWork() throws Exception { if (nodeService.hasAspect(nodeRef, ASPECT_RECORD) == false) - { + { // disable delete rules ruleService.disableRuleType("outbound"); try @@ -694,34 +685,34 @@ public class RecordServiceImpl implements RecordService, { throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found."); } - + // get the documents readers Long aclId = nodeService.getNodeAclId(nodeRef); Set readers = permissionService.getReaders(aclId); Set writers = permissionService.getWriters(aclId); - + // add the current owner to the list of extended writers String owner = ownableService.getOwner(nodeRef); - + // remove the owner ownableService.setOwner(nodeRef, OwnableService.NO_OWNER); - + // get the documents primary parent assoc ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); - + // move the document into the file plan nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); - + // save the information about the originating details Map aspectProperties = new HashMap(3); aspectProperties.put(PROP_RECORD_ORIGINATING_LOCATION, (Serializable) parentAssoc.getParentRef()); aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, userId); aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date()); nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties); - + // make the document a record makeRecord(nodeRef); - + if (isLinked == true) { // turn off rules @@ -730,12 +721,12 @@ public class RecordServiceImpl implements RecordService, { // maintain the original primary location nodeService.addChild(parentAssoc.getParentRef(), nodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName()); - + // set the extended security Set combinedWriters = new HashSet(writers); combinedWriters.add(owner); combinedWriters.add(AuthenticationUtil.getFullyAuthenticatedUser()); - + extendedSecurityService.addExtendedSecurity(nodeRef, readers, combinedWriters); } finally @@ -754,7 +745,7 @@ public class RecordServiceImpl implements RecordService, } }); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecord(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map, org.alfresco.service.cmr.repository.ContentReader) */ @@ -763,30 +754,30 @@ public class RecordServiceImpl implements RecordService, { ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("name", name); - + // if none set the default record type is cm:content if (type == null) { type = ContentModel.TYPE_CONTENT; } // TODO ensure that the type is a sub-type of cm:content - + // get the unfiled record container for the file plan NodeRef unfiledContainer = filePlanService.getUnfiledContainer(filePlan); if (unfiledContainer == null) { throw new AlfrescoRuntimeException("Unable to create record, because unfiled container could not be found."); } - + // create the new record NodeRef record = fileFolderService.create(unfiledContainer, name, type).getNodeRef(); - + // set the properties if (properties != null) { nodeService.addProperties(record, properties); } - + // set the content if (reader != null) { @@ -795,10 +786,10 @@ public class RecordServiceImpl implements RecordService, writer.setMimetype(reader.getMimetype()); writer.putContent(reader); } - + // make record makeRecord(record); - + return record; } @@ -813,12 +804,12 @@ public class RecordServiceImpl implements RecordService, try { // get the record id - String recordId = identifierService.generateIdentifier(ASPECT_RECORD, + String recordId = identifierService.generateIdentifier(ASPECT_RECORD, nodeService.getPrimaryParent(document).getParentRef()); - + // get the record name String name = (String)nodeService.getProperty(document, ContentModel.PROP_NAME); - + // rename the record int dotIndex = name.lastIndexOf("."); String prefix = name; @@ -827,20 +818,20 @@ public class RecordServiceImpl implements RecordService, { prefix = name.substring(0, dotIndex); postfix = name.substring(dotIndex); - } + } String recordName = prefix + " (" + recordId + ")" + postfix; fileFolderService.rename(document, recordName); - + if (logger.isDebugEnabled() == true) { logger.debug("Rename " + name + " to " + recordName); } - + // add the record aspect Map props = new HashMap(2); props.put(PROP_IDENTIFIER, recordId); props.put(PROP_ORIGIONAL_NAME, name); - nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props); + nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props); } catch (FileNotFoundException e) { @@ -850,7 +841,7 @@ public class RecordServiceImpl implements RecordService, { ruleService.enableRules(); } - + } /** @@ -869,8 +860,9 @@ public class RecordServiceImpl implements RecordService, if (childAssocRef != null) { NodeRef parent = childAssocRef.getParentRef(); - if (parent != null && - recordsManagementService.isRecordFolder(parent) == true) + //FIXME + RecordFolderService recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); + if (parent != null && recordFolderService.isRecordFolder(parent) == true) { result = true; } @@ -921,6 +913,8 @@ public class RecordServiceImpl implements RecordService, // initialise disposition details if (nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE) == false) { + //FIXME + DispositionService dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); DispositionSchedule di = dispositionService.getDispositionSchedule(record); if (di != null && di.isRecordLevelDisposition() == true) { @@ -985,14 +979,14 @@ public class RecordServiceImpl implements RecordService, { ruleService.disableRules(); try - { + { // get record property values Map properties = nodeService.getProperties(nodeRef); - String recordId = (String)properties.get(PROP_IDENTIFIER); + String recordId = (String)properties.get(PROP_IDENTIFIER); String documentOwner = (String)properties.get(PROP_RECORD_ORIGINATING_USER_ID); String origionalName = (String)properties.get(PROP_ORIGIONAL_NAME); NodeRef originatingLocation = (NodeRef)properties.get(PROP_RECORD_ORIGINATING_LOCATION); - + // first remove the secondary link association List parentAssocs = nodeService.getParentAssocs(nodeRef); for (ChildAssociationRef childAssociationRef : parentAssocs) @@ -1003,7 +997,7 @@ public class RecordServiceImpl implements RecordService, break; } } - + // remove all RM related aspects from the node Set aspects = nodeService.getAspects(nodeRef); for (QName aspect : aspects) @@ -1014,39 +1008,39 @@ public class RecordServiceImpl implements RecordService, nodeService.removeAspect(nodeRef, aspect); } } - + // get the records primary parent association ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); - + // move the record into the collaboration site nodeService.moveNode(nodeRef, originatingLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); - + // rename to the origional name if (origionalName != null) { fileFolderService.rename(nodeRef, origionalName); - + if (logger.isDebugEnabled() == true) { String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); logger.debug("Rename " + name + " to " + origionalName); } } - + // save the information about the rejection details Map aspectProperties = new HashMap(3); aspectProperties.put(PROP_RECORD_REJECTION_USER_ID, userId); aspectProperties.put(PROP_RECORD_REJECTION_DATE, new Date()); aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason); nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties); - - // Restore the owner of the document + + // Restore the owner of the document if (StringUtils.isBlank(documentOwner)) { throw new AlfrescoRuntimeException("Unable to find the creator of document."); } ownableService.setOwner(nodeRef, documentOwner); - + // send an email to the record creator notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner); } @@ -1068,46 +1062,46 @@ public class RecordServiceImpl implements RecordService, { ParameterCheck.mandatory("record", record); ParameterCheck.mandatory("property", property); - + if (isRecord(record) == false) { throw new AlfrescoRuntimeException("Can not check if the property " + property.toString() + " is editable, because node reference is not a record."); } - + if (logger.isDebugEnabled() == true) { logger.debug("Checking whether property " + property.toString() + " is editable for user " + AuthenticationUtil.getRunAsUser()); } - + // DEBUG ... FilePlanService fps = (FilePlanService)applicationContext.getBean("filePlanService"); FilePlanRoleService fprs = (FilePlanRoleService)applicationContext.getBean("filePlanRoleService"); PermissionService ps = (PermissionService)applicationContext.getBean("permissionService"); - - NodeRef filePlan = fps.getFilePlan(record); + + NodeRef filePlan = fps.getFilePlan(record); Set roles = fprs.getRolesByUser(filePlan, AuthenticationUtil.getRunAsUser()); - + if (logger.isDebugEnabled() == true) { logger.debug(" ... users roles"); } - + for (Role role : roles) { if (logger.isDebugEnabled() == true) { logger.debug(" ... user has role " + role.getName() + " with capabilities "); } - + for (Capability cap : role.getCapabilities()) { if (logger.isDebugEnabled() == true) { logger.debug(" ... " + cap.getName()); } - } + } } - + if (logger.isDebugEnabled() == true) { logger.debug(" ... user has the following set permissions on the file plan"); @@ -1115,14 +1109,14 @@ public class RecordServiceImpl implements RecordService, Set perms = ps.getAllSetPermissions(filePlan); for (AccessPermission perm : perms) { - if (logger.isDebugEnabled() == true && + if (logger.isDebugEnabled() == true && (perm.getPermission().contains(RMPermissionModel.EDIT_NON_RECORD_METADATA) || perm.getPermission().contains(RMPermissionModel.EDIT_RECORD_METADATA))) { logger.debug(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString()); - } + } } - + if (ps.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA).equals(AccessStatus.ALLOWED)) { if (logger.isDebugEnabled() == true) @@ -1130,9 +1124,9 @@ public class RecordServiceImpl implements RecordService, logger.debug(" ... user has the edit non record metadata permission on the file plan"); } } - + // END DEBUG ... - + boolean result = alwaysEditProperty(property); if (result == true) { @@ -1149,17 +1143,17 @@ public class RecordServiceImpl implements RecordService, AccessStatus accessNonRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_NON_RECORD_METADATA); AccessStatus accessDeclaredRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_DECLARED_RECORD_METADATA); AccessStatus accessRecord = capabilityService.getCapabilityAccessState(record, RMPermissionModel.EDIT_RECORD_METADATA); - + if (AccessStatus.ALLOWED.equals(accessNonRecord) == true) { if (logger.isDebugEnabled() == true) { logger.debug(" ... user has edit nonrecord metadata capability"); } - + allowNonRecordEdit = true; } - + if (AccessStatus.ALLOWED.equals(accessRecord) == true || AccessStatus.ALLOWED.equals(accessDeclaredRecord) == true) { @@ -1167,29 +1161,29 @@ public class RecordServiceImpl implements RecordService, { logger.debug(" ... user has edit record or declared metadata capability"); } - + allowRecordEdit = true; } - + if (allowNonRecordEdit == true && allowRecordEdit == true) { if (logger.isDebugEnabled() == true) { logger.debug(" ... so all properties can be edited."); } - + result = true; } else if (allowNonRecordEdit == true && allowRecordEdit == false) { // can only edit non record properties - if (isRecordMetadata(property) == false) + if (isRecordMetadata(property) == false) { if (logger.isDebugEnabled() == true) { logger.debug(" ... property is not considered record metadata so editable."); } - + result = true; } else @@ -1209,9 +1203,9 @@ public class RecordServiceImpl implements RecordService, { logger.debug(" ... property is considered record metadata so editable."); } - + result = true; - } + } else { if (logger.isDebugEnabled() == true) @@ -1224,17 +1218,17 @@ public class RecordServiceImpl implements RecordService, } return result; } - + /** * Helper method that indicates whether a property is considered record metadata or not. - * - * @param property property + * + * @param property property * @return boolea true if record metadata, false otherwise */ private boolean isRecordMetadata(QName property) { boolean result = ArrayUtils.contains(RECORD_MODEL_URIS, property.getNamespaceURI()); - + if (result == false && ArrayUtils.contains(NON_RECORD_MODEL_URIS, property.getNamespaceURI()) == false) { PropertyDefinition def = dictionaryService.getProperty(property); @@ -1247,13 +1241,13 @@ public class RecordServiceImpl implements RecordService, } } } - + return result; } - + /** * Determines whether the property should always be allowed to be edited or not. - * + * * @param property * @return */ @@ -1263,22 +1257,58 @@ public class RecordServiceImpl implements RecordService, ArrayUtils.contains(ALWAYS_EDIT_PROPERTIES, property) || isProtectedProperty(property)); } - + /** * Helper method to determine whether a property is protected at a dictionary definition * level. - * + * * @param property property qualified name * @return booelan true if protected, false otherwise */ private boolean isProtectedProperty(QName property) { - boolean result = false; + boolean result = false; PropertyDefinition def = dictionaryService.getProperty(property); if (def != null) { result = def.isProtected(); - } + } + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isMetadataStub(NodeRef) + */ + @Override + public boolean isMetadataStub(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return nodeService.hasAspect(nodeRef, ASPECT_GHOSTED); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecords(NodeRef) + */ + @Override + public List getRecords(NodeRef recordFolder) + { + ParameterCheck.mandatory("recordFolder", recordFolder); + + List result = new ArrayList(1); + //FIXME + RecordFolderService recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); + if (recordFolderService.isRecordFolder(recordFolder) == true) + { + List assocs = this.nodeService.getChildAssocs(recordFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef child = assoc.getChildRef(); + if (isRecord(child) == true) + { + result.add(child); + } + } + } return result; } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java index caf5a4ec0d..54b495b947 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderService.java @@ -18,15 +18,114 @@ */ package org.alfresco.module.org_alfresco_module_rm.recordfolder; +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; + /** * Record folder service interface - * - * TODO move methods from RecordManagementService - * + * * @author Roy Wetherall * @since 2.1 */ public interface RecordFolderService { - // TODO see RecordManagementService for Record Folder methods that need moving into this interface + /** + * @param nodeRef + */ + void initialiseRecordFolder(NodeRef nodeRef); + + /** + * Indicates whether the given node is a record folder or not. + * + * @param nodeRef node reference + * @return boolean true if record folder, false otherwise + */ + boolean isRecordFolder(NodeRef nodeRef); + + /** + * Indicates whether the contents of a record folder are all declared. + * + * @param nodeRef node reference (record folder) + * @return boolean true if record folder contents are declared, false otherwise + */ + boolean isRecordFolderDeclared(NodeRef nodeRef); + + /** + * Indicates whether a record folder is closed or not. + * + * @param nodeRef node reference (record folder) + * @return boolean true if record folder is closed, false otherwise + * + * @since 2.0 + */ + boolean isRecordFolderClosed(NodeRef nodeRef); + + /** + * Create a record folder in the rm container. The record folder will take the name and type + * provided. + * + * @param rmContainer records management container + * @param name name + * @param type type + * @return NodeRef node reference of record folder + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type); + + /** + * Create a record folder in the rm container. The record folder will take the name, type and + * properties provided. + * + * @param rmContainer records management container + * @param name name + * @param type type + * @param properties properties + * @return NodeRef node reference of record folder + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, QName type, Map properties); + + /** + * Create a record folder in the rm container. The record folder will take the name provided. + * Type defaults to rm:recordFolder. + * + * @param rmContainer records management container + * @param name name + * @return NodeRef node reference of record folder + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name); + + /** + * Create a record folder in the rm container. The record folder will take the name and + * properties provided. Type defaults to rm:recordFolder. + * + * @param rmContainer records management container + * @param name name + * @param properties properties + * @return NodeRef node reference of record folder + */ + NodeRef createRecordFolder(NodeRef rmContainer, String name, Map properties); + + /** + * Get all the record folders that a record is filed into. + * + * @param record the record node reference + * @return List list of folder record node references + */ + // TODO rename to List getParentRecordFolders(NodeRef record); + List getRecordFolders(NodeRef record); + + // TODO NodeRef getRecordFolderByPath(String path); + + // TODO NodeRef getRecordFolderById(String id); + + // TODO NodeRef getRecordFolderByName(NodeRef parent, String name); + + // TODO void deleteRecordFolder(NodeRef recordFolder); + + // TODO List getParentRecordsManagementContainers(NodeRef container); // also applicable to record folders + + // TODO rename to getContainedRecords(NodeRef recordFolder); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java index 3e75b406df..1060ab8a66 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/recordfolder/RecordFolderServiceImpl.java @@ -18,11 +18,19 @@ */ package org.alfresco.module.org_alfresco_module_rm.recordfolder; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; 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.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; @@ -30,42 +38,59 @@ import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.ParameterCheck; +import org.springframework.extensions.surf.util.I18NUtil; /** * Record Folder Service Implementation - * + * * @author Roy Wetherall * @since 2.1 */ public class RecordFolderServiceImpl extends ServiceBaseImpl - implements RecordFolderService, + implements RecordFolderService, RecordsManagementModel, NodeServicePolicies.OnCreateChildAssociationPolicy { + /** I18N */ + private final static String MSG_RECORD_FOLDER_EXPECTED = "rm.service.record-folder-expected"; + private final static String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root"; + private final static String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type"; + private final static String MSG_RECORD_FOLDER_TYPE = "rm.service.record-folder-type"; + /** Policy component */ private PolicyComponent policyComponent; - + /** Disposition service */ private DispositionService dispositionService; - + + /** Record Service */ + private RecordService recordService; + + /** File Plan Service */ + private FilePlanService filePlanService; + /** Behaviours */ - private JavaBehaviour onCreateChildAssociation - = new JavaBehaviour(this, - "onCreateChildAssociation", + private JavaBehaviour onCreateChildAssociation + = new JavaBehaviour(this, + "onCreateChildAssociation", NotificationFrequency.FIRST_EVENT); - private JavaBehaviour onCreateChildAssociationInRecordFolderFolder - = new JavaBehaviour(this, - "onCreateChildAssociationInRecordFolder", + private JavaBehaviour onCreateChildAssociationInRecordFolderFolder + = new JavaBehaviour(this, + "onCreateChildAssociationInRecordFolder", NotificationFrequency.FIRST_EVENT); - + /** - * @param policyComponent policy component + * @param policyComponent policy component */ public void setPolicyComponent(PolicyComponent policyComponent) { this.policyComponent = policyComponent; } - + /** * @param dispositionService disposition service */ @@ -73,21 +98,37 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl { this.dispositionService = dispositionService; } - + + /** + * @param recordService record service + */ + public void setRecordService(RecordService recordService) + { + this.recordService = recordService; + } + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + /** * Init method */ public void init() { policyComponent.bindAssociationBehaviour( - NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, - TYPE_RECORD_CATEGORY, + NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, + TYPE_RECORD_CATEGORY, ContentModel.ASSOC_CONTAINS, onCreateChildAssociation); - + policyComponent.bindAssociationBehaviour( - NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, - TYPE_RECORD_FOLDER, + NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, + TYPE_RECORD_FOLDER, ContentModel.ASSOC_CONTAINS, onCreateChildAssociationInRecordFolderFolder); } @@ -101,10 +142,10 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl NodeRef nodeRef = childAssocRef.getChildRef(); if (nodeService.exists(nodeRef) == true) { - initialiseRecordFolder(nodeRef); + initialiseRecordFolder(nodeRef); } } - + /** * Prevent folders being created within existing record folders. */ @@ -118,7 +159,7 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl { throw new AlfrescoRuntimeException("You can't create a folder within an exisiting record folder."); } - + // ensure nothing is being added to a closed record folder NodeRef recordFolder = childAssocRef.getParentRef(); Boolean isClosed = (Boolean) this.nodeService.getProperty(recordFolder, PROP_IS_CLOSED); @@ -128,11 +169,11 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl } } } - + /** - * - * @param nodeRef + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#initialiseRecordFolder(NodeRef) */ + @Override public void initialiseRecordFolder(NodeRef nodeRef) { // initialise disposition details @@ -146,4 +187,169 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl } } + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolder(NodeRef) + */ + @Override + public boolean isRecordFolder(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + return instanceOf(nodeRef, TYPE_RECORD_FOLDER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderDeclared(NodeRef) + */ + @Override + public boolean isRecordFolderDeclared(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Check we have a record folder + if (isRecordFolder(nodeRef) == false) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); + } + + boolean result = true; + + // Check that each record in the record folder in declared + + List records = recordService.getRecords(nodeRef); + for (NodeRef record : records) + { + if (recordService.isDeclared(record) == false) + { + result = false; + break; + } + } + + return result; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderClosed(NodeRef) + */ + @Override + public boolean isRecordFolderClosed(NodeRef nodeRef) + { + ParameterCheck.mandatory("nodeRef", nodeRef); + + // Check we have a record folder + if (isRecordFolder(nodeRef) == false) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED)); + } + + return ((Boolean)this.nodeService.getProperty(nodeRef, PROP_IS_CLOSED)).booleanValue(); + } + + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + QName type) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("type", type); + + return createRecordFolder(rmContainer, name, type, null); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, QName, Map) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + QName type, Map properties) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("type", type); + ParameterCheck.mandatory("properties", properties); + + // Check that we are not trying to create a record folder in a root container + if (filePlanService.isFilePlan(rmContainer) == true) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_ROOT)); + } + + // Check that the parent is a container + QName parentType = nodeService.getType(rmContainer); + if (TYPE_RECORD_CATEGORY.equals(parentType) == false && + dictionaryService.isSubClass(parentType, TYPE_RECORD_CATEGORY) == false) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARENT_RECORD_FOLDER_TYPE, parentType.toString())); + } + + // Check that the the provided type is a sub-type of rm:recordFolder + if (TYPE_RECORD_FOLDER.equals(type) == false && + dictionaryService.isSubClass(type, TYPE_RECORD_FOLDER) == false) + { + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_TYPE, type.toString())); + } + + Map props = new HashMap(1); + if (properties != null && properties.size() != 0) + { + props.putAll(properties); + } + props.put(ContentModel.PROP_NAME, name); + + return nodeService.createNode( + rmContainer, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), + type, + props).getChildRef(); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + + // TODO defaults to rm:recordFolder, but in future could auto-detect sub-type of folder based on context + return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER); + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#createRecordFolder(NodeRef, String, Map) + */ + @Override + public NodeRef createRecordFolder(NodeRef rmContainer, String name, + Map properties) + { + ParameterCheck.mandatory("rmContainer", rmContainer); + ParameterCheck.mandatoryString("name", name); + ParameterCheck.mandatory("properties", properties); + + return createRecordFolder(rmContainer, name, TYPE_RECORD_FOLDER, properties); + } + + @Override + public List getRecordFolders(NodeRef record) + { + ParameterCheck.mandatory("record", record); + + List result = new ArrayList(1); + if (recordService.isRecord(record) == true) + { + List assocs = this.nodeService.getParentAssocs(record, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef assoc : assocs) + { + NodeRef parent = assoc.getParentRef(); + if (isRecordFolder(parent) == true) + { + result.add(parent); + } + } + } + return result; + } + } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java index 315d16c0ca..b64abf5791 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/AbstractRmWebScript.java @@ -23,7 +23,6 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -36,22 +35,21 @@ import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; /** - * + * * @author Neil McErlean */ public abstract class AbstractRmWebScript extends DeclarativeWebScript { protected NodeService nodeService; - protected RecordsManagementService rmService; protected DispositionService dispositionService; protected NamespaceService namespaceService; /** * Parses the request and providing it's valid returns the NodeRef. - * + * * @param req The webscript request * @return The NodeRef passed in the request - * + * * @author Gavin Cornwell */ protected NodeRef parseRequestForNodeRef(WebScriptRequest req) @@ -62,28 +60,18 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript String storeType = templateVars.get("store_type"); String storeId = templateVars.get("store_id"); String nodeId = templateVars.get("id"); - + // create the NodeRef and ensure it is valid StoreRef storeRef = new StoreRef(storeType, storeId); NodeRef nodeRef = new NodeRef(storeRef, nodeId); - + if (!this.nodeService.exists(nodeRef)) { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef.toString()); } - - return nodeRef; - } - /** - * Sets the RecordsManagementService instance - * - * @param rmService The RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; + return nodeRef; } /** @@ -93,10 +81,10 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript { this.dispositionService = dispositionService; } - + /** * Sets the NodeService instance - * + * * @param nodeService The NodeService instance */ public void setNodeService(NodeService nodeService) @@ -106,7 +94,7 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript /** * Sets the NamespaceService instance - * + * * @param namespaceService The NamespaceService instance */ public void setNamespaceService(NamespaceService namespaceService) @@ -116,7 +104,7 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript /** * This method checks if the json object contains an entry with the specified name. - * + * * @param json the json object. * @param paramName the name to check for. * @throws WebScriptException if the specified entry is missing. @@ -132,7 +120,7 @@ public abstract class AbstractRmWebScript extends DeclarativeWebScript /** * This method checks if the json object contains entries with the specified names. - * + * * @param json the json object. * @param paramNames the names to check for. * @throws WebScriptException if any of the specified entries are missing. diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java index 845b15bb58..42f293300a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/BootstrapTestDataGet.java @@ -327,7 +327,7 @@ public class BootstrapTestDataGet extends DeclarativeWebScript { // Fire action to "set-up" the folder correctly logger.info("Setting up bootstraped record folder: " + folderName); - RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("recordFolderService"); + RecordFolderServiceImpl recordService = (RecordFolderServiceImpl)applicationContext.getBean("RecordFolderService"); recordService.initialiseRecordFolder(recordFolder); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java index 1f183609ad..124fa9ed6b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionPut.java @@ -28,21 +28,19 @@ import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminSe import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition; import org.alfresco.service.namespace.QName; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; /** * Implementation for Java backed webscript to update RM custom reference definitions. * There is currently only support for updating the label (for bidirectional references) or * the source/target (for parent/child references). - * + * * @author Neil McErlean */ public class CustomReferenceDefinitionPut extends AbstractRmWebScript @@ -53,11 +51,8 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript private static final String SOURCE = "source"; private static final String LABEL = "label"; - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(CustomReferenceDefinitionPut.class); - private RecordsManagementAdminService rmAdminService; - + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) { this.rmAdminService = rmAdminService; @@ -74,7 +69,7 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript try { json = new JSONObject(new JSONTokener(req.getContent().getContent())); - + ftlModel = updateCustomReference(req, json); } catch (IOException iox) @@ -92,10 +87,10 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, iae.getMessage(), iae); } - + return ftlModel; } - + /** * Applies custom properties. */ @@ -104,12 +99,12 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript { Map result = new HashMap(); Map params = new HashMap(); - + for (Iterator iter = json.keys(); iter.hasNext(); ) { String nextKeyString = (String)iter.next(); Serializable nextValue = (Serializable)json.get(nextKeyString); - + params.put(nextKeyString, nextValue); } @@ -125,11 +120,11 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript throw new WebScriptException(Status.STATUS_NOT_FOUND, "Could not find reference definition for: " + refId); } - + String newLabel = (String)params.get(LABEL); String newSource = (String)params.get(SOURCE); String newTarget = (String)params.get(TARGET); - + // Determine whether it's a bidi or a p/c ref AssociationDefinition assocDef = rmAdminService.getCustomReferenceDefinitions().get(refQName); if (assocDef == null) @@ -137,7 +132,7 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript throw new WebScriptException(Status.STATUS_NOT_FOUND, "Could not find reference definition for: " + refId); } - + if (assocDef instanceof ChildAssociationDefinition) { if (newSource != null || newTarget != null) @@ -149,11 +144,11 @@ public class CustomReferenceDefinitionPut extends AbstractRmWebScript { rmAdminService.updateCustomAssocDefinition(refQName, newLabel); } - + result.put(URL, req.getServicePath()); result.put("refId", refQName.getLocalName()); result.put("success", Boolean.TRUE); - + return result; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java index 33abb27ce5..799ea70888 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java @@ -30,8 +30,6 @@ import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; @@ -39,24 +37,20 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * This class provides the implementation for the customisable.get webscript. - * + * * @author Roy Wetherall */ public class CustomisableGet extends DeclarativeWebScript { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(CustomisableGet.class); - /** Records management admin service */ private RecordsManagementAdminService rmAdminService; - + /** Dictionary service */ private DictionaryService dictionaryService; - + /** Namespace service */ private NamespaceService namespaceService; - + /** * @param rmAdminService records management admin service */ @@ -64,11 +58,11 @@ public class CustomisableGet extends DeclarativeWebScript { this.rmAdminService = rmAdminService; } - + /** * @param namespaceService namespace service */ - public void setNamespaceService(NamespaceService namespaceService) + public void setNamespaceService(NamespaceService namespaceService) { this.namespaceService = namespaceService; } @@ -76,7 +70,7 @@ public class CustomisableGet extends DeclarativeWebScript /** * @param dictionaryService dictionary service */ - public void setDictionaryService(DictionaryService dictionaryService) + public void setDictionaryService(DictionaryService dictionaryService) { this.dictionaryService = dictionaryService; } @@ -87,7 +81,7 @@ public class CustomisableGet extends DeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + Set qnames = rmAdminService.getCustomisable(); ArrayList items = new ArrayList(qnames.size()); for (QName qname : qnames) @@ -102,11 +96,11 @@ public class CustomisableGet extends DeclarativeWebScript title = qname.getLocalName(); } boolean isAspect = definition.isAspect(); - + items.add(new Item(name, isAspect, title)); } } - + // Sort the customisable types and aspects by title Collections.sort(items, new Comparator() { @@ -115,11 +109,11 @@ public class CustomisableGet extends DeclarativeWebScript { return o1.title.compareToIgnoreCase(o2.title); }}); - - model.put("items", items); + + model.put("items", items); return model; } - + /** * Model items */ @@ -128,36 +122,36 @@ public class CustomisableGet extends DeclarativeWebScript private String name; private boolean isAspect; private String title; - + public Item(String name, boolean isAspect, String title) { this.name = name; this.isAspect = isAspect; this.title = title; } - + public String getName() { return name; } - + public boolean getIsAspect() { return isAspect; } - + public String getTitle() { return title; } - + @Override public int hashCode() { int var_code = (null == name ? 0 : name.hashCode()); return 31 + var_code; } - + @Override public boolean equals(Object obj) { @@ -170,5 +164,5 @@ public class CustomisableGet extends DeclarativeWebScript return this.name.equals(((Item)obj).name); } } - } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java index fc727688c3..a2f025dce5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ImportPost.java @@ -28,7 +28,6 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; 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; @@ -50,8 +49,8 @@ import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.extensions.webscripts.WrappingWebScriptRequest; -import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; import org.springframework.extensions.webscripts.servlet.FormData.FormField; +import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest; import org.springframework.util.FileCopyUtils; /** @@ -73,7 +72,6 @@ public class ImportPost extends DeclarativeWebScript protected NodeService nodeService; protected DictionaryService dictionaryService; protected ImporterService importerService; - protected RecordsManagementService rmService; protected FilePlanRoleService filePlanRoleService; protected FilePlanService filePlanService; @@ -113,16 +111,6 @@ public class ImportPost extends DeclarativeWebScript this.filePlanRoleService = filePlanRoleService; } - /** - * Sets the RecordsManagementService instance - * - * @param rmService The RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * @param filePlanService file plan service */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java index a12d465759..26a84cdae2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; @@ -54,7 +53,6 @@ import org.springframework.util.StringUtils; */ public class ListOfValuesGet extends DeclarativeWebScript { - protected RecordsManagementService rmService; protected RecordsManagementActionService rmActionService; protected RecordsManagementAuditService rmAuditService; protected RecordsManagementEventService rmEventService; @@ -62,16 +60,6 @@ public class ListOfValuesGet extends DeclarativeWebScript protected DictionaryService ddService; protected NamespaceService namespaceService; - /** - * Sets the RecordsManagementService instance - * - * @param rmService The RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * Sets the RecordsManagementActionService instance * diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java index 35359155cf..1c5ef756d3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportGet.java @@ -26,7 +26,6 @@ import java.util.Date; import java.util.List; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; 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.model.RecordsManagementModel; @@ -59,7 +58,6 @@ public class TransferReportGet extends BaseTransferWebScript protected static final String REPORT_FILE_SUFFIX = ".json"; protected DictionaryService ddService; - protected RecordsManagementService rmService; protected DispositionService dispositionService; protected ContentStreamer contentStreamer; @@ -83,16 +81,6 @@ public class TransferReportGet extends BaseTransferWebScript this.dispositionService = dispositionService; } - /** - * Sets the RecordsManagementService instance - * - * @param rmService RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * @param contentStreamer */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java index b6cf3de032..4d48186417 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java @@ -31,7 +31,6 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.alfresco.model.ContentModel; -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.disposition.DispositionSchedule; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; @@ -77,7 +76,6 @@ public class TransferReportPost extends BaseTransferWebScript protected DictionaryService ddService; protected RecordsManagementActionService rmActionService; - protected RecordsManagementService rmService; protected DispositionService dispositionService; protected ContentService contentService; @@ -91,16 +89,6 @@ public class TransferReportPost extends BaseTransferWebScript this.ddService = ddService; } - /** - * Sets the RecordsManagementService instance - * - * @param rmService RecordsManagementService instance - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - /** * Sets the disposition service * diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java index 10df5a2354..f89066c943 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/UserRightsReportGet.java @@ -26,7 +26,6 @@ import java.util.Set; import javax.servlet.http.HttpServletResponse; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.role.Role; @@ -42,7 +41,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * Implementation for Java backed webscript to return user rights report. - * + * * @author Gavin Cornwell */ public class UserRightsReportGet extends DeclarativeWebScript @@ -50,48 +49,39 @@ public class UserRightsReportGet extends DeclarativeWebScript protected AuthorityService authorityService; protected PersonService personService; protected NodeService nodeService; - protected RecordsManagementService rmService; protected FilePlanRoleService filePlanRoleService; protected FilePlanService filePlanService; - + /** * Sets the AuthorityService instance - * - * @param authorityService AuthorityService instance + * + * @param authorityService AuthorityService instance */ public void setAuthorityService(AuthorityService authorityService) { this.authorityService = authorityService; } - + /** * Sets the PersonService instance - * - * @param personService PersonService instance + * + * @param personService PersonService instance */ public void setPersonService(PersonService personService) { this.personService = personService; } - + /** * Sets the NodeService instance - * - * @param nodeService NodeService instance + * + * @param nodeService NodeService instance */ public void setNodeService(NodeService nodeService) { - this.nodeService = nodeService; + this.nodeService = nodeService; } - - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.rmService = recordsManagementService; - } - + /** * @param filePlanRoleService file plan role service */ @@ -99,15 +89,15 @@ public class UserRightsReportGet extends DeclarativeWebScript { this.filePlanRoleService = filePlanRoleService; } - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + /* * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) */ @@ -115,19 +105,19 @@ public class UserRightsReportGet extends DeclarativeWebScript protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { NodeRef filePlanNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); - + if (filePlanNode == null) { - status.setCode(HttpServletResponse.SC_BAD_REQUEST, + status.setCode(HttpServletResponse.SC_BAD_REQUEST, "The default RM site could not be found."); return null; } - - // construct all the maps etc. needed to build the model + + // construct all the maps etc. needed to build the model Map usersMap = new HashMap(8); Map rolesMap = new HashMap(8); Map groupsMap = new HashMap(8); - + // iterate over all the roles for the file plan and construct models Set roles = filePlanRoleService.getRoles(filePlanNode); for (Role role : roles) @@ -140,12 +130,12 @@ public class UserRightsReportGet extends DeclarativeWebScript roleModel = new RoleModel(role); rolesMap.put(roleName, roleModel); } - + // get the users for the current RM role String group = role.getRoleGroupName(); Set users = authorityService.getContainedAuthorities(AuthorityType.USER, group, true); roleModel.setUsers(users); - + // setup a user model object for each user for (String userName : users) { @@ -153,30 +143,30 @@ public class UserRightsReportGet extends DeclarativeWebScript if (userModel == null) { NodeRef userRef = this.personService.getPerson(userName); - userModel = new UserModel(userName, - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), + userModel = new UserModel(userName, + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); usersMap.put(userName, userModel); } - + userModel.addRole(roleName); } - + // get the groups for the cuurent RM role Set groups = authorityService.getContainedAuthorities(AuthorityType.GROUP, group, false); roleModel.setGroups(groups); - + // setup a user model object for each user in each group for (String groupName : groups) { GroupModel groupModel = groupsMap.get(groupName); if (groupModel == null) { - groupModel = new GroupModel(groupName, + groupModel = new GroupModel(groupName, authorityService.getAuthorityDisplayName(groupName)); groupsMap.put(groupName, groupModel); } - + // get users in each group Set groupUsers = this.authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true); for (String userName : groupUsers) @@ -185,31 +175,31 @@ public class UserRightsReportGet extends DeclarativeWebScript if (userModel == null) { NodeRef userRef = this.personService.getPerson(userName); - userModel = new UserModel(userName, - (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), + userModel = new UserModel(userName, + (String)this.nodeService.getProperty(userRef, ContentModel.PROP_FIRSTNAME), (String)this.nodeService.getProperty(userRef, ContentModel.PROP_LASTNAME)); usersMap.put(userName, userModel); } - + userModel.addGroup(groupName); userModel.addRole(roleName); groupModel.addUser(userName); } } } - + // add all the lists data to a Map Map reportModel = new HashMap(4); reportModel.put("users", usersMap); reportModel.put("roles", rolesMap); reportModel.put("groups", groupsMap); - + // create model object with the lists model Map model = new HashMap(1); model.put("report", reportModel); return model; } - + /** * Class to represent a role for use in a Freemarker template. * @@ -219,43 +209,43 @@ public class UserRightsReportGet extends DeclarativeWebScript { private Set users = new HashSet(8); private Set groups = new HashSet(8); - + public RoleModel(Role role) { super(role.getName(), role.getDisplayLabel(), role.getCapabilities(), role.getRoleGroupName()); } - + public void addUser(String username) { this.users.add(username); } - + public void addGroup(String groupName) { this.groups.add(groupName); } - + public void setUsers(Set users) { this.users = users; } - + public void setGroups(Set groups) { this.groups = groups; } - + public Set getUsers() { return this.users; } - + public Set getGroups() { return this.groups; } } - + /** * Class to represent a user for use in a Freemarker template. * @@ -268,7 +258,7 @@ public class UserRightsReportGet extends DeclarativeWebScript private String lastName; private Set roles; private Set groups; - + public UserModel(String userName, String firstName, String lastName) { this.userName = userName; @@ -297,23 +287,23 @@ public class UserRightsReportGet extends DeclarativeWebScript { return this.roles; } - + public Set getGroups() { return this.groups; } - + public void addRole(String roleName) { this.roles.add(roleName); } - + public void addGroup(String groupName) { this.groups.add(groupName); } } - + /** * Class to represent a group for use in a Freemarker template. * @@ -324,7 +314,7 @@ public class UserRightsReportGet extends DeclarativeWebScript private String name; private String label; private Set users; - + public GroupModel(String name, String label) { this.name = name; @@ -346,7 +336,7 @@ public class UserRightsReportGet extends DeclarativeWebScript { return this.users; } - + public void addUser(String userName) { this.users.add(userName); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java index e5d8b0501c..68055798c0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventDelete.java @@ -27,25 +27,20 @@ import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Records management event delete web script - * + * * @author Roy Wetherall */ public class RmEventDelete extends DeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventDelete.class); - /** Reccords management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -60,7 +55,7 @@ public class RmEventDelete extends DeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Event name Map templateVars = req.getServiceMatch().getTemplateVars(); String eventName = templateVars.get("eventname"); @@ -68,16 +63,16 @@ public class RmEventDelete extends DeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided on the URL."); } - + // Check the event exists if (rmEventService.existsEvent(eventName) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); } - + // Remove the event rmEventService.removeEvent(eventName); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java index ad01f08864..a2292de8cb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventGet.java @@ -28,25 +28,20 @@ import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Records management event GET web script - * + * * @author Roy Wetherall */ public class RmEventGet extends DeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventGet.class); - /** Reccords management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -58,7 +53,7 @@ public class RmEventGet extends DeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Event name Map templateVars = req.getServiceMatch().getTemplateVars(); String eventName = templateVars.get("eventname"); @@ -66,17 +61,17 @@ public class RmEventGet extends DeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided on the URL."); } - + // Check the event exists if (rmEventService.existsEvent(eventName) == false) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); } - + // Get the event RecordsManagementEvent event = rmEventService.getEvent(eventName); model.put("event", event); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java index 2b9a57a1f5..bcd4515e14 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventTypesGet.java @@ -28,25 +28,20 @@ import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Records management event types GET web script - * + * * @author Roy Wetherall */ public class RmEventTypesGet extends DeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventTypesGet.class); - /** Reccords management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -58,11 +53,11 @@ public class RmEventTypesGet extends DeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Get the events List events = rmEventService.getEventTypes(); model.put("eventtypes", events); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java index 91d0c96ef2..f13f53c51c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsGet.java @@ -28,25 +28,20 @@ import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * Records management events GET web script - * + * * @author Roy Wetherall */ public class RmEventsGet extends DeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventsGet.class); - /** Reccords management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -58,11 +53,11 @@ public class RmEventsGet extends DeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Get the events List events = rmEventService.getEvents(); model.put("events", events); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java index cc5b7c774d..85a53d9ff8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleDelete.java @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; @@ -31,15 +29,11 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * Delete role web script - * + * * @author Roy Wetherall */ public class RmRoleDelete extends RoleDeclarativeWebScript { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRoleDelete.class); - /** * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) */ @@ -47,7 +41,7 @@ public class RmRoleDelete extends RoleDeclarativeWebScript public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Role name Map templateVars = req.getServiceMatch().getTemplateVars(); String roleParam = templateVars.get("rolename"); @@ -55,23 +49,23 @@ public class RmRoleDelete extends RoleDeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); } - + // get the file plan NodeRef filePlan = getFilePlan(req); if (filePlan == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); } - + // Check that the role exists if (filePlanRoleService.existsRole(filePlan, roleParam) == false) { - throw new WebScriptException(Status.STATUS_NOT_FOUND, + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + filePlan.toString()); } - + filePlanRoleService.deleteRole(filePlan, roleParam); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java index d6d0251089..4d905915ba 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRoleGet.java @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; @@ -31,19 +29,16 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * Role GET web script API - * + * * @author Roy Wetherall */ public class RmRoleGet extends RoleDeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRoleGet.class); - @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + // Role name Map templateVars = req.getServiceMatch().getTemplateVars(); String roleParam = templateVars.get("rolename"); @@ -51,24 +46,24 @@ public class RmRoleGet extends RoleDeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); } - + // get the file plan NodeRef filePlan = getFilePlan(req); if (filePlan == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); } - + // Check that the role exists if (filePlanRoleService.existsRole(filePlan, roleParam) == false) { - throw new WebScriptException(Status.STATUS_NOT_FOUND, + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + filePlan); } - + RoleItem item = new RoleItem(filePlanRoleService.getRole(filePlan, roleParam)); model.put("role", item); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java index cc8b10d644..7c73cd1255 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolePut.java @@ -28,8 +28,6 @@ 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.role.Role; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -40,17 +38,14 @@ import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; /** - * - * + * + * * @author Roy Wetherall */ public class RmRolePut extends RoleDeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRolePut.class); - private CapabilityService capabilityService; - + public void setCapabilityService(CapabilityService capabilityService) { this.capabilityService = capabilityService; @@ -59,7 +54,7 @@ public class RmRolePut extends RoleDeclarativeWebScript @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - Map model = new HashMap(); + Map model = new HashMap(); JSONObject json = null; try { @@ -70,38 +65,38 @@ public class RmRolePut extends RoleDeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "No role name was provided on the URL."); } - + json = new JSONObject(new JSONTokener(req.getContent().getContent())); String name = json.getString("name"); // TODO check String displayLabel = json.getString("displayLabel"); // TODO check - + JSONArray capabilitiesArray = json.getJSONArray("capabilities"); Set capabilites = new HashSet(capabilitiesArray.length()); for (int i = 0; i < capabilitiesArray.length(); i++) { - Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); + Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); capabilites.add(capability); } - + // get the file plan NodeRef filePlan = getFilePlan(req); if (filePlan == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); } - + // Check that the role exists if (filePlanRoleService.existsRole(filePlan, roleParam) == false) { - throw new WebScriptException(Status.STATUS_NOT_FOUND, + throw new WebScriptException(Status.STATUS_NOT_FOUND, "The role " + roleParam + " does not exist on the records managment root " + filePlan); } - - Role role = filePlanRoleService.updateRole(filePlan, name, displayLabel, capabilites); + + Role role = filePlanRoleService.updateRole(filePlan, name, displayLabel, capabilites); model.put("role", new RoleItem(role)); - + } catch (IOException iox) { @@ -113,7 +108,7 @@ public class RmRolePut extends RoleDeclarativeWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java index 188260c52a..9a49f21128 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java @@ -24,8 +24,6 @@ import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.role.Role; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; @@ -38,10 +36,6 @@ import org.springframework.extensions.webscripts.WebScriptRequest; */ public class RmRolesGet extends RoleDeclarativeWebScript { - /** Logger */ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRolesGet.class); - /** * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) */ @@ -57,7 +51,7 @@ public class RmRolesGet extends RoleDeclarativeWebScript { throw new WebScriptException(Status.STATUS_FOUND, "File plan does not exist."); } - + // get the includesystem parameter boolean includeSystem = false; String includeSystemValue = req.getParameter("is"); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java index 663481ba5f..837bcbe01e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesPost.java @@ -28,8 +28,6 @@ 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.role.Role; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -41,16 +39,13 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * RM Roles Post implementation - * + * * @author Roy Wetherall */ public class RmRolesPost extends RoleDeclarativeWebScript { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmRolesPost.class); - private CapabilityService capabilityService; - + public void setCapabilityService(CapabilityService capabilityService) { this.capabilityService = capabilityService; @@ -59,7 +54,7 @@ public class RmRolesPost extends RoleDeclarativeWebScript @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - Map model = new HashMap(); + Map model = new HashMap(); JSONObject json = null; try { @@ -68,25 +63,25 @@ public class RmRolesPost extends RoleDeclarativeWebScript // TODO check String displayString = json.getString("displayLabel"); // TODO check - + JSONArray capabilitiesArray = json.getJSONArray("capabilities"); Set capabilites = new HashSet(capabilitiesArray.length()); for (int i = 0; i < capabilitiesArray.length(); i++) { - Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); + Capability capability = capabilityService.getCapability(capabilitiesArray.getString(i)); capabilites.add(capability); } - + // get the file plan NodeRef filePlan = getFilePlan(req); if (filePlan == null) { throw new WebScriptException(Status.STATUS_NOT_FOUND, "File plan does not exist."); } - - Role role = filePlanRoleService.createRole(filePlan, name, displayString, capabilites); + + Role role = filePlanRoleService.createRole(filePlan, name, displayString, capabilites); model.put("role", new RoleItem(role)); - + } catch (IOException iox) { @@ -98,7 +93,7 @@ public class RmRolesPost extends RoleDeclarativeWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java index 0fa9ad8e19..a4f681db98 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/ExtendedSecurityServiceImpl.java @@ -45,7 +45,7 @@ import org.alfresco.util.ParameterCheck; /** * Extended security service implementation. - * + * * @author Roy Wetherall * @since 2.1 */ @@ -57,19 +57,19 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl /** Ad hoc properties used for reference counting */ private final static QName PROP_EXTENDED_READER_ROLE = QName.createQName(RM_URI, "extendedReaderRole"); private final static QName PROP_EXTENDED_WRITER_ROLE = QName.createQName(RM_URI, "extendedWriterRole"); - + /** Policy component */ private PolicyComponent policyComponent; - + /** Record service */ private RecordService recordService; - + /** File plan service */ private FilePlanService filePlanService; - + /** File plan role service */ private FilePlanRoleService filePlanRoleService; - + /** * @param policyComponent policy component */ @@ -77,7 +77,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { this.policyComponent = policyComponent; } - + /** * @param recordService record service */ @@ -85,7 +85,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { this.recordService = recordService; } - + /** * @param filePlanService file plan service */ @@ -93,7 +93,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { this.filePlanService = filePlanService; } - + /** * @param filePlanRoleService file plan role service */ @@ -101,18 +101,18 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { this.filePlanRoleService = filePlanRoleService; } - + /** * Init method */ public void init() { policyComponent.bindClassBehaviour( - NodeServicePolicies.OnMoveNodePolicy.QNAME, - ASPECT_EXTENDED_SECURITY, + NodeServicePolicies.OnMoveNodePolicy.QNAME, + ASPECT_EXTENDED_SECURITY, new JavaBehaviour(this, "onMoveNode", NotificationFrequency.TRANSACTION_COMMIT)); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#hasExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef) */ @@ -120,7 +120,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { return nodeService.hasAspect(nodeRef, ASPECT_EXTENDED_SECURITY); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#getExtendedReaders(org.alfresco.service.cmr.repository.NodeRef) */ @@ -129,16 +129,16 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl public Set getExtendedReaders(NodeRef nodeRef) { Set result = null; - + Map readerMap = (Map)nodeService.getProperty(nodeRef, PROP_READERS); if (readerMap != null) { result = readerMap.keySet(); } - + return result; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#getExtendedWriters(org.alfresco.service.cmr.repository.NodeRef) */ @@ -147,13 +147,13 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl public Set getExtendedWriters(NodeRef nodeRef) { Set result = null; - + Map map = (Map)nodeService.getProperty(nodeRef, PROP_WRITERS); if (map != null) { result = map.keySet(); } - + return result; } @@ -165,7 +165,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { addExtendedSecurity(nodeRef, readers, writers, true); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService#addExtendedSecurity(org.alfresco.service.cmr.repository.NodeRef, java.util.Set, java.util.Set, boolean) */ @@ -174,45 +174,45 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("applyToParents", applyToParents); - + if (nodeRef != null) { addExtendedSecurityImpl(nodeRef, readers, writers, applyToParents); } } - + @SuppressWarnings("unchecked") private void addExtendedSecurityImpl(NodeRef nodeRef, Set readers, Set writers, boolean applyToParents) { ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("applyToParents", applyToParents); - + // add the aspect if missing if (nodeService.hasAspect(nodeRef, ASPECT_EXTENDED_SECURITY) == false) { nodeService.addAspect(nodeRef, ASPECT_EXTENDED_SECURITY, null); } - + // update the readers map if (readers != null && readers.size() != 0) { // get reader map Map readersMap = (Map)nodeService.getProperty(nodeRef, PROP_READERS); - + // set the readers property (this will in turn apply the aspect if required) nodeService.setProperty(nodeRef, PROP_READERS, (Serializable)addToMap(readersMap, readers)); } - + // update the writers map if (writers != null && writers.size() != 0) { // get writer map Map writersMap = (Map)nodeService.getProperty(nodeRef, PROP_WRITERS); - + // set the writers property (this will in turn apply the aspect if required) nodeService.setProperty(nodeRef, PROP_WRITERS, (Serializable)addToMap(writersMap, writers)); } - + // apply the readers to any renditions of the content if (recordService.isRecord(nodeRef) == true) { @@ -223,12 +223,12 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl addExtendedSecurityImpl(child, readers, writers, false); } } - + // add to the extended security roles addExtendedSecurityRoles(nodeRef, readers, writers); - + if (applyToParents == true) - { + { // apply the extended readers up the file plan primary hierarchy NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef(); if (parent != null && @@ -237,11 +237,11 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl addExtendedSecurityImpl(parent, readers, null, applyToParents); addExtendedSecurityImpl(parent, writers, null, applyToParents); } - } + } } - + /** - * + * * @param nodeRef * @param readers * @param writers @@ -249,13 +249,13 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl private void addExtendedSecurityRoles(NodeRef nodeRef, Set readers, Set writers) { NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - + addExtendedSecurityRolesImpl(filePlan, readers, PROP_EXTENDED_READER_ROLE, FilePlanRoleService.ROLE_EXTENDED_READERS); addExtendedSecurityRolesImpl(filePlan, writers, PROP_EXTENDED_WRITER_ROLE, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - } - + } + /** - * + * * @param filePlan * @param authorities * @param propertyName @@ -268,9 +268,9 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { // get the reference count Map referenceCountMap = (Map)nodeService.getProperty(filePlan, propertyName); - + for (String authority : authorities) - { + { if (authority.equals(PermissionService.ALL_AUTHORITIES) == false && authority.equals(PermissionService.OWNER_AUTHORITY) == false) { @@ -282,57 +282,55 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl } } } - + // update the reference count nodeService.setProperty(filePlan, propertyName, (Serializable)addToMap(referenceCountMap, authorities)); - } + } } - - @SuppressWarnings("unused") - private void removeExtendedSecurityRoles(NodeRef nodeRef, Set readers, Set writers) - { - NodeRef filePlan = filePlanService.getFilePlan(nodeRef); - - removeExtendedSecurityRolesImpl(filePlan, readers, PROP_EXTENDED_READER_ROLE, FilePlanRoleService.ROLE_EXTENDED_READERS); - removeExtendedSecurityRolesImpl(filePlan, writers, PROP_EXTENDED_WRITER_ROLE, FilePlanRoleService.ROLE_EXTENDED_WRITERS); - } - - @SuppressWarnings("unchecked") - private void removeExtendedSecurityRolesImpl(NodeRef filePlan, Set authorities, QName propertyName, String roleName) - { - if (authorities != null) - { - // get the reference count - Map referenceCountMap = (Map)nodeService.getProperty(filePlan, propertyName); - - for (String authority : authorities) - { - if (authority.equals(PermissionService.ALL_AUTHORITIES) == false) - { - if (referenceCountMap == null) - { - // remove the authority from the role - filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority); - } - else - { - Integer count = referenceCountMap.get(authority); - if (count == null || count == 1) - { - // remove the authority from the role - filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority); - } - } - } - } - - // update the reference count - nodeService.setProperty(filePlan, propertyName, (Serializable)removeFromMap(referenceCountMap, authorities)); - } - } - + +// private void removeExtendedSecurityRoles(NodeRef nodeRef, Set readers, Set writers) +// { +// NodeRef filePlan = filePlanService.getFilePlan(nodeRef); +// +// removeExtendedSecurityRolesImpl(filePlan, readers, PROP_EXTENDED_READER_ROLE, FilePlanRoleService.ROLE_EXTENDED_READERS); +// removeExtendedSecurityRolesImpl(filePlan, writers, PROP_EXTENDED_WRITER_ROLE, FilePlanRoleService.ROLE_EXTENDED_WRITERS); +// } +// +// private void removeExtendedSecurityRolesImpl(NodeRef filePlan, Set authorities, QName propertyName, String roleName) +// { +// if (authorities != null) +// { +// // get the reference count +// Map referenceCountMap = (Map)nodeService.getProperty(filePlan, propertyName); +// +// for (String authority : authorities) +// { +// if (authority.equals(PermissionService.ALL_AUTHORITIES) == false) +// { +// if (referenceCountMap == null) +// { +// // remove the authority from the role +// filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority); +// } +// else +// { +// Integer count = referenceCountMap.get(authority); +// if (count == null || count == 1) +// { +// // remove the authority from the role +// filePlanRoleService.unassignRoleFromAuthority(filePlan, roleName, authority); +// } +// } +// } +// } +// +// // update the reference count +// nodeService.setProperty(filePlan, propertyName, (Serializable)removeFromMap(referenceCountMap, authorities)); +// } +// } + /** - * + * * @param map * @param keys * @return @@ -344,7 +342,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl // create map map = new HashMap(7); } - + for (String key : keys) { if (key.equals(PermissionService.ALL_AUTHORITIES) == false) @@ -362,24 +360,24 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl } } } - + return map; } - + @Override public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Set writers) { - removeExtendedSecurity(nodeRef, readers, writers, true); + removeExtendedSecurity(nodeRef, readers, writers, true); } - + @Override public void removeExtendedSecurity(NodeRef nodeRef, Set readers, Setwriters, boolean applyToParents) { if (hasExtendedSecurity(nodeRef) == true) { removeExtendedSecurityImpl(nodeRef, readers, writers); - + // remove the readers from any renditions of the content if (recordService.isRecord(nodeRef) == true) { @@ -390,7 +388,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl removeExtendedSecurityImpl(child, readers, writers); } } - + if (applyToParents == true) { // apply the extended readers up the file plan primary hierarchy @@ -400,16 +398,16 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { removeExtendedSecurity(parent, readers, null, applyToParents); removeExtendedSecurity(parent, writers, null, applyToParents); - } + } } } } - + /** * Removes a set of readers and writers from a node reference. *

    * Removes the aspect and resets the property to null if all readers and writers are removed. - * + * * @param nodeRef node reference * @param readers {@link Set} of readers * @param writers {@link Set} of writers @@ -419,17 +417,17 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl { Map readersMap = (Map)nodeService.getProperty(nodeRef, PROP_READERS); nodeService.setProperty(nodeRef, PROP_READERS, (Serializable)removeFromMap(readersMap, readers)); - + Map writersMap = (Map)nodeService.getProperty(nodeRef, PROP_WRITERS); nodeService.setProperty(nodeRef, PROP_WRITERS, (Serializable)removeFromMap(writersMap, writers)); - + if (readersMap == null && writersMap == null) { // remove the aspect nodeService.removeAspect(nodeRef, ASPECT_EXTENDED_SECURITY); - } + } } - + private Map removeFromMap(Map map, Set keys) { if (map != null && keys != null && keys.size() != 0) @@ -456,29 +454,29 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl } } } - + // reset the map to null if now empty if (map != null && map.isEmpty() == true) { map = null; } - + return map; } - + @Override public void removeAllExtendedSecurity(NodeRef nodeRef) { removeAllExtendedSecurity(nodeRef, true); } - + @Override public void removeAllExtendedSecurity(NodeRef nodeRef, boolean applyToParents) { if (hasExtendedSecurity(nodeRef) == true) { - removeExtendedSecurity(nodeRef, getExtendedReaders(nodeRef), getExtendedWriters(nodeRef)); - } + removeExtendedSecurity(nodeRef, getExtendedReaders(nodeRef), getExtendedWriters(nodeRef)); + } } /** @@ -487,7 +485,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl @Override public void onMoveNode(final ChildAssociationRef origAssoc, final ChildAssociationRef newAssoc) { - AuthenticationUtil.runAsSystem(new RunAsWork() + AuthenticationUtil.runAsSystem(new RunAsWork() { @Override public Void doWork() throws Exception @@ -495,13 +493,13 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl NodeRef record = newAssoc.getChildRef(); NodeRef newParent = newAssoc.getParentRef(); NodeRef oldParent = origAssoc.getParentRef(); - + Set readers = getExtendedReaders(record); Set writers = getExtendedWriters(record); - + addExtendedSecurity(newParent, readers, writers); removeExtendedSecurity(oldParent, readers, writers); - + return null; } }); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java index e821ab5e19..a0c7b566b1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/FilePlanPermissionServiceImpl.java @@ -23,11 +23,11 @@ import java.util.List; import java.util.Set; import org.alfresco.model.ContentModel; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; 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.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; @@ -48,7 +48,7 @@ import org.apache.commons.logging.LogFactory; /** * File plan permission service. - * + * * @author Roy Wetherall * @since 2.1 */ @@ -62,18 +62,18 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl /** Policy component */ protected PolicyComponent policyComponent; - /** Records management service */ - protected RecordsManagementService recordsManagementService; - /** File plan service */ protected FilePlanService filePlanService; - + /** Record service */ protected RecordService recordService; + /** Record folder service */ + protected RecordFolderService recordFolderService; + /** Logger */ protected static Log logger = LogFactory.getLog(FilePlanPermissionServiceImpl.class); - + /** * Initialisation method */ @@ -88,23 +88,23 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl TYPE_RECORD_FOLDER, new JavaBehaviour(this, "onCreateRecordFolder", NotificationFrequency.TRANSACTION_COMMIT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnAddAspectPolicy.QNAME, - ASPECT_RECORD, + NodeServicePolicies.OnAddAspectPolicy.QNAME, + ASPECT_RECORD, new JavaBehaviour(this, "onAddRecord", NotificationFrequency.TRANSACTION_COMMIT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnMoveNodePolicy.QNAME, - ASPECT_RECORD, + NodeServicePolicies.OnMoveNodePolicy.QNAME, + ASPECT_RECORD, new JavaBehaviour(this, "onMoveRecord", NotificationFrequency.TRANSACTION_COMMIT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnCreateNodePolicy.QNAME, - TYPE_HOLD, + NodeServicePolicies.OnCreateNodePolicy.QNAME, + TYPE_HOLD, new JavaBehaviour(this, "onCreateHoldTransfer", NotificationFrequency.TRANSACTION_COMMIT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnCreateNodePolicy.QNAME, - TYPE_TRANSFER, + NodeServicePolicies.OnCreateNodePolicy.QNAME, + TYPE_TRANSFER, new JavaBehaviour(this, "onCreateHoldTransfer", NotificationFrequency.TRANSACTION_COMMIT)); } - + /** * @param permissionService permission service */ @@ -112,7 +112,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { this.permissionService = permissionService; } - + /** * @param nodeService node service */ @@ -120,7 +120,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { this.nodeService = nodeService; } - + /** * @param policyComponent policy component */ @@ -128,15 +128,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { this.policyComponent = policyComponent; } - - /** - * @param recordsManagementService records management service - */ - public void setRecordsManagementService(RecordsManagementService recordsManagementService) - { - this.recordsManagementService = recordsManagementService; - } - + /** * @param filePlanService file plan service */ @@ -144,7 +136,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { this.filePlanService = filePlanService; } - + /** * @param recordService record service */ @@ -153,6 +145,14 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl this.recordService = recordService; } + /** + * @param recordFolderService record folder service + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * @param childAssocRef */ @@ -208,7 +208,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl public void onCreateRecordFolder(ChildAssociationRef childAssocRef) { final NodeRef folderNodeRef = childAssocRef.getChildRef(); - + // initialise the permissions setUpPermissions(folderNodeRef); @@ -245,12 +245,12 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl }, AuthenticationUtil.getSystemUserName()); } } - + /** * Sets ups records permission when aspect is added. - * + * * @see NodeServicePolicies.OnAddAspectPolicy#onAddAspect(NodeRef, QName) - * + * * @param record * @param aspectTypeQName */ @@ -262,18 +262,18 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { if (nodeService.exists(record) == true && nodeService.hasAspect(record, aspectTypeQName) == true) { - NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); + NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef(); initialiseRecordPermissions(record, recordFolder); } return null; } - }, AuthenticationUtil.getSystemUserName()); + }, AuthenticationUtil.getSystemUserName()); } - + /** * Sets up permissions for transfer and hold objects - * + * * @param childAssocRef */ public void onCreateHoldTransfer(final ChildAssociationRef childAssocRef) @@ -286,7 +286,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl if (nodeService.exists(nodeRef) == true) { setUpPermissions(nodeRef); - + NodeRef parent = childAssocRef.getParentRef(); Set perms = permissionService.getAllSetPermissions(parent); for (AccessPermission perm : perms) @@ -308,24 +308,24 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl } } } - + return null; } }); } - + /** * Initialise the record permissions for the given parent. - * + * * NOTE: method is public so it can be accessed via the associated patch bean. - * - * @param record record + * + * @param record record * @param parent records permission parent */ public void initialiseRecordPermissions(NodeRef record, NodeRef parent) { setUpPermissions(record); - + Set perms = permissionService.getAllSetPermissions(parent); for (AccessPermission perm : perms) { @@ -345,12 +345,12 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl allow); } } - + } - + /** * onMoveRecord behaviour - * + * * @param sourceAssocRef source association reference * @param destinationAssocRef destination association reference */ @@ -364,7 +364,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl if (nodeService.exists(record) == true && nodeService.hasAspect(record, ASPECT_RECORD) == true) { Set keepPerms = new HashSet(5); - + // record any permissions specifically set on the record (ie any filling or record_file permisions not on the parent) Set origionalParentPerms = permissionService.getAllSetPermissions(sourceAssocRef.getParentRef()); Set origionalRecordPerms= permissionService.getAllSetPermissions(record); @@ -374,7 +374,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl ExtendedWriterDynamicAuthority.EXTENDED_WRITER.equals(perm.getAuthority()) == false) { if ((perm.getPermission().equals(RMPermissionModel.FILING) == true || - perm.getPermission().equals(RMPermissionModel.FILE_RECORDS) == true) && + perm.getPermission().equals(RMPermissionModel.FILE_RECORDS) == true) && origionalParentPerms.contains(perm) == false) { // then we can assume this is a permission we want to preserve @@ -382,20 +382,20 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl } } } - + // clear all existing permissions and start again permissionService.deletePermissions(record); - + // re-setup the records permissions initialiseRecordPermissions(record, destinationAssocRef.getParentRef()); - + // re-add keep'er permissions for (AccessPermission keeper : keepPerms) { setPermission(record, keeper.getAuthority(), keeper.getPermission()); } } - + return null; } }, AuthenticationUtil.getSystemUserName()); @@ -424,7 +424,7 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl } }, AuthenticationUtil.getSystemUserName()); } - } + } /** * @see org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService#setPermission(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, boolean) @@ -443,8 +443,8 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { setPermissionDown(nodeRef, authority, permission); } - else if (filePlanService.isFilePlanContainer(nodeRef) == true || - recordsManagementService.isRecordFolder(nodeRef) == true || + else if (filePlanService.isFilePlanContainer(nodeRef) == true || + recordFolderService.isRecordFolder(nodeRef) == true || recordService.isRecord(nodeRef) == true) { setReadPermissionUp(nodeRef, authority); @@ -477,17 +477,17 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl setReadPermissionUpImpl(parent, authority); } } - + /** * Helper method used to set the read permission up the hierarchy - * + * * @param nodeRef node reference * @param authority authority */ private void setReadPermissionUpImpl(NodeRef nodeRef, String authority) { setPermissionImpl(nodeRef, authority, RMPermissionModel.READ_RECORDS); - + NodeRef parent = nodeService.getPrimaryParent(nodeRef).getParentRef(); if (parent != null && filePlanService.isFilePlanComponent(parent) == true) { @@ -509,16 +509,16 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { // set permissions setPermissionImpl(nodeRef, authority, permission); - + if (filePlanService.isFilePlanContainer(nodeRef) == true || - recordsManagementService.isRecordFolder(nodeRef) == true) - { + recordFolderService.isRecordFolder(nodeRef) == true) + { List assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : assocs) { NodeRef child = assoc.getChildRef(); if (filePlanService.isFilePlanContainer(child) == true || - recordsManagementService.isRecordFolder(child) == true || + recordFolderService.isRecordFolder(child) == true || recordService.isRecord(child) == true || instanceOf(child, TYPE_HOLD) == true || instanceOf(child, TYPE_TRANSFER) == true) @@ -562,16 +562,16 @@ public class FilePlanPermissionServiceImpl extends ServiceBaseImpl { // Delete permission on this node permissionService.deletePermission(nodeRef, authority, permission); - + if (filePlanService.isFilePlanContainer(nodeRef) == true || - recordsManagementService.isRecordFolder(nodeRef) == true) + recordFolderService.isRecordFolder(nodeRef) == true) { List assocs = nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef assoc : assocs) { NodeRef child = assoc.getChildRef(); if (filePlanService.isFilePlanContainer(child) == true || - recordsManagementService.isRecordFolder(child) == true || + recordFolderService.isRecordFolder(child) == true || recordService.isRecord(child) == true|| instanceOf(child, TYPE_HOLD) == true || instanceOf(child, TYPE_TRANSFER) == true) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java index 53ce066cf0..f41dbdd24d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/ReviewedAction.java @@ -28,7 +28,7 @@ import org.apache.commons.logging.LogFactory; /** * Reviewed action. - * + * * @author Neil McErlean */ public class ReviewedAction extends RMActionExecuterAbstractBase @@ -36,7 +36,7 @@ public class ReviewedAction extends RMActionExecuterAbstractBase private static Log logger = LogFactory.getLog(ReviewedAction.class); /** - * + * * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, * org.alfresco.service.cmr.repository.NodeRef) */ @@ -50,19 +50,19 @@ public class ReviewedAction extends RMActionExecuterAbstractBase { reviewRecord(actionedUponNodeRef, vrDef); } - else if (recordsManagementService.isRecordFolder(actionedUponNodeRef) == true) + else if (recordFolderService.isRecordFolder(actionedUponNodeRef) == true) { - for (NodeRef record : recordsManagementService.getRecords(actionedUponNodeRef)) + for (NodeRef record : recordService.getRecords(actionedUponNodeRef)) { reviewRecord(record, vrDef); } } } } - + /** * Make record as reviewed. - * + * * @param nodeRef * @param vrDef */ @@ -82,7 +82,7 @@ public class ReviewedAction extends RMActionExecuterAbstractBase .append(nodeRef); logger.debug(msg.toString()); } - + this.nodeService.setProperty(nodeRef, PROP_REVIEW_AS_OF, reviewAsOf); //TODO And record previous review date, time, user } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java index ab7b19a59f..802692a6da 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/vital/VitalRecordServiceImpl.java @@ -24,11 +24,11 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; -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.fileplan.FilePlanComponentKind; 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.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; @@ -46,11 +46,11 @@ import org.alfresco.util.PropertyMap; /** * Vital record service interface implementation. - * + * * @author Roy Wetherall * @since 2.0 */ -public class VitalRecordServiceImpl implements VitalRecordService, +public class VitalRecordServiceImpl implements VitalRecordService, RecordsManagementModel, NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.OnCreateChildAssociationPolicy @@ -58,15 +58,15 @@ public class VitalRecordServiceImpl implements VitalRecordService, /** Services */ private NodeService nodeService; private PolicyComponent policyComponent; - private RecordsManagementService rmService; private RecordsManagementActionService rmActionService; private FilePlanAuthenticationService filePlanAuthenticationService; private FilePlanService filePlanService; - + private RecordFolderService recordFolderService; + /** Behaviours */ private JavaBehaviour onUpdateProperties; private JavaBehaviour onCreateChildAssociation; - + /** * @param nodeService node service */ @@ -74,7 +74,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, { this.nodeService = nodeService; } - + /** * @param policyComponent policy component */ @@ -82,15 +82,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, { this.policyComponent = policyComponent; } - - /** - * @param rmService records management service - */ - public void setRecordsManagementService(RecordsManagementService rmService) - { - this.rmService = rmService; - } - + /** * @param rmActionService records management action service */ @@ -98,20 +90,28 @@ public class VitalRecordServiceImpl implements VitalRecordService, { this.rmActionService = rmActionService; } - + public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService) { this.filePlanAuthenticationService = filePlanAuthenticationService; } - + /** * @param filePlanService file plan service */ - public void setFilePlanService(FilePlanService filePlanService) + public void setFilePlanService(FilePlanService filePlanService) { this.filePlanService = filePlanService; } - + + /** + * @param recordFolderService + */ + public void setRecordFolderService(RecordFolderService recordFolderService) + { + this.recordFolderService = recordFolderService; + } + /** * Init method. */ @@ -122,16 +122,16 @@ public class VitalRecordServiceImpl implements VitalRecordService, NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, ASPECT_VITAL_RECORD_DEFINITION, onUpdateProperties); - - onCreateChildAssociation = new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.TRANSACTION_COMMIT); + + onCreateChildAssociation = new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.TRANSACTION_COMMIT); policyComponent.bindAssociationBehaviour( - NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, - TYPE_RECORD_FOLDER, + NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, + TYPE_RECORD_FOLDER, ContentModel.ASSOC_CONTAINS, onCreateChildAssociation); policyComponent.bindAssociationBehaviour( - NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, - TYPE_RECORD_CATEGORY, + NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, + TYPE_RECORD_CATEGORY, ContentModel.ASSOC_CONTAINS, onCreateChildAssociation); } @@ -142,7 +142,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, @Override public void onUpdateProperties(final NodeRef nodeRef, Map before, Map after) { - if (nodeService.exists(nodeRef) == true && + if (nodeService.exists(nodeRef) == true && nodeService.hasAspect(nodeRef, ASPECT_FILE_PLAN_COMPONENT) == true) { // check that vital record definition has been changed in the first place @@ -160,9 +160,9 @@ public class VitalRecordServiceImpl implements VitalRecordService, }} ); } - } + } } - + /** * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean) */ @@ -174,7 +174,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, if (nodeService.exists(nodeRef) == true) { onCreateChildAssociation.disable(); - onUpdateProperties.disable(); + onUpdateProperties.disable(); try { AuthenticationUtil.runAsSystem(new RunAsWork() @@ -183,11 +183,11 @@ public class VitalRecordServiceImpl implements VitalRecordService, public Void doWork() throws Exception { if (filePlanService.isRecordCategory(nodeRef) == true || - rmService.isRecordFolder(nodeRef) == true) + recordFolderService.isRecordFolder(nodeRef) == true) { inheritVitalRecordDefinition(nodeRef); } - + return null; } }); @@ -195,15 +195,15 @@ public class VitalRecordServiceImpl implements VitalRecordService, finally { onCreateChildAssociation.enable(); - onUpdateProperties.enable(); + onUpdateProperties.enable(); } } } } - + /** * Helper method to set the inherited vital record definition details. - * + * * @param nodeRef node reference */ private void inheritVitalRecordDefinition(NodeRef nodeRef) @@ -212,12 +212,12 @@ public class VitalRecordServiceImpl implements VitalRecordService, Period currentReviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); if (currentReviewPeriod == null || PERIOD_NONE.equals(currentReviewPeriod) == true) - { + { // get the immediate parent NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); - + // is the parent a record category - if (parentRef != null && + if (parentRef != null && FilePlanComponentKind.RECORD_CATEGORY.equals(filePlanService.getFilePlanComponentKind(parentRef)) == true) { // is the child a record category or folder @@ -226,22 +226,22 @@ public class VitalRecordServiceImpl implements VitalRecordService, kind.equals(FilePlanComponentKind.RECORD_FOLDER) == true) { // set the vital record definition values to match that of the parent - nodeService.setProperty(nodeRef, - PROP_VITAL_RECORD_INDICATOR, + nodeService.setProperty(nodeRef, + PROP_VITAL_RECORD_INDICATOR, nodeService.getProperty(parentRef, PROP_VITAL_RECORD_INDICATOR)); - nodeService.setProperty(nodeRef, - PROP_REVIEW_PERIOD, + nodeService.setProperty(nodeRef, + PROP_REVIEW_PERIOD, nodeService.getProperty(parentRef, PROP_REVIEW_PERIOD)); } } - } + } } - + /** * Helper method used by services with access to the private bean to initialise vital record details. - * + * * TODO consider what (if any of this) should be on the public interface - * + * * @param nodeRef node reference to initialise with vital record details */ public void initialiseVitalRecord(NodeRef nodeRef) @@ -255,7 +255,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, { Map reviewProps = new HashMap(1); reviewProps.put(RecordsManagementModel.PROP_REVIEW_AS_OF, reviewAsOf); - + if (nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD) == false) { nodeService.addAspect(nodeRef, RecordsManagementModel.ASPECT_VITAL_RECORD, reviewProps); @@ -267,7 +267,7 @@ public class VitalRecordServiceImpl implements VitalRecordService, nodeService.setProperties(nodeRef, props); } } - } + } else { // if we are re-filling then remove the vital aspect if it is not longer a vital record @@ -277,14 +277,14 @@ public class VitalRecordServiceImpl implements VitalRecordService, } } } - + /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getVitalRecordDefinition(org.alfresco.service.cmr.repository.NodeRef) + * @see VitalRecordService#getVitalRecordDefinition(NodeRef) */ public VitalRecordDefinition getVitalRecordDefinition(NodeRef nodeRef) { VitalRecordDefinition result = null; - + FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef); if (FilePlanComponentKind.RECORD.equals(kind) == true) { @@ -297,28 +297,28 @@ public class VitalRecordServiceImpl implements VitalRecordService, result = VitalRecordDefinitionImpl.create(nodeService, nodeRef); } } - + return result; } - + /** * Resolves the record vital definition. *

    - * NOTE: Currently we only support the resolution of the vital record definition from the + * NOTE: Currently we only support the resolution of the vital record definition from the * primary record parent. ie the record folder the record was originally filed within. *

    * TODO: Add an algorithm to resolve the correct vital record definition when a record is filed in many * record folders. - * + * * @param record * @return VitalRecordDefinition */ private VitalRecordDefinition resolveVitalRecordDefinition(NodeRef record) { NodeRef parent = nodeService.getPrimaryParent(record).getParentRef(); - return getVitalRecordDefinition(parent); + return getVitalRecordDefinition(parent); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService#setVitalRecordDefintion(org.alfresco.service.cmr.repository.NodeRef, boolean, org.alfresco.service.cmr.repository.Period) */ @@ -328,16 +328,16 @@ public class VitalRecordServiceImpl implements VitalRecordService, // Check params ParameterCheck.mandatory("nodeRef", nodeRef); ParameterCheck.mandatory("enabled", enabled); - + // Set the properties (will automatically add the vital record definition aspect) nodeService.setProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR, enabled); nodeService.setProperty(nodeRef, PROP_REVIEW_PERIOD, reviewPeriod); - + return new VitalRecordDefinitionImpl(enabled, reviewPeriod); } - + /** - * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isVitalRecord(org.alfresco.service.cmr.repository.NodeRef) + * @see VitalRecordService#isVitalRecord(NodeRef) */ public boolean isVitalRecord(NodeRef nodeRef) { diff --git a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java index b10878e632..3fcc20fdf3 100644 --- a/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java +++ b/rm-server/source/java/org/alfresco/workflow/requestInfo/RequestInfoNotifier.java @@ -20,7 +20,6 @@ package org.alfresco.workflow.requestInfo; import org.activiti.engine.delegate.DelegateTask; import org.activiti.engine.delegate.TaskListener; -import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.util.ParameterCheck; import org.springframework.extensions.surf.util.I18NUtil; @@ -92,16 +91,15 @@ public class RequestInfoNotifier implements TaskListener * @param recordName The name of the record * @return Returns the email subject */ - @SuppressWarnings("unused") - private String getEmailSubject(String recordName) - { - StringBuilder sb = new StringBuilder(); - sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.subject")); - sb.append(" '"); - sb.append(recordName); - sb.append("'"); - return sb.toString(); - } +// private String getEmailSubject(String recordName) +// { +// StringBuilder sb = new StringBuilder(); +// sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.subject")); +// sb.append(" '"); +// sb.append(recordName); +// sb.append("'"); +// return sb.toString(); +// } /** * Helper method for building the email body @@ -109,18 +107,17 @@ public class RequestInfoNotifier implements TaskListener * @param recordName The name of the record * @return Returns the email body */ - @SuppressWarnings("unused") - private String getEmailBody(String recordName) - { - StringBuilder sb = new StringBuilder(); - sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body1")); - sb.append(" '"); - sb.append(AuthenticationUtil.getFullyAuthenticatedUser()); - sb.append("' "); - sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body2")); - sb.append(" '"); - sb.append(recordName); - sb.append("'."); - return sb.toString(); - } +// private String getEmailBody(String recordName) +// { +// StringBuilder sb = new StringBuilder(); +// sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body1")); +// sb.append(" '"); +// sb.append(AuthenticationUtil.getFullyAuthenticatedUser()); +// sb.append("' "); +// sb.append(I18NUtil.getMessage("activitiReviewPooled.workflow.email.body2")); +// sb.append(" '"); +// sb.append(recordName); +// sb.append("'."); +// return sb.toString(); +// } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/DeclarativeCapabilityTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/DeclarativeCapabilityTest.java index 948770e112..f30c01c21d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/DeclarativeCapabilityTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/DeclarativeCapabilityTest.java @@ -77,17 +77,17 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase undeclaredRecord = utils.createRecord(rmFolder, "undeclaredRecord.txt"); // Closed folder - closedFolder = rmService.createRecordFolder(rmContainer, "closedFolder"); + closedFolder = recordFolderService.createRecordFolder(rmContainer, "closedFolder"); utils.closeFolder(closedFolder); // Frozen artifacts - recordFolderContainsFrozen = rmService.createRecordFolder(rmContainer, "containsFrozen"); + recordFolderContainsFrozen = recordFolderService.createRecordFolder(rmContainer, "containsFrozen"); frozenRecord = utils.createRecord(rmFolder, "frozenRecord.txt"); frozenRecord2 = utils.createRecord(recordFolderContainsFrozen, "frozen2.txt"); - frozenRecordFolder = rmService.createRecordFolder(rmContainer, "frozenRecordFolder"); + frozenRecordFolder = recordFolderService.createRecordFolder(rmContainer, "frozenRecordFolder"); // MoveTo artifacts - moveToFolder = rmService.createRecordFolder(rmContainer, "moveToFolder"); + moveToFolder = recordFolderService.createRecordFolder(rmContainer, "moveToFolder"); moveToCategory = filePlanService.createRecordCategory(rmContainer, "moveToCategory"); } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java index ed09fba0ac..935436216f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java @@ -40,44 +40,44 @@ import org.alfresco.util.GUID; /** * System test for RM-1008 - * + * * @author Roy Wetherall * @since 2.1 */ -public class RM1008Test extends BaseRMTestCase -{ +public class RM1008Test extends BaseRMTestCase +{ private String myUser; - + @Override protected void initServices() { super.initServices(); } - + @Override protected boolean isRecordTest() { return true; } - + @Override protected boolean isUserTest() { return true; } - + @Override protected void setupTestUsersImpl(NodeRef filePlan) { super.setupTestUsersImpl(filePlan); - + myUser = GUID.generate(); createPerson(myUser); filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_USER, myUser); } - + public void testContainers() throws Exception - { + { doTestInTransaction(new Test() { @Override @@ -87,20 +87,20 @@ public class RM1008Test extends BaseRMTestCase assertNotNull(holdContainer); NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); assertNotNull(transferContainer); - + Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); - + assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override @@ -110,23 +110,23 @@ public class RM1008Test extends BaseRMTestCase assertNotNull(holdContainer); NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); assertNotNull(transferContainer); - + Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(holdContainer)); assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transferContainer)); - + assertEquals(AccessStatus.DENIED, permissionService.hasPermission(holdContainer, RMPermissionModel.FILING)); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transferContainer, RMPermissionModel.FILING)); - + return null; } }, myUser); } - + public void testHold() - { + { final NodeRef hold = doTestInTransaction(new Test() { @Override @@ -138,7 +138,7 @@ public class RM1008Test extends BaseRMTestCase return holds.iterator().next(); } }, rmAdminName); - + doTestInTransaction(new Test() { @Override @@ -146,82 +146,82 @@ public class RM1008Test extends BaseRMTestCase { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - + return null; } }, myUser); - + doTestInTransaction(new Test() { @Override public Void run() { filePlanPermissionService.setPermission(filePlan, myUser, FILING); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - + return null; } }, myUser); - + doTestInTransaction(new Test() { @Override public Void run() { filePlanPermissionService.deletePermission(filePlan, myUser, FILING); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(hold)); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(hold, RMPermissionModel.FILING)); - + return null; } }, myUser); } - + public void testTransfer() { final NodeRef transferFolder = doTestInTransaction(new Test() @@ -235,39 +235,39 @@ public class RM1008Test extends BaseRMTestCase dsProps.put(PROP_DISPOSITION_AUTHORITY, "test"); dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test"); dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false); - DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps); - + DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps); + Map adParams = new HashMap(3); adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); - adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); - + adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - + adParams = new HashMap(3); adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer"); adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); - adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); - + adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0"); + dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); - return rmService.createRecordFolder(transferCat, "transferFolder"); + return recordFolderService.createRecordFolder(transferCat, "transferFolder"); } }); - + final NodeRef transfer = doTestInTransaction(new Test() { @Override public NodeRef run() - { + { actionService.executeRecordsManagementAction(transferFolder, "cutoff"); actionService.executeRecordsManagementAction(transferFolder, "transfer"); - + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); List childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - return childAssocs.get(0).getChildRef(); + return childAssocs.get(0).getChildRef(); } - + @Override public void test(NodeRef result) throws Exception { @@ -275,7 +275,7 @@ public class RM1008Test extends BaseRMTestCase assertEquals(TYPE_TRANSFER, nodeService.getType(result)); } }); - + doTestInTransaction(new Test() { @Override @@ -283,82 +283,82 @@ public class RM1008Test extends BaseRMTestCase { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - + return null; } }, myUser); - + doTestInTransaction(new Test() { @Override public Void run() { filePlanPermissionService.setPermission(filePlan, myUser, FILING); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - + return null; } }, myUser); - + doTestInTransaction(new Test() { @Override public Void run() { filePlanPermissionService.deletePermission(filePlan, myUser, FILING); - + return null; } }, rmAdminName); - + doTestInTransaction(new Test() { @Override public Void run() - { + { Capability viewRecords = capabilityService.getCapability("ViewRecords"); assertNotNull(viewRecords); - + assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer)); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING)); - + return null; } }, myUser); - + } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1027Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1027Test.java index cb27c1c56b..5d02b0fdb9 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1027Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1027Test.java @@ -25,12 +25,12 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Unit test for RM-1027 .. can't copy a closed folder - * + * * @author Roy Wetherall * @since 2.1 */ -public class RM1027Test extends BaseRMTestCase -{ +public class RM1027Test extends BaseRMTestCase +{ public void testCopyingAClosedFolder() throws Exception { final NodeRef recordFolder = doTestInTransaction(new Test() @@ -39,40 +39,40 @@ public class RM1027Test extends BaseRMTestCase public NodeRef run() { // create a folder and close it - NodeRef recordFolder = rmService.createRecordFolder(rmContainer, "My Closed Record Folder"); + NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); utils.closeFolder(recordFolder); - + assertTrue((Boolean)nodeService.getProperty(recordFolder, PROP_IS_CLOSED)); - + return recordFolder; } }); - + doTestInTransaction(new Test() { @Override public NodeRef run() throws Exception - { + { // create a destination for the copy NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); - + // try and copy the closed record folder FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); - + return copyInfo.getNodeRef(); } - + @Override public void test(NodeRef copy) throws Exception { - assertNotNull(copy); - + assertNotNull(copy); + assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); assertFalse((Boolean)nodeService.getProperty(copy, PROP_IS_CLOSED)); } - }); + }); } - + public void testCopyingAFolderWithADispositionSchedule() throws Exception { final NodeRef recordFolder = doTestInTransaction(new Test() @@ -80,38 +80,38 @@ public class RM1027Test extends BaseRMTestCase @Override public NodeRef run() { - // create a folder - NodeRef recordFolder = rmService.createRecordFolder(rmContainer, "My Closed Record Folder"); - + // create a folder + NodeRef recordFolder = recordFolderService.createRecordFolder(rmContainer, "My Closed Record Folder"); + // show that the default disposition schedule has been applied assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)); - + return recordFolder; } }); - + doTestInTransaction(new Test() { @Override public NodeRef run() throws Exception - { + { // create a destination for the copy NodeRef destination = filePlanService.createRecordCategory(filePlan, "Copy Destination"); - + // try and copy the closed record folder FileInfo copyInfo = fileFolderService.copy(recordFolder, destination, null); - + return copyInfo.getNodeRef(); } - + @Override public void test(NodeRef copy) throws Exception { - assertNotNull(copy); - + assertNotNull(copy); + assertNotNull(nodeService.getProperty(copy, PROP_IDENTIFIER)); assertFalse(nodeService.hasAspect(copy, ASPECT_DISPOSITION_LIFECYCLE)); } - }); + }); } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1039Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1039Test.java index d3d411ba9d..0101ae7e89 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1039Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1039Test.java @@ -36,21 +36,21 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule - * + * * @author Roy Wetherall * @since 2.1 */ -public class RM1039Test extends BaseRMTestCase -{ +public class RM1039Test extends BaseRMTestCase +{ @Override protected boolean isRecordTest() { return true; } - + // try and move a folder from no disposition schedule to a disposition schedule public void testMoveRecordFolderFromNoDisToDis() throws Exception - { + { final NodeRef recordFolder = doTestInTransaction(new Test() { @Override @@ -58,11 +58,11 @@ public class RM1039Test extends BaseRMTestCase { // create a record category (no disposition schedule) NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); - + // create a record folder - return rmService.createRecordFolder(recordCategory, "Grace Wetherall"); + return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall"); } - + @Override public void test(NodeRef result) throws Exception { @@ -71,16 +71,16 @@ public class RM1039Test extends BaseRMTestCase assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); } }); - + final NodeRef record = doTestInTransaction(new Test() { @Override public NodeRef run() { - // create a record + // create a record return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef(); } - + @Override public void test(NodeRef result) throws Exception { @@ -89,7 +89,7 @@ public class RM1039Test extends BaseRMTestCase assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); } }); - + doTestInTransaction(new Test() { @Override @@ -98,79 +98,79 @@ public class RM1039Test extends BaseRMTestCase Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders"); assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder)); assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer)); - + // take a look at the move capability Capability moveCapability = capabilityService.getCapability("Move"); assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer)); - + // move the node return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef(); } - + @Override public void test(NodeRef result) throws Exception { assertNotNull(result); assertNotNull(dispositionService.getDispositionSchedule(result)); assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE)); - + DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result); assertNotNull(dispositionAction); - + assertNull(dispositionAction.getAsOfDate()); - assertEquals("cutoff", dispositionAction.getName()); + assertEquals("cutoff", dispositionAction.getName()); assertEquals(1, dispositionAction.getEventCompletionDetails().size()); - + // take a look at the record and check things are as we would expect - assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); + assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE)); } }); } - + // move from a disposition schedule to another .. both record folder level - + // move from a disposition schedule to another .. from record to folder level - - + + // try and move a cutoff folder public void testMoveCutoffRecordFolder() throws Exception - { + { final NodeRef destination = doTestInTransaction(new Test() { @Override public NodeRef run() { // create a record category (no disposition schedule) - return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); + return filePlanService.createRecordCategory(filePlan, "Caitlin Reed"); } }); - + final NodeRef testFolder = doTestInTransaction(new Test() { @Override public NodeRef run() { // create folder - NodeRef testFolder = rmService.createRecordFolder(rmContainer, "Peter Edward Francis"); - + NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis"); + // complete event Map params = new HashMap(1); params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME); actionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params); - + // cutoff folder actionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME); - + // take a look at the move capability Capability moveCapability = capabilityService.getCapability("Move"); assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination)); - - return testFolder; + + return testFolder; } }); - + doTestInTransaction(new FailureTest() - { + { @Override public void run() throws Exception { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DispositionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DispositionServiceImplTest.java index a929dcc64a..bc27c5b19d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DispositionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/DispositionServiceImplTest.java @@ -46,7 +46,7 @@ import org.alfresco.service.namespace.QName; /** * Disposition service implementation unit test. - * + * * @author Roy Wetherall */ public class DispositionServiceImplTest extends BaseRMTestCase @@ -56,7 +56,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase { return true; } - + public void testGetDispositionProperties() throws Exception { doTestInTransaction(new Test() @@ -64,49 +64,49 @@ public class DispositionServiceImplTest extends BaseRMTestCase public Void run() { Collection properties = dispositionService.getDispositionProperties(); - + assertNotNull(properties); assertEquals(5, properties.size()); - + for (DispositionProperty property : properties) { assertNotNull(property.getQName()); assertNotNull(property.getPropertyDefinition()); } - + return null; } }); } - + /** * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) */ public void testGetDispositionSchedule() throws Exception - { + { doTestInTransaction(new Test() { @Override public Void run() { - // Check for null lookup's + // Check for null lookup's assertNull(dispositionService.getDispositionSchedule(filePlan)); - + // Get the containers disposition schedule DispositionSchedule ds = dispositionService.getDispositionSchedule(rmContainer); - assertNotNull(ds); + assertNotNull(ds); checkDispositionSchedule(ds, false); - + // Get the folders disposition schedule ds = dispositionService.getDispositionSchedule(rmContainer); - assertNotNull(ds); + assertNotNull(ds); checkDispositionSchedule(ds, false); - + return null; } - }); - + }); + // Failure: Root node doTestInTransaction(new FailureTest ( @@ -117,21 +117,21 @@ public class DispositionServiceImplTest extends BaseRMTestCase @Override public void run() { - dispositionService.getDispositionSchedule(rootNodeRef); + dispositionService.getDispositionSchedule(rootNodeRef); } - }); - + }); + // Failure: Non-rm node doTestInTransaction(new FailureTest() { @Override public void run() { - dispositionService.getDispositionSchedule(folder); + dispositionService.getDispositionSchedule(folder); } - }); + }); } - + /** * @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef) */ @@ -143,40 +143,40 @@ public class DispositionServiceImplTest extends BaseRMTestCase public Void run() { assertNull(dispositionService.getDispositionSchedule(mhContainer)); - + // Level 1 - doCheck(mhContainer11, "ds11", false); + doCheck(mhContainer11, "ds11", false); doCheck(mhContainer12, "ds12", false); - + // Level 2 doCheck(mhContainer21, "ds11", false); doCheck(mhContainer22, "ds12", false); doCheck(mhContainer23, "ds23", false); - + // Level 3 doCheck(mhContainer31, "ds11", false); doCheck(mhContainer32, "ds12", false); doCheck(mhContainer33, "ds33", true); doCheck(mhContainer34, "ds23", false); - doCheck(mhContainer35, "ds35", true); - + doCheck(mhContainer35, "ds35", true); + // Folders doCheckFolder(mhRecordFolder41, "ds11", false); doCheckFolder(mhRecordFolder42, "ds12", false); doCheckFolder(mhRecordFolder43, "ds33", true); doCheckFolder(mhRecordFolder44, "ds23", false); - doCheckFolder(mhRecordFolder45, "ds35", true); - + doCheckFolder(mhRecordFolder45, "ds35", true); + return null; } - + private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) { DispositionSchedule ds = dispositionService.getDispositionSchedule(container); assertNotNull(ds); - checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); + checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); } - + private void doCheckFolder(NodeRef container, String dispositionInstructions, boolean isRecordLevel) { doCheck(container, dispositionInstructions, isRecordLevel); @@ -185,48 +185,48 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(dispositionService.getNextDispositionAction(container)); } } - }); - + }); + } - + /** * Checks a disposition schedule - * + * * @param ds disposition scheduleS */ private void checkDispositionSchedule(DispositionSchedule ds, String dispositionInstructions, String dispositionAuthority, boolean isRecordLevel) { assertEquals(dispositionAuthority, ds.getDispositionAuthority()); assertEquals(dispositionInstructions, ds.getDispositionInstructions()); - assertEquals(isRecordLevel, ds.isRecordLevelDisposition()); - + assertEquals(isRecordLevel, ds.isRecordLevelDisposition()); + List defs = ds.getDispositionActionDefinitions(); assertNotNull(defs); assertEquals(2, defs.size()); - + DispositionActionDefinition defCutoff = ds.getDispositionActionDefinitionByName("cutoff"); assertNotNull(defCutoff); assertEquals("cutoff", defCutoff.getName()); - + DispositionActionDefinition defDestroy = ds.getDispositionActionDefinitionByName("destroy"); assertNotNull(defDestroy); assertEquals("destroy", defDestroy.getName()); } - + /** - * + * * @param ds */ private void checkDispositionSchedule(DispositionSchedule ds, boolean isRecordLevel) { checkDispositionSchedule(ds, CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); } - + /** * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) */ public void testGetAssociatedDispositionSchedule() throws Exception - { + { // Get associated disposition schedule for rmContainer doTestInTransaction(new Test() { @@ -235,28 +235,28 @@ public class DispositionServiceImplTest extends BaseRMTestCase { // Get the containers disposition schedule DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(rmContainer); - assertNotNull(ds); + assertNotNull(ds); checkDispositionSchedule(ds, false); - + // Show the null disposition schedules assertNull(dispositionService.getAssociatedDispositionSchedule(filePlan)); assertNull(dispositionService.getAssociatedDispositionSchedule(rmFolder)); return null; } - }); - + }); + // Failure: associated disposition schedule for non-rm node doTestInTransaction(new FailureTest() { @Override public void run() { - dispositionService.getAssociatedDispositionSchedule(folder); + dispositionService.getAssociatedDispositionSchedule(folder); } - }); + }); } - + /** * @see DispositionService#getAssociatedDispositionSchedule(NodeRef) */ @@ -268,35 +268,35 @@ public class DispositionServiceImplTest extends BaseRMTestCase public Void run() { assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer)); - + // Level 1 - doCheck(mhContainer11, "ds11", false); + doCheck(mhContainer11, "ds11", false); doCheck(mhContainer12, "ds12", false); - + // Level 2 assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer21)); assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer22)); doCheck(mhContainer23, "ds23", false); - + // Level 3 assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer31)); assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer32)); doCheck(mhContainer33, "ds33", true); assertNull(dispositionService.getAssociatedDispositionSchedule(mhContainer34)); - doCheck(mhContainer35, "ds35", true); - + doCheck(mhContainer35, "ds35", true); + return null; } - + private void doCheck(NodeRef container, String dispositionInstructions, boolean isRecordLevel) { DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(container); assertNotNull(ds); - checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); + checkDispositionSchedule(ds, dispositionInstructions, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, isRecordLevel); } - }); + }); } - + /** * @see DispositionService#hasDisposableItems(DispositionSchedule) */ @@ -310,20 +310,20 @@ public class DispositionServiceImplTest extends BaseRMTestCase // Add a new disposition schedule NodeRef container = filePlanService.createRecordCategory(rmContainer, "hasDisposableTest"); DispositionSchedule ds = utils.createBasicDispositionSchedule(container); - + assertTrue(dispositionService.hasDisposableItems(dispositionSchedule)); assertFalse(dispositionService.hasDisposableItems(ds)); - + return null; } - }); + }); } - + /** * @see DispositionService#hasDisposableItems(DispositionSchedule) */ public void testHasDisposableItemsMultiHier() throws Exception - { + { doTestInTransaction(new Test() { @Override @@ -334,17 +334,17 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertTrue(dispositionService.hasDisposableItems(mhDispositionSchedule23)); assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule33)); assertFalse(dispositionService.hasDisposableItems(mhDispositionSchedule35)); - + return null; } - }); + }); } - + /** * @see DispositionService#getDisposableItems(DispositionSchedule) */ public void testGetDisposableItems() throws Exception - { + { doTestInTransaction(new Test() { @Override @@ -354,17 +354,17 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(nodeRefs); assertEquals(1, nodeRefs.size()); assertTrue(nodeRefs.contains(rmFolder)); - + return null; } - }); + }); } - + /** * @see DispositionService#getDisposableItems(DispositionSchedule) */ public void testGetDisposableItemsMultiHier() throws Exception - { + { doTestInTransaction(new Test() { @Override @@ -374,30 +374,30 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(nodeRefs); assertEquals(1, nodeRefs.size()); assertTrue(nodeRefs.contains(mhRecordFolder41)); - + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule12); assertNotNull(nodeRefs); assertEquals(1, nodeRefs.size()); assertTrue(nodeRefs.contains(mhRecordFolder42)); - + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule23); assertNotNull(nodeRefs); assertEquals(1, nodeRefs.size()); assertTrue(nodeRefs.contains(mhRecordFolder44)); - + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule33); assertNotNull(nodeRefs); assertEquals(0, nodeRefs.size()); - + nodeRefs = dispositionService.getDisposableItems(mhDispositionSchedule35); assertNotNull(nodeRefs); assertEquals(0, nodeRefs.size()); - + return null; } - }); + }); } - + /** * @see DispositionService#createDispositionSchedule(NodeRef, Map) */ @@ -411,25 +411,25 @@ public class DispositionServiceImplTest extends BaseRMTestCase { // Create a new container NodeRef container = filePlanService.createRecordCategory(filePlan, "testCreateDispositionSchedule"); - + // Create a new disposition schedule utils.createBasicDispositionSchedule(container, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false, true); - + return container; - } - + } + @Override - public void test(NodeRef result) throws Exception + public void test(NodeRef result) throws Exception { // Get the created disposition schedule DispositionSchedule ds = dispositionService.getAssociatedDispositionSchedule(result); assertNotNull(ds); - + // Check the disposition schedule checkDispositionSchedule(ds, "testCreateDispositionSchedule", "testCreateDispositionSchedule", false); } - }); - + }); + // Failure: create disposition schedule on container with existing disposition schedule doTestInTransaction(new FailureTest ( @@ -439,11 +439,11 @@ public class DispositionServiceImplTest extends BaseRMTestCase @Override public void run() { - utils.createBasicDispositionSchedule(rmContainer); + utils.createBasicDispositionSchedule(rmContainer); } - }); + }); } - + /** * @see DispositionService#createDispositionSchedule(NodeRef, Map) */ @@ -458,33 +458,33 @@ public class DispositionServiceImplTest extends BaseRMTestCase // Create a new structure container NodeRef testA = filePlanService.createRecordCategory(mhContainer, "testA"); NodeRef testB = filePlanService.createRecordCategory(testA, "testB"); - + // Create new disposition schedules utils.createBasicDispositionSchedule(testA, "testA", "testA", false, true); utils.createBasicDispositionSchedule(testB, "testB", "testB", false, true); - + // Add created containers to model setNodeRef("testA", testA); setNodeRef("testB", testB); - + return null; - } - + } + @Override - public void test(Void result) throws Exception + public void test(Void result) throws Exception { // Get the created disposition schedule DispositionSchedule testA = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testA")); assertNotNull(testA); DispositionSchedule testB = dispositionService.getAssociatedDispositionSchedule(getNodeRef("testB")); assertNotNull(testB); - + // Check the disposition schedule checkDispositionSchedule(testA, "testA", "testA", false); checkDispositionSchedule(testB, "testB", "testB", false); } - }); - + }); + // Failure: create disposition schedule on container with existing disposition schedule doTestInTransaction(new FailureTest ( @@ -494,10 +494,10 @@ public class DispositionServiceImplTest extends BaseRMTestCase @Override public void run() { - utils.createBasicDispositionSchedule(mhContainer11); + utils.createBasicDispositionSchedule(mhContainer11); } - }); - + }); + // Failure: create disposition schedule on a container where there are disposable items under management doTestInTransaction(new FailureTest ( @@ -507,11 +507,11 @@ public class DispositionServiceImplTest extends BaseRMTestCase @Override public void run() { - utils.createBasicDispositionSchedule(mhContainer21); + utils.createBasicDispositionSchedule(mhContainer21); } - }); + }); } - + /** * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) */ @@ -528,9 +528,9 @@ public class DispositionServiceImplTest extends BaseRMTestCase return null; } - }); + }); } - + /** * @see DispositionService#getAssociatedRecordsManagementContainer(DispositionSchedule) */ @@ -544,35 +544,35 @@ public class DispositionServiceImplTest extends BaseRMTestCase NodeRef nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule11); assertNotNull(nodeRef); assertEquals(mhContainer11, nodeRef); - + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule12); assertNotNull(nodeRef); assertEquals(mhContainer12, nodeRef); - + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule23); assertNotNull(nodeRef); assertEquals(mhContainer23, nodeRef); - + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule33); assertNotNull(nodeRef); assertEquals(mhContainer33, nodeRef); - + nodeRef = dispositionService.getAssociatedRecordsManagementContainer(mhDispositionSchedule35); assertNotNull(nodeRef); assertEquals(mhContainer35, nodeRef); return null; } - }); + }); } - + // TODO DispositionActionDefinition addDispositionActionDefinition - + // TODO void removeDispositionActionDefinition( - + private NodeRef record43; private NodeRef record45; - + public void testUpdateDispositionActionDefinitionMultiHier() throws Exception { doTestInTransaction(new Test() @@ -582,11 +582,11 @@ public class DispositionServiceImplTest extends BaseRMTestCase { record43 = utils.createRecord(mhRecordFolder43, "record1.txt"); record45 = utils.createRecord(mhRecordFolder45, "record2.txt"); - + return null; - } + } }); - + doTestInTransaction(new Test() { @Override @@ -598,12 +598,12 @@ public class DispositionServiceImplTest extends BaseRMTestCase checkDisposableItemUnchanged(record43); checkDisposableItemUnchanged(mhRecordFolder44); checkDisposableItemUnchanged(record45); - + updateDispositionScheduleOnContainer(mhContainer11); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -614,18 +614,18 @@ public class DispositionServiceImplTest extends BaseRMTestCase checkDisposableItemUnchanged(mhRecordFolder44); checkDisposableItemUnchanged(record45);; } - }); - + }); + doTestInTransaction(new Test() { @Override public Void run() throws Exception { updateDispositionScheduleOnContainer(mhContainer12); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -636,18 +636,18 @@ public class DispositionServiceImplTest extends BaseRMTestCase checkDisposableItemUnchanged(mhRecordFolder44); checkDisposableItemUnchanged(record45);; } - }); - + }); + doTestInTransaction(new Test() { @Override public Void run() throws Exception { updateDispositionScheduleOnContainer(mhContainer33); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -659,17 +659,17 @@ public class DispositionServiceImplTest extends BaseRMTestCase checkDisposableItemUnchanged(record45);; } }); - + doTestInTransaction(new Test() { @Override public Void run() throws Exception { updateDispositionScheduleOnContainer(mhContainer23); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -681,17 +681,17 @@ public class DispositionServiceImplTest extends BaseRMTestCase checkDisposableItemUnchanged(record45); } }); - + doTestInTransaction(new Test() { @Override public Void run() throws Exception { updateDispositionScheduleOnContainer(mhContainer35); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -704,7 +704,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase } }); } - + private void publishDispositionActionDefinitionChange(DispositionActionDefinition dad) { PublishExecutorRegistry reg = (PublishExecutorRegistry)applicationContext.getBean("publishExecutorRegistry"); @@ -712,39 +712,39 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(pub); pub.publish(dad.getNodeRef()); } - + private void checkDisposableItemUnchanged(NodeRef recordFolder) { checkDispositionAction( - dispositionService.getNextDispositionAction(recordFolder), - "cutoff", - new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME}, - CommonRMTestUtils.PERIOD_NONE); + dispositionService.getNextDispositionAction(recordFolder), + "cutoff", + new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME}, + CommonRMTestUtils.PERIOD_NONE); } - + private void checkDisposableItemChanged(NodeRef recordFolder) throws Exception { checkDispositionAction( - dispositionService.getNextDispositionAction(recordFolder), - "cutoff", - new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"}, - "week|1"); + dispositionService.getNextDispositionAction(recordFolder), + "cutoff", + new String[]{CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished"}, + "week|1"); } - + private void updateDispositionScheduleOnContainer(NodeRef nodeRef) { Map updateProps = new HashMap(3); - updateProps.put(PROP_DISPOSITION_PERIOD, "week|1"); + updateProps.put(PROP_DISPOSITION_PERIOD, "week|1"); updateProps.put(PROP_DISPOSITION_EVENT, (Serializable)Arrays.asList(CommonRMTestUtils.DEFAULT_EVENT_NAME, "abolished")); - + DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); DispositionActionDefinition dad = ds.getDispositionActionDefinitionByName("cutoff"); - dispositionService.updateDispositionActionDefinition(dad, updateProps); + dispositionService.updateDispositionActionDefinition(dad, updateProps); publishDispositionActionDefinitionChange(dad); } - + /** - * + * * @param da * @param name * @param arrEventNames @@ -754,21 +754,21 @@ public class DispositionServiceImplTest extends BaseRMTestCase { assertNotNull(da); assertEquals(name, da.getName()); - + List events = da.getEventCompletionDetails(); assertNotNull(events); assertEquals(arrEventNames.length, events.size()); - + List origEvents = new ArrayList(events.size()); for (EventCompletionDetails event : events) { origEvents.add(event.getEventName()); } - + List expectedEvents = Arrays.asList(arrEventNames); Collection copy = new ArrayList(origEvents); - - for (Iterator i = origEvents.iterator(); i.hasNext(); ) + + for (Iterator i = origEvents.iterator(); i.hasNext(); ) { String origEvent = i.next(); @@ -778,7 +778,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase copy.remove(origEvent); } } - + if (copy.size() != 0 && expectedEvents.size() != 0) { StringBuffer buff = new StringBuffer(255); @@ -800,9 +800,9 @@ public class DispositionServiceImplTest extends BaseRMTestCase } buff.append(")."); } - fail(buff.toString()); + fail(buff.toString()); } - + if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod) == true) { assertNull(da.getAsOfDate()); @@ -812,23 +812,23 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(da.getAsOfDate()); } } - + // TODO boolean isNextDispositionActionEligible(NodeRef nodeRef); - - // TODO DispositionAction getNextDispositionAction(NodeRef nodeRef); - + + // TODO DispositionAction getNextDispositionAction(NodeRef nodeRef); + // TODO List getCompletedDispositionActions(NodeRef nodeRef); - + // TODO DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef); - + // TODO List getDispositionPeriodProperties(); - + /* === Issues === */ - + private NodeRef testRM263RecordCategory; private DispositionSchedule testRM263DispositionSchedule; private NodeRef testRM263Record; - + /** * https://issues.alfresco.com/jira/browse/RM-263 */ @@ -841,31 +841,31 @@ public class DispositionServiceImplTest extends BaseRMTestCase { testRM263RecordCategory = filePlanService.createRecordCategory(rmContainer, "rm263"); testRM263DispositionSchedule = utils.createBasicDispositionSchedule( - testRM263RecordCategory, - "test", - "test", - true, + testRM263RecordCategory, + "test", + "test", + true, false); - + Map adParams = new HashMap(3); adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff"); adParams.put(PROP_DISPOSITION_DESCRIPTION, "test"); adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, PROP_PUBLICATION_DATE.toString()); - + dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams); - - NodeRef recordFolder = rmService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder"); + + NodeRef recordFolder = recordFolderService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder"); testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record"); - + return null; } }); - + doTestInTransaction(new Test() { private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf"); - + @Override public Void run() throws Exception { @@ -873,17 +873,17 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNull(pubDate); Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); assertNull(asOfDate); - + DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); assertNotNull(da); assertNull(da.getAsOfDate()); - + //rma:recordSearchDispositionActionAsOf" nodeService.setProperty(testRM263Record, PROP_PUBLICATION_DATE, new Date()); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -891,7 +891,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase assertNotNull(pubDate); Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF); assertNotNull(asOfDate); - + DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record); assertNotNull(da); assertNotNull(da.getAsOfDate()); @@ -902,7 +902,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase private NodeRef testRM386RecordCategory; private DispositionSchedule testRM386DispositionSchedule; private NodeRef testRM386Record; - + /** * Test to make sure all the search rollups are correct after schedule is updated * @throws Exception @@ -916,43 +916,43 @@ public class DispositionServiceImplTest extends BaseRMTestCase { testRM386RecordCategory = filePlanService.createRecordCategory(rmContainer, "RM386"); testRM386DispositionSchedule = utils.createBasicDispositionSchedule( - testRM386RecordCategory, - "disposition instructions", - "disposition authority", + testRM386RecordCategory, + "disposition instructions", + "disposition authority", true, // record level true); // set the default actions - - NodeRef recordFolder = rmService.createRecordFolder(testRM386RecordCategory, "testRM386RecordFolder"); + + NodeRef recordFolder = recordFolderService.createRecordFolder(testRM386RecordCategory, "testRM386RecordFolder"); testRM386Record = utils.createRecord(recordFolder, "testRM386Record", "testRM386Record"); - + return null; } - + @SuppressWarnings("unchecked") @Override public void test(Void result) throws Exception { // Test the rollups for the record Map properties = nodeService.getProperties(testRM386Record); - + assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); - + assertEquals("none", properties.get(PROP_RS_DISPOSITION_PERIOD)); assertEquals("0", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); - + List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); assertNotNull(events); assertEquals(1, events.size()); - assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, events.get(0)); + assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, events.get(0)); assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - + assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); assertNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - } + } }); - + doTestInTransaction(new Test() { @Override @@ -960,57 +960,57 @@ public class DispositionServiceImplTest extends BaseRMTestCase { DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff"); assertNotNull(actionDefinition); - + Map adParams = new HashMap(3); - + List events = new ArrayList(1); events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME); events.add("obsolete"); adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); - adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); - + adParams.put(PROP_DISPOSITION_PERIOD, "week|1"); + dispositionService.updateDispositionActionDefinition( - actionDefinition, - adParams ); - + actionDefinition, + adParams ); + return actionDefinition; } - + @SuppressWarnings("unchecked") @Override public void test(DispositionActionDefinition result) throws Exception - { + { // Publish the updates PublishUpdatesJobExecuter updater = (PublishUpdatesJobExecuter)applicationContext.getBean("publishUpdatesJobExecuter"); updater.executeImpl(); - // Check the record has been updated + // Check the record has been updated DispositionAction dispositionAction = dispositionService.getNextDispositionAction(testRM386Record); assertNotNull(dispositionAction); assertEquals("cutoff", dispositionAction.getName()); assertNotNull(dispositionAction.getAsOfDate()); assertEquals(2, dispositionAction.getEventCompletionDetails().size()); - + // Test the rollups for the record Map properties = nodeService.getProperties(testRM386Record); - + assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE)); assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY)); assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS)); - + assertEquals("week", properties.get(PROP_RS_DISPOSITION_PERIOD)); assertEquals("1", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); - + List events = (List)properties.get(PROP_RS_DISPOSITION_EVENTS); assertNotNull(events); - assertEquals(2, events.size()); + assertEquals(2, events.size()); assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - + assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME)); assertNotNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); } }); - + } - + } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedSecurityServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedSecurityServiceImplTest.java index 1407ced003..9e20f7ed84 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedSecurityServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedSecurityServiceImplTest.java @@ -31,63 +31,63 @@ import org.alfresco.util.GUID; /** * Records management security service test. - * + * * @author Roy Wetherall */ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase { private ExtendedSecurityService extendedSecurityService; - + private NodeRef record; private NodeRef recordToo; private NodeRef moveRecordCategory; private NodeRef moveRecordFolder; - + @Override protected boolean isUserTest() { return true; } - + @Override protected void initServices() { super.initServices(); - + extendedSecurityService = (ExtendedSecurityService)applicationContext.getBean("ExtendedSecurityService"); } - + @Override protected void setupTestDataImpl() { super.setupTestDataImpl(); - + record = utils.createRecord(rmFolder, "record.txt"); - recordToo = utils.createRecord(rmFolder, "recordToo.txt"); - + recordToo = utils.createRecord(rmFolder, "recordToo.txt"); + moveRecordCategory = filePlanService.createRecordCategory(filePlan, "moveRecordCategory"); - moveRecordFolder = rmService.createRecordFolder(moveRecordCategory, "moveRecordFolder"); + moveRecordFolder = recordFolderService.createRecordFolder(moveRecordCategory, "moveRecordFolder"); } - + private String createTestUser() { return doTestInTransaction(new Test() { public String run() - { + { String userName = GUID.generate(); createPerson(userName); return userName; } }, AuthenticationUtil.getSystemUserName()); } - + public void testExtendedSecurity() { final String monkey = createTestUser(); final String elephant = createTestUser(); final String snake = createTestUser(); - + doTestInTransaction(new Test() { public Void run() @@ -96,124 +96,124 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); assertFalse(extendedSecurityService.hasExtendedSecurity(record)); - + assertNull(extendedSecurityService.getExtendedReaders(record)); assertNull(extendedSecurityService.getExtendedWriters(record)); - + Set extendedReaders = new HashSet(2); extendedReaders.add(monkey); extendedReaders.add(elephant); - + extendedSecurityService.addExtendedSecurity(record, extendedReaders, null); - + Map testMap = new HashMap(2); testMap.put(monkey, Integer.valueOf(1)); testMap.put(elephant, Integer.valueOf(1)); - + checkExtendedReaders(filePlan, testMap); checkExtendedReaders(rmContainer, testMap); checkExtendedReaders(rmFolder, testMap); checkExtendedReaders(record, testMap); - + Set extendedReadersToo = new HashSet(2); extendedReadersToo.add(monkey); extendedReadersToo.add(snake); - + extendedSecurityService.addExtendedSecurity(recordToo, extendedReadersToo, null); - + Map testMapToo = new HashMap(2); testMapToo.put(monkey, Integer.valueOf(1)); testMapToo.put(snake, Integer.valueOf(1)); - + Map testMapThree = new HashMap(3); testMapThree.put(monkey, Integer.valueOf(2)); testMapThree.put(elephant, Integer.valueOf(1)); testMapThree.put(snake, Integer.valueOf(1)); - + checkExtendedReaders(filePlan, testMapThree); checkExtendedReaders(rmContainer, testMapThree); checkExtendedReaders(rmFolder, testMapThree); checkExtendedReaders(recordToo, testMapToo); - + // test remove (with no parent inheritance) - + Set removeMap1 = new HashSet(2); removeMap1.add(elephant); removeMap1.add(monkey); - + extendedSecurityService.removeExtendedSecurity(rmFolder, removeMap1, null, false); - + Map testMapFour = new HashMap(2); testMapFour.put(monkey, Integer.valueOf(1)); testMapFour.put(snake, Integer.valueOf(1)); - + checkExtendedReaders(filePlan, testMapThree); checkExtendedReaders(rmContainer, testMapThree); checkExtendedReaders(rmFolder, testMapFour); checkExtendedReaders(recordToo, testMapToo); - + // test remove (apply to parents) - + Set removeMap2 = new HashSet(1); removeMap2.add(snake); - + extendedSecurityService.removeExtendedSecurity(recordToo, removeMap2, null, true); - + testMapThree.remove(snake); testMapFour.remove(snake); testMapToo.remove(snake); - + checkExtendedReaders(filePlan, testMapThree); checkExtendedReaders(rmContainer, testMapThree); checkExtendedReaders(rmFolder, testMapFour); checkExtendedReaders(recordToo, testMapToo); - + return null; } }); - } - + } + public void testMove() { final String monkey = createTestUser(); final String elephant = createTestUser(); - + doTestInTransaction(new Test() { Map testMap = new HashMap(2); - + public Void run() throws Exception { testMap.put(monkey, Integer.valueOf(1)); - testMap.put(elephant, Integer.valueOf(1)); - + testMap.put(elephant, Integer.valueOf(1)); + assertFalse(extendedSecurityService.hasExtendedSecurity(filePlan)); assertFalse(extendedSecurityService.hasExtendedSecurity(rmContainer)); assertFalse(extendedSecurityService.hasExtendedSecurity(rmFolder)); assertFalse(extendedSecurityService.hasExtendedSecurity(record)); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); - + assertNull(extendedSecurityService.getExtendedReaders(record)); - + Set extendedReaders = new HashSet(2); extendedReaders.add(monkey); extendedReaders.add(elephant); - + extendedSecurityService.addExtendedSecurity(record, extendedReaders, null); - + checkExtendedReaders(filePlan, testMap); checkExtendedReaders(rmContainer, testMap); checkExtendedReaders(rmFolder, testMap); checkExtendedReaders(record, testMap); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordCategory)); assertFalse(extendedSecurityService.hasExtendedSecurity(moveRecordFolder)); - + fileFolderService.move(record, moveRecordFolder, "movedRecord"); - + return null; } - + @Override public void test(Void result) throws Exception { @@ -224,26 +224,26 @@ public class ExtendedSecurityServiceImplTest extends BaseRMTestCase checkExtendedReaders(moveRecordFolder, testMap); checkExtendedReaders(record, testMap); } - }); + }); } - - + + @SuppressWarnings("unchecked") private void checkExtendedReaders(NodeRef nodeRef, Map testMap) { assertTrue(extendedSecurityService.hasExtendedSecurity(nodeRef)); - + Map readersMap = (Map)nodeService.getProperty(nodeRef, PROP_READERS); assertNotNull(readersMap); assertEquals(testMap.size(), readersMap.size()); - + for (Map.Entry entry: testMap.entrySet()) { assertTrue(readersMap.containsKey(entry.getKey())); assertEquals(entry.getKey(), entry.getValue(), readersMap.get(entry.getKey())); - + } - + Set readers = extendedSecurityService.getExtendedReaders(nodeRef); assertNotNull(readers); assertEquals(testMap.size(), readers.size()); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanPermissionServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanPermissionServiceImplTest.java index 72a8e4e268..1bf47d9168 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanPermissionServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanPermissionServiceImplTest.java @@ -28,7 +28,7 @@ import org.springframework.extensions.webscripts.GUID; /** * File plan permission service unit test - * + * * @author Roy Wetherall * @since 2.1 */ @@ -42,16 +42,16 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase { return true; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() */ @Override protected boolean isRecordTest() { - return true; + return true; } - + /** * Helper to create test user */ @@ -69,7 +69,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase } }, AuthenticationUtil.getSystemUserName()); } - + /** * Helper to set permission */ @@ -83,9 +83,9 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase filePlanPermissionService.setPermission(nodeRef, userName, permission); return null; } - }); + }); } - + /** * Helper to delete permission */ @@ -99,17 +99,17 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase filePlanPermissionService.deletePermission(nodeRef, userName, permission); return null; } - }); + }); } - + /** * test set/delete permissions on file plan */ public void testSetDeletePermissionFilePlan() throws Exception { String userName = createTestUser(); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -118,10 +118,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file - + setPermission(filePlan, userName, RMPermissionModel.FILING); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.ALLOWED, // fileplan file AccessStatus.ALLOWED, // category read @@ -130,10 +130,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.ALLOWED, // record folder file AccessStatus.ALLOWED, // record read AccessStatus.ALLOWED); // record file - + deletePermission(filePlan, userName, RMPermissionModel.FILING); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -142,12 +142,12 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file - + //what happens if we try and remove READ for a normal user on the file plan ??? deletePermission(filePlan, userName, RMPermissionModel.READ_RECORDS); - + // nothing .. user still has read on file plan .. only removing the user from all roles will remove read on file plan - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -157,15 +157,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file } - + /** * Test set/delete permission on record categorty */ public void testSetDeletePermissionRecordCategory() throws Exception { String userName = createTestUser(); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -174,10 +174,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file - + setPermission(rmContainer, userName, RMPermissionModel.FILING); - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -186,10 +186,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.ALLOWED, // record folder file AccessStatus.ALLOWED, // record read AccessStatus.ALLOWED); // record file - + deletePermission(rmContainer, userName, RMPermissionModel.FILING); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -199,15 +199,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file } - + /** * Test set/delete permission on record folder */ public void testSetDeletePermissionRecordFolder() throws Exception { String userName = createTestUser(); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -216,10 +216,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file - + setPermission(rmFolder, userName, RMPermissionModel.FILING); - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -228,10 +228,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.ALLOWED, // record folder file AccessStatus.ALLOWED, // record read AccessStatus.ALLOWED); // record file - + deletePermission(rmFolder, userName, RMPermissionModel.FILING); - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -241,15 +241,15 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file } - + /** * Test set/delete permission on record */ public void testSetDeletePermissionRecord() throws Exception { String userName = createTestUser(); - - assertPermissions(userName, + + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -258,10 +258,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file - + setPermission(recordOne, userName, RMPermissionModel.FILING); - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -270,10 +270,10 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record folder file AccessStatus.ALLOWED, // record read AccessStatus.ALLOWED); // record file - + deletePermission(recordOne, userName, RMPermissionModel.FILING); - assertPermissions(userName, + assertPermissions(userName, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -283,23 +283,23 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase AccessStatus.DENIED, // record read AccessStatus.DENIED); // record file } - + public void testMoveRecord() throws Exception { String userOne = createTestUser(); String userTwo = createTestUser(); String userThree = createTestUser(); - + final NodeRef otherFolder = doTestInTransaction(new Test() { @Override public NodeRef run() { - return rmService.createRecordFolder(rmContainer, "otherFolder"); + return recordFolderService.createRecordFolder(rmContainer, "otherFolder"); } }); - - assertPermissions(userOne, + + assertPermissions(userOne, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -318,7 +318,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userOne); - assertPermissions(userTwo, + assertPermissions(userTwo, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -337,7 +337,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userTwo); - assertPermissions(userThree, + assertPermissions(userThree, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.DENIED, // category read @@ -356,12 +356,12 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userThree); - + setPermission(rmFolder, userOne, RMPermissionModel.FILING); setPermission(otherFolder, userTwo, RMPermissionModel.FILING); setPermission(recordOne, userThree, RMPermissionModel.FILING); - - assertPermissions(userOne, + + assertPermissions(userOne, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -380,7 +380,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userOne); - assertPermissions(userTwo, + assertPermissions(userTwo, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -399,7 +399,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userTwo); - assertPermissions(userThree, + assertPermissions(userThree, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -418,7 +418,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userThree); - + // move the record! doTestInTransaction(new Test() { @@ -429,8 +429,8 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }); - - assertPermissions(userOne, + + assertPermissions(userOne, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -449,7 +449,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userOne); - assertPermissions(userTwo, + assertPermissions(userTwo, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -468,7 +468,7 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userTwo); - assertPermissions(userThree, + assertPermissions(userThree, AccessStatus.ALLOWED, // fileplan read AccessStatus.DENIED, // fileplan file AccessStatus.ALLOWED, // category read @@ -487,38 +487,38 @@ public class FilePlanPermissionServiceImplTest extends BaseRMTestCase return null; } }, userThree); - + } - - + + /** * Helper to assert permissions for passed user */ private void assertPermissions(final String userName, final AccessStatus ... accessStatus) { assertEquals(8, accessStatus.length); - + doTestInTransaction(new Test() { @Override public Void run() { - assertEquals("Everyone who has a role has read permissions on the file plan", + assertEquals("Everyone who has a role has read permissions on the file plan", accessStatus[0], permissionService.hasPermission(filePlan, RMPermissionModel.READ_RECORDS)); assertEquals(accessStatus[1], permissionService.hasPermission(filePlan, RMPermissionModel.FILING)); - + assertEquals(accessStatus[2], permissionService.hasPermission(rmContainer, RMPermissionModel.READ_RECORDS)); assertEquals(accessStatus[3], permissionService.hasPermission(rmContainer, RMPermissionModel.FILING)); - + assertEquals(accessStatus[4], permissionService.hasPermission(rmFolder, RMPermissionModel.READ_RECORDS)); assertEquals(accessStatus[5], permissionService.hasPermission(rmFolder, RMPermissionModel.FILING)); - + assertEquals(accessStatus[6], permissionService.hasPermission(recordOne, RMPermissionModel.READ_RECORDS)); assertEquals(accessStatus[7], permissionService.hasPermission(recordOne, RMPermissionModel.FILING)); - + return null; } }, userName); } - + } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanServiceImplTest.java index c7c7834e5e..e0e181619f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FilePlanServiceImplTest.java @@ -30,21 +30,21 @@ import org.alfresco.util.GUID; /** * File plan service unit test - * + * * @author Roy Wetherall * @since 2.1 */ public class FilePlanServiceImplTest extends BaseRMTestCase { - /** - * Pull in collaboration test data + /** + * Pull in collaboration test data */ @Override protected boolean isCollaborationSiteTest() { return true; } - + /** * {@link FilePlanService#isFilePlan(org.alfresco.service.cmr.repository.NodeRef)} */ @@ -53,14 +53,14 @@ public class FilePlanServiceImplTest extends BaseRMTestCase doTestInTransaction(new VoidTest() { public void runImpl() throws Exception - { + { assertTrue(filePlanService.isFilePlan(filePlan)); assertFalse(filePlanService.isFilePlan(rmContainer)); assertFalse(filePlanService.isFilePlan(dmDocument)); } - }); + }); } - + /** * {@link FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)} */ @@ -69,15 +69,15 @@ public class FilePlanServiceImplTest extends BaseRMTestCase doTestInTransaction(new VoidTest() { public void runImpl() throws Exception - { + { assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); assertNull(filePlanService.getFilePlan(dmDocument)); } - }); + }); } - + /** * {@link FilePlanService#getFilePlanBySiteId(String)} */ @@ -86,18 +86,18 @@ public class FilePlanServiceImplTest extends BaseRMTestCase doTestInTransaction(new VoidTest() { public void runImpl() throws Exception - { + { assertEquals(filePlan, filePlanService.getFilePlanBySiteId(siteId)); assertNull(filePlanService.getFilePlanBySiteId("rubbish")); - + String siteId = GUID.generate(); siteService.createSite("anything", siteId, "title", "descrition", SiteVisibility.PUBLIC); assertNull(filePlanService.getFilePlanBySiteId(siteId)); } - }); - + }); + } - + /** * @see FilePlanService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) */ @@ -111,12 +111,12 @@ public class FilePlanServiceImplTest extends BaseRMTestCase assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); - + return null; } }); } - + /** * @see FilePlanService#getFilePlanComponentKind(NodeRef) */ @@ -129,20 +129,20 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { return utils.createRecord(rmFolder, "testRecord.txt"); } - + @Override public void test(NodeRef result) throws Exception { assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); - assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); - // TODO HOLD and TRANSFER + assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); + // TODO HOLD and TRANSFER assertNull(filePlanService.getFilePlanComponentKind(folder)); } - }); + }); } - + /** * @see FilePlanService#isRecordCategory(NodeRef) */ @@ -156,12 +156,12 @@ public class FilePlanServiceImplTest extends BaseRMTestCase assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); - + return null; } }); } - + /** * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String) * @see FilePlanService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName) @@ -185,7 +185,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); } }); - + // Create specific type of root doTestInTransaction(new Test() { @@ -203,43 +203,43 @@ public class FilePlanServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); } }); - + // Failure: creating root in existing hierarchy doTestInTransaction(new FailureTest() { @Override public void run() { - filePlanService.createFilePlan(rmContainer, GUID.generate()); + filePlanService.createFilePlan(rmContainer, GUID.generate()); } }); - + // Failure: type no extended from root container doTestInTransaction(new FailureTest() { @Override public void run() { - filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); + filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); } }); } - + /** * A basic test of a records management container - * + * * @param nodeRef node reference * @param name name of the container - * @param type the type of container + * @param type the type of container */ private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) { // Check the basic details assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); - assertEquals(type, nodeService.getType(nodeRef)); + assertEquals(type, nodeService.getType(nodeRef)); } - + /** * @see FilePlanService#createRecordCategory(NodeRef, String) * @see FilePlanService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName) @@ -263,7 +263,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); } }); - + // Create container (in container) doTestInTransaction(new Test() { @@ -281,7 +281,7 @@ public class FilePlanServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); } }); - + // TODO need a custom type of container! // Create container of a given type // doTestInTransaction(new Test() @@ -300,28 +300,28 @@ public class FilePlanServiceImplTest extends BaseRMTestCase // basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); // } // }); - + // Fail Test: parent is not a container doTestInTransaction(new FailureTest() { @Override public void run() { - filePlanService.createRecordCategory(folder, GUID.generate()); + filePlanService.createRecordCategory(folder, GUID.generate()); } }); - + // Fail Test: type is not a sub-type of rm:recordsManagementContainer doTestInTransaction(new FailureTest() { @Override public void run() { - filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); + filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); } }); } - + /** * @see FilePlanService#getAllContained(NodeRef) * @see FilePlanService#getAllContained(NodeRef, boolean) @@ -336,43 +336,43 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { // Add to the test data NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { + { List nodes = filePlanService.getAllContained(rmContainer); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(rmFolder)); - + nodes = filePlanService.getAllContained(rmContainer, false); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(rmFolder)); - + nodes = filePlanService.getAllContained(rmContainer, true); assertNotNull(nodes); - assertEquals(4, nodes.size()); + assertEquals(4, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(rmFolder)); assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @@ -381,9 +381,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { filePlanService.getAllContained(rmFolder); } - }); + }); } - + /** * @see FilePlanService#getContainedRecordCategories(NodeRef) * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) @@ -398,38 +398,38 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { // Add to the test data NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { + { List nodes = filePlanService.getContainedRecordCategories(rmContainer); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + nodes = filePlanService.getContainedRecordCategories(rmContainer, false); assertNotNull(nodes); - assertEquals(1, nodes.size()); + assertEquals(1, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); - + nodes = filePlanService.getContainedRecordCategories(rmContainer, true); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @@ -438,9 +438,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { filePlanService.getContainedRecordCategories(rmFolder); } - }); + }); } - + /** * @see FilePlanService#getContainedRecordFolders(NodeRef) * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) @@ -455,38 +455,38 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { // Add to the test data NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); - + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { + { List nodes = filePlanService.getContainedRecordFolders(rmContainer); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + nodes = filePlanService.getContainedRecordFolders(rmContainer, false); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + nodes = filePlanService.getContainedRecordFolders(rmContainer, true); assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(rmFolder)); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(rmFolder)); assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @@ -495,11 +495,11 @@ public class FilePlanServiceImplTest extends BaseRMTestCase { filePlanService.getContainedRecordFolders(rmFolder); } - }); + }); } - + /** - * Test to create a simple multi-hierarchy record taxonomy + * Test to create a simple multi-hierarchy record taxonomy */ public void testCreateSimpleHierarchy() { @@ -509,15 +509,15 @@ public class FilePlanServiceImplTest extends BaseRMTestCase public Void run() { // Create 3 level hierarchy - NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); + NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); assertNotNull("Unable to create container", levelOne); NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); assertNotNull("Unable to create container", levelTwo); NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); assertNotNull("Unable to create container", levelThree); - NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", rmService.createRecordFolder(levelThree, "recordFolder3")); + NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); assertNotNull("Unable to create record folder", levelThreeRecordFolder); - + return null; } @@ -529,9 +529,9 @@ public class FilePlanServiceImplTest extends BaseRMTestCase basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); - + // TODO need to check that the parents and children can be retrieved correctly } - }); + }); } } 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 4f09db04f4..089338367b 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 @@ -18,10 +18,12 @@ */ package org.alfresco.module.org_alfresco_module_rm.test.service; +import java.util.ArrayList; import java.util.List; -import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; @@ -30,17 +32,16 @@ import org.alfresco.util.GUID; /** * Records management service test. - * + * * @author Roy Wetherall */ public class RecordsManagementServiceImplTest extends BaseRMTestCase -{ +{ /********** RM Component methods **********/ - + /** - * @see RecordsManagementService#isFilePlanComponent(org.alfresco.service.cmr.repository.NodeRef) + * @see FilePlanService#isFilePlanComponent(NodeRef) */ - @SuppressWarnings("deprecation") public void testIsFilePlanComponent() throws Exception { doTestInTransaction(new Test() @@ -48,19 +49,18 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase @Override public NodeRef run() { - assertTrue("The rm root container should be a rm component", rmService.isFilePlanComponent(filePlan)); - assertTrue("The rm container should be a rm component", rmService.isFilePlanComponent(rmContainer)); - assertTrue("The rm folder should be a rm component", rmService.isFilePlanComponent(rmFolder)); - + assertTrue("The rm root container should be a rm component", filePlanService.isFilePlanComponent(filePlan)); + assertTrue("The rm container should be a rm component", filePlanService.isFilePlanComponent(rmContainer)); + assertTrue("The rm folder should be a rm component", filePlanService.isFilePlanComponent(rmFolder)); + return null; } }); } - + /** - * @see RecordsManagementService#getFilePlanComponentKind(NodeRef) + * @see FilePlanService#getFilePlanComponentKind(NodeRef) */ - @SuppressWarnings("deprecation") public void testGetFilePlanComponentKind() throws Exception { doTestInTransaction(new Test() @@ -70,24 +70,23 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase { return utils.createRecord(rmFolder, "testRecord.txt"); } - + @Override public void test(NodeRef result) throws Exception { - assertEquals(FilePlanComponentKind.FILE_PLAN, rmService.getFilePlanComponentKind(filePlan)); - assertEquals(FilePlanComponentKind.RECORD_CATEGORY, rmService.getFilePlanComponentKind(rmContainer)); - assertEquals(FilePlanComponentKind.RECORD_FOLDER, rmService.getFilePlanComponentKind(rmFolder)); - assertEquals(FilePlanComponentKind.RECORD, rmService.getFilePlanComponentKind(result)); - // TODO HOLD and TRANSFER - assertNull(rmService.getFilePlanComponentKind(folder)); + assertEquals(FilePlanComponentKind.FILE_PLAN, filePlanService.getFilePlanComponentKind(filePlan)); + assertEquals(FilePlanComponentKind.RECORD_CATEGORY, filePlanService.getFilePlanComponentKind(rmContainer)); + assertEquals(FilePlanComponentKind.RECORD_FOLDER, filePlanService.getFilePlanComponentKind(rmFolder)); + assertEquals(FilePlanComponentKind.RECORD, filePlanService.getFilePlanComponentKind(result)); + // TODO HOLD and TRANSFER + assertNull(filePlanService.getFilePlanComponentKind(folder)); } - }); + }); } - + /** - * @see RecordsManagementService#isFilePlan(NodeRef) + * @see FilePlanService#isFilePlan(NodeRef) */ - @SuppressWarnings("deprecation") public void testIsFilePlan() throws Exception { doTestInTransaction(new Test() @@ -95,19 +94,18 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase @Override public NodeRef run() { - assertTrue("This is a records management root", rmService.isFilePlan(filePlan)); - assertFalse("This should not be a records management root", rmService.isFilePlan(rmContainer)); - assertFalse("This should not be a records management root", rmService.isFilePlan(rmFolder)); - + assertTrue("This is a records management root", filePlanService.isFilePlan(filePlan)); + assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmContainer)); + assertFalse("This should not be a records management root", filePlanService.isFilePlan(rmFolder)); + return null; } }); } - + /** - * @see RecordsManagementService#isRecordCategory(NodeRef) + * @see FilePlanService#isRecordCategory(NodeRef) */ - @SuppressWarnings("deprecation") public void testIsRecordCategory() throws Exception { doTestInTransaction(new Test() @@ -115,17 +113,17 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase @Override public NodeRef run() { - assertFalse("This should not be a record category.", rmService.isRecordCategory(filePlan)); - assertTrue("This is a record category.", rmService.isRecordCategory(rmContainer)); - assertFalse("This should not be a record category.", rmService.isRecordCategory(rmFolder)); - + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(filePlan)); + assertTrue("This is a record category.", filePlanService.isRecordCategory(rmContainer)); + assertFalse("This should not be a record category.", filePlanService.isRecordCategory(rmFolder)); + return null; } }); } - + /** - * @see RecordsManagementService#isRecordFolder(NodeRef) + * @see RecordFolderService#isRecordFolder(NodeRef) */ public void testIsRecordFolder() throws Exception { @@ -134,63 +132,57 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase @Override public NodeRef run() { - assertFalse("This should not be a record folder", rmService.isRecordFolder(filePlan)); - assertFalse("This should not be a record folder", rmService.isRecordFolder(rmContainer)); - assertTrue("This should be a record folder", rmService.isRecordFolder(rmFolder)); - + assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(filePlan)); + assertFalse("This should not be a record folder", recordFolderService.isRecordFolder(rmContainer)); + assertTrue("This should be a record folder", recordFolderService.isRecordFolder(rmFolder)); + return null; } }); } - - /** - * @see RecordsManagementService#getRecordsManagementRoot() - */ + public void testGetRecordsManagementRoot() throws Exception { doTestInTransaction(new Test() { - @SuppressWarnings("deprecation") @Override public NodeRef run() { - assertEquals(filePlan, rmService.getFilePlan(filePlan)); - assertEquals(filePlan, rmService.getFilePlan(rmContainer)); - assertEquals(filePlan, rmService.getFilePlan(rmFolder)); - + assertEquals(filePlan, filePlanService.getFilePlan(filePlan)); + assertEquals(filePlan, filePlanService.getFilePlan(rmContainer)); + assertEquals(filePlan, filePlanService.getFilePlan(rmFolder)); + return null; } }); } - + /********** Record Management Root methods **********/ - + /** - * @see RecordsManagementService#getFilePlans() + * @see FilePlanService#getFilePlans() */ public void testGetRecordsManagementRoots() throws Exception { doTestInTransaction(new Test() { - @SuppressWarnings("deprecation") @Override public NodeRef run() { - List roots = rmService.getFilePlans(); + List roots = new ArrayList(filePlanService.getFilePlans()); assertNotNull(roots); assertTrue(roots.size() != 0); - assertTrue(roots.contains(filePlan)); - + assertTrue(roots.contains(filePlan)); + return null; } - }); + }); } - + /** - * @see RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String) - * @see RecordsManagementService#createFilePlan(org.alfresco.service.cmr.repository.NodeRef, String, org.alfresco.service.namespace.QName) + * @see FilePlanService#createFilePlan(NodeRef, String) + * @see FilePlanService#createFilePlan(NodeRef, String, QName) */ - @SuppressWarnings("deprecation") public void testCreateFilePlan() throws Exception { // Create default type of root @@ -200,7 +192,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public NodeRef run() { String id = setString("id", GUID.generate()); - return rmService.createFilePlan(folder, id); + return filePlanService.createFilePlan(folder, id); } @Override @@ -210,7 +202,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); } }); - + // Create specific type of root doTestInTransaction(new Test() { @@ -218,7 +210,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public NodeRef run() { String id = setString("id", GUID.generate()); - return rmService.createFilePlan(folder, id, TYPE_FILE_PLAN); + return filePlanService.createFilePlan(folder, id, TYPE_FILE_PLAN); } @Override @@ -228,35 +220,34 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_FILE_PLAN); } }); - + // Failure: creating root in existing hierarchy doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createFilePlan(rmContainer, GUID.generate()); + filePlanService.createFilePlan(rmContainer, GUID.generate()); } }); - + // Failure: type no extended from root container doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); + filePlanService.createFilePlan(folder, GUID.generate(), TYPE_FOLDER); } }); } - + /********** Records Management Container methods **********/ - + /** - * @see RecordsManagementService#createRecordCategory(NodeRef, String) - * @see RecordsManagementService#createRecordCategory(NodeRef, String, org.alfresco.service.namespace.QName) + * @see FilePlanService#createRecordCategory(NodeRef, String) + * @see FilePlanService#createFilePlan(NodeRef, String, QName) */ - @SuppressWarnings("deprecation") public void testCreateRecordCategory() throws Exception { // Create container (in root) @@ -266,7 +257,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public NodeRef run() { String id = setString("id", GUID.generate()); - return rmService.createRecordCategory(filePlan, id); + return filePlanService.createRecordCategory(filePlan, id); } @Override @@ -276,7 +267,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); } }); - + // Create container (in container) doTestInTransaction(new Test() { @@ -284,7 +275,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public NodeRef run() { String id = setString("id", GUID.generate()); - return rmService.createRecordCategory(rmContainer, id); + return filePlanService.createRecordCategory(rmContainer, id); } @Override @@ -294,7 +285,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_RECORD_CATEGORY); } }); - + // TODO need a custom type of container! // Create container of a given type // doTestInTransaction(new Test() @@ -303,7 +294,7 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase // public NodeRef run() // { // String id = setString("id", GUID.generate()); -// return rmService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); +// return filePlanService.createRecordCategory(filePlan, id, TYPE_RECORD_SERIES); // } // // @Override @@ -313,33 +304,32 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase // basicRMContainerCheck(result, getString("id"), TYPE_RECORD_SERIES); // } // }); - + // Fail Test: parent is not a container doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createRecordCategory(folder, GUID.generate()); + filePlanService.createRecordCategory(folder, GUID.generate()); } }); - + // Fail Test: type is not a sub-type of rm:recordsManagementContainer doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); + filePlanService.createRecordCategory(filePlan, GUID.generate(), TYPE_FOLDER); } }); } - + /** - * @see RecordsManagementService#getAllContained(NodeRef) - * @see RecordsManagementService#getAllContained(NodeRef, boolean) + * @see FilePlanService#getAllContained(NodeRef) + * @see FilePlanService#getAllContained(NodeRef, boolean) */ - @SuppressWarnings("deprecation") public void testGetAllContained() throws Exception { // Get all contained test @@ -349,60 +339,59 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public Void run() { // Add to the test data - NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer"); - + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { - List nodes = rmService.getAllContained(rmContainer); + { + List nodes = filePlanService.getAllContained(rmContainer); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(rmFolder)); - - nodes = rmService.getAllContained(rmContainer, false); + + nodes = filePlanService.getAllContained(rmContainer, false); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(rmFolder)); - - nodes = rmService.getAllContained(rmContainer, true); + + nodes = filePlanService.getAllContained(rmContainer, true); assertNotNull(nodes); - assertEquals(4, nodes.size()); + assertEquals(4, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); - assertTrue(nodes.contains(rmFolder)); + assertTrue(nodes.contains(rmFolder)); assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.getAllContained(rmFolder); + filePlanService.getAllContained(rmFolder); } - }); + }); } - + /** - * @see RecordsManagementService#getContainedRecordCategories(NodeRef) - * @see RecordsManagementService#getContainedRecordCategories(NodeRef, boolean) + * @see FilePlanService#getContainedRecordCategories(NodeRef) + * @see FilePlanService#getContainedRecordCategories(NodeRef, boolean) */ - @SuppressWarnings("deprecation") public void testGetContainedRecordCategories() throws Exception { // Test getting all contained containers @@ -412,55 +401,54 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public Void run() { // Add to the test data - NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer"); - + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { - List nodes = rmService.getContainedRecordCategories(rmContainer); + { + List nodes = filePlanService.getContainedRecordCategories(rmContainer); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = rmService.getContainedRecordCategories(rmContainer, false); - assertNotNull(nodes); - assertEquals(1, nodes.size()); + assertEquals(1, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); - - nodes = rmService.getContainedRecordCategories(rmContainer, true); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, false); assertNotNull(nodes); - assertEquals(2, nodes.size()); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(getNodeRef("series"))); + + nodes = filePlanService.getContainedRecordCategories(rmContainer, true); + assertNotNull(nodes); + assertEquals(2, nodes.size()); assertTrue(nodes.contains(getNodeRef("series"))); assertTrue(nodes.contains(getNodeRef("seriesChildContainer"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.getContainedRecordCategories(rmFolder); + filePlanService.getContainedRecordCategories(rmFolder); } - }); + }); } - + /** - * @see RecordsManagementService#getContainedRecordFolders(NodeRef) - * @see RecordsManagementService#getContainedRecordFolders(NodeRef, boolean) + * @see FilePlanService#getContainedRecordFolders(NodeRef) + * @see FilePlanService#getContainedRecordFolders(NodeRef, boolean) */ - @SuppressWarnings("deprecation") public void testGetContainedRecordFolders() throws Exception { // Test getting all contained record folders @@ -470,72 +458,72 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public Void run() { // Add to the test data - NodeRef series = rmService.createRecordCategory(rmContainer, "rmSeries"); - NodeRef seriesChildFolder = rmService.createRecordFolder(series, "seriesRecordFolder"); - NodeRef seriesChildContainer = rmService.createRecordCategory(series, "childContainer"); - + NodeRef series = filePlanService.createRecordCategory(rmContainer, "rmSeries"); + NodeRef seriesChildFolder = recordFolderService.createRecordFolder(series, "seriesRecordFolder"); + NodeRef seriesChildContainer = filePlanService.createRecordCategory(series, "childContainer"); + // Put in model setNodeRef("series", series); setNodeRef("seriesChildFolder", seriesChildFolder); setNodeRef("seriesChildContainer", seriesChildContainer); - + return null; } - + @Override public void test(Void result) throws Exception - { - List nodes = rmService.getContainedRecordFolders(rmContainer); + { + List nodes = filePlanService.getContainedRecordFolders(rmContainer); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = rmService.getContainedRecordFolders(rmContainer, false); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, false); assertNotNull(nodes); - assertEquals(1, nodes.size()); - assertTrue(nodes.contains(rmFolder)); - - nodes = rmService.getContainedRecordFolders(rmContainer, true); + assertEquals(1, nodes.size()); + assertTrue(nodes.contains(rmFolder)); + + nodes = filePlanService.getContainedRecordFolders(rmContainer, true); assertNotNull(nodes); - assertEquals(2, nodes.size()); - assertTrue(nodes.contains(rmFolder)); + assertEquals(2, nodes.size()); + assertTrue(nodes.contains(rmFolder)); assertTrue(nodes.contains(getNodeRef("seriesChildFolder"))); } }); - + // Failure: call on record folder doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.getContainedRecordFolders(rmFolder); + filePlanService.getContainedRecordFolders(rmFolder); } - }); + }); } - - /********** Record Folder methods **********/ - + + /********** Record Folder methods **********/ + // TODO void testIsRecordFolderDeclared() - + // TODO void testIsRecordFolderClosed() - + // TODO void testGetRecords() - + /** - * @see RecordsManagementService#createRecordFolder(NodeRef, String) - * @see RecordsManagementService#createRecordFolder(NodeRef, String, QName) + * @see RecordFolderService#createRecordFolder(NodeRef, String) + * @see RecordFolderService#createRecordFolder(NodeRef, String, QName) */ public void testCreateRecordFolder() throws Exception { - // Create record + // Create record doTestInTransaction(new Test() { @Override public NodeRef run() { String id = setString("id", GUID.generate()); - return rmService.createRecordFolder(rmContainer, id); + return recordFolderService.createRecordFolder(rmContainer, id); } @Override @@ -545,37 +533,36 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(result, getString("id"), TYPE_RECORD_FOLDER); } }); - + // TODO Create record of type - + // Failure: Create record with invalid type doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER); + recordFolderService.createRecordFolder(rmContainer, GUID.generate(), TYPE_FOLDER); } }); - + // Failure: Create record folder in root doTestInTransaction(new FailureTest() { @Override public void run() { - rmService.createRecordFolder(filePlan, GUID.generate()); + recordFolderService.createRecordFolder(filePlan, GUID.generate()); } }); } - + /********** RM2 - Multi-hierarchy record taxonomy's **********/ - + /** - * Test to create a simple multi-hierarchy record taxonomy + * Test to create a simple multi-hierarchy record taxonomy */ - @SuppressWarnings("deprecation") public void testCreateSimpleHierarchy() { doTestInTransaction(new Test() @@ -584,15 +571,15 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase public Void run() { // Create 3 level hierarchy - NodeRef levelOne = setNodeRef("container1", rmService.createRecordCategory(filePlan, "container1")); + NodeRef levelOne = setNodeRef("container1", filePlanService.createRecordCategory(filePlan, "container1")); assertNotNull("Unable to create container", levelOne); - NodeRef levelTwo = setNodeRef("container2", rmService.createRecordCategory(levelOne, "container2")); + NodeRef levelTwo = setNodeRef("container2", filePlanService.createRecordCategory(levelOne, "container2")); assertNotNull("Unable to create container", levelTwo); - NodeRef levelThree = setNodeRef("container3", rmService.createRecordCategory(levelTwo, "container3")); + NodeRef levelThree = setNodeRef("container3", filePlanService.createRecordCategory(levelTwo, "container3")); assertNotNull("Unable to create container", levelThree); - NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", rmService.createRecordFolder(levelThree, "recordFolder3")); + NodeRef levelThreeRecordFolder = setNodeRef("recordFolder3", recordFolderService.createRecordFolder(levelThree, "recordFolder3")); assertNotNull("Unable to create record folder", levelThreeRecordFolder); - + return null; } @@ -604,25 +591,25 @@ public class RecordsManagementServiceImplTest extends BaseRMTestCase basicRMContainerCheck(getNodeRef("container2"), "container2", TYPE_RECORD_CATEGORY); basicRMContainerCheck(getNodeRef("container3"), "container3", TYPE_RECORD_CATEGORY); basicRMContainerCheck(getNodeRef("recordFolder3"), "recordFolder3", TYPE_RECORD_FOLDER); - + // TODO need to check that the parents and children can be retrieved correctly } - }); + }); } - + /** * A basic test of a records management container - * + * * @param nodeRef node reference * @param name name of the container - * @param type the type of container + * @param type the type of container */ private void basicRMContainerCheck(NodeRef nodeRef, String name, QName type) { // Check the basic details assertEquals(name, nodeService.getProperty(nodeRef, PROP_NAME)); assertNotNull("RM id has not been set", nodeService.getProperty(nodeRef, PROP_IDENTIFIER)); - assertEquals(type, nodeService.getType(nodeRef)); + assertEquals(type, nodeService.getType(nodeRef)); } - + } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/VitalRecordServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/VitalRecordServiceImplTest.java index ef2f8eb741..a494adc490 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/VitalRecordServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/VitalRecordServiceImplTest.java @@ -33,7 +33,7 @@ import org.alfresco.util.GUID; /** * Vital record service implementation unit test. - * + * * @author Roy Wetherall */ public class VitalRecordServiceImplTest extends BaseRMTestCase @@ -42,31 +42,31 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase protected static final Period PERIOD_NONE = new Period("none|0"); protected static final Period PERIOD_WEEK = new Period("week|1"); protected static final Period PERIOD_MONTH = new Period("month|1"); - + /** Test records */ private NodeRef mhRecord51; private NodeRef mhRecord52; private NodeRef mhRecord53; private NodeRef mhRecord54; private NodeRef mhRecord55; - - /** - * Indicate this test uses the collaboration site test data + + /** + * Indicate this test uses the collaboration site test data */ @Override protected boolean isCollaborationSiteTest() { return true; } - + /** Indicate this is a multi hierarchy test */ @Override protected boolean isMultiHierarchyTest() { return true; } - - /** vital record multi-hierarchy test data + + /** vital record multi-hierarchy test data * * |--rmRootContainer (no vr def) * | @@ -77,7 +77,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase * | |--mhContainer-2-1 (vr def) * | | * | |--mhContainer-3-1 (no vr def) - * | + * | * |--mhContainer-1-2 (has schedule - folder level) (no vr def) * | * |--mhContainer-2-2 (no vr def) @@ -85,26 +85,26 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase * | |--mhContainer-3-2 (vr def disabled) * | | * | |--mhContainer-3-3 (has schedule - record level) (vr def) - * | + * | * |--mhContainer-2-3 (has schedule - folder level) (vr def) * | * |--mhContainer-3-4 (no vr def) - * | - * |--mhContainer-3-5 (has schedule- record level) (vr def) - */ + * | + * |--mhContainer-3-5 (has schedule- record level) (vr def) + */ @Override protected void setupMultiHierarchyTestData() { // Load core test data super.setupMultiHierarchyTestData(); - + // Setup vital record definitions setupVitalRecordDefinition(mhContainer21, true, PERIOD_WEEK); setupVitalRecordDefinition(mhContainer32, false, PERIOD_WEEK); setupVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); setupVitalRecordDefinition(mhContainer23, true, PERIOD_WEEK); setupVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - + // Create records retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { @@ -116,15 +116,15 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase mhRecord53 = utils.createRecord(mhRecordFolder43, "record53.txt"); mhRecord54 = utils.createRecord(mhRecordFolder44, "record54.txt"); mhRecord55 = utils.createRecord(mhRecordFolder45, "record55.txt"); - + return null; } - }); + }); } - + /** * Helper to set up the vital record definition data in a transactional manner. - * + * * @param nodeRef * @param enabled * @param period @@ -142,10 +142,10 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase } }); } - + /** * Based on the initial data: - * - check category, folder and record raw values. + * - check category, folder and record raw values. * - check search aspect values. */ public void testInit() @@ -154,7 +154,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase { @Override public Void run() - { + { assertHasVitalRecordDefinition(mhContainer, false, null); assertHasVitalRecordDefinition(mhContainer11, false, null); assertHasVitalRecordDefinition(mhContainer12, false, null); @@ -166,24 +166,24 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - + assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder42, false, null); assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - + assertVitalRecord(mhRecord51, true, PERIOD_WEEK); assertVitalRecord(mhRecord52, false, null); assertVitalRecord(mhRecord53, true, PERIOD_WEEK); assertVitalRecord(mhRecord54, true, PERIOD_WEEK); assertVitalRecord(mhRecord55, true, PERIOD_MONTH); - + return null; } - }); + }); } - + /** * Test that when new record categories and record folders are created in an existing file plan * structure that they correctly inherit the correct vital record property values @@ -195,26 +195,26 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase { @Override public NodeRef run() - { + { return filePlanService.createRecordCategory(mhContainer35, GUID.generate()); } - + @Override public void test(NodeRef result) throws Exception { assertHasVitalRecordDefinition(result, true, PERIOD_MONTH); } }); - + // Test record folder value inheritance doTestInTransaction(new Test() { @Override public NodeRef run() - { - return rmService.createRecordFolder(mhContainer32, GUID.generate()); + { + return recordFolderService.createRecordFolder(mhContainer32, GUID.generate()); } - + @Override public void test(NodeRef result) throws Exception { @@ -222,9 +222,9 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase } }); } - + /** Filling tests */ - + public void testFileNewContent() throws Exception { doTestInTransaction(new Test() @@ -233,23 +233,23 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase public NodeRef run() { NodeRef record = fileFolderService.create(mhRecordFolder41, "test101.txt" , TYPE_CONTENT).getNodeRef(); - + ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); writer.setEncoding("UTF-8"); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.putContent("hello world this is some test content"); - + return record; } - + @Override - public void test(NodeRef record) throws Exception + public void test(NodeRef record) throws Exception { assertVitalRecord(record, true, PERIOD_WEEK); - } - }); + } + }); } - + // public void testFileUnfiledrecord() throws Exception // { // doTestInTransaction(new Test() @@ -257,20 +257,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase // @Override // public NodeRef run() throws Exception // { -// recordService.createRecord(filePlan, dmDocument); +// recordService.createRecord(filePlan, dmDocument); // fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); -// +// // return dmDocument; // } -// +// // @Override -// public void test(NodeRef record) throws Exception +// public void test(NodeRef record) throws Exception // { // assertVitalRecord(record, true, PERIOD_WEEK); -// } -// }); +// } +// }); // } -// +// // public void testFileDirectlyFromCollab() throws Exception // { // doTestInTransaction(new Test() @@ -281,17 +281,17 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase // fileFolderService.move(dmDocument, mhRecordFolder41, "record.txt"); // return dmDocument; // } -// +// // @Override -// public void test(NodeRef record) throws Exception +// public void test(NodeRef record) throws Exception // { // assertVitalRecord(record, true, PERIOD_WEEK); -// } -// }); +// } +// }); // } - + /** Helper Methods */ - + /** * Test to ensure that changes made to vital record definitions are reflected down the hierarchy. */ @@ -302,14 +302,14 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase { @Override public Void run() - { + { setupVitalRecordDefinition(mhContainer31, true, PERIOD_MONTH); return null; } - + @Override public void test(Void result) throws Exception - { + { assertHasVitalRecordDefinition(mhContainer, false, null); assertHasVitalRecordDefinition(mhContainer11, false, null); assertHasVitalRecordDefinition(mhContainer12, false, null); @@ -321,13 +321,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - + assertHasVitalRecordDefinition(mhRecordFolder41, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhRecordFolder42, false, null); assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - + assertVitalRecord(mhRecord51, true, PERIOD_MONTH); assertVitalRecord(mhRecord52, false, null); assertVitalRecord(mhRecord53, true, PERIOD_WEEK); @@ -335,20 +335,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertVitalRecord(mhRecord55, true, PERIOD_MONTH); } }); - + // 'turn off' vital record def doTestInTransaction(new Test() { @Override public Void run() - { + { setupVitalRecordDefinition(mhContainer31, false, PERIOD_NONE); return null; } - + @Override public void test(Void result) throws Exception - { + { assertHasVitalRecordDefinition(mhContainer, false, null); assertHasVitalRecordDefinition(mhContainer11, false, null); assertHasVitalRecordDefinition(mhContainer12, false, null); @@ -360,13 +360,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - + assertHasVitalRecordDefinition(mhRecordFolder41, false, null); assertHasVitalRecordDefinition(mhRecordFolder42, false, null); assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_WEEK); assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - + assertVitalRecord(mhRecord51, false, null); assertVitalRecord(mhRecord52, false, null); assertVitalRecord(mhRecord53, true, PERIOD_WEEK); @@ -374,20 +374,20 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertVitalRecord(mhRecord55, true, PERIOD_MONTH); } }); - + // Test parent change overrites existing doTestInTransaction(new Test() { @Override public Void run() - { + { setupVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); return null; } - + @Override public void test(Void result) throws Exception - { + { assertHasVitalRecordDefinition(mhContainer, false, null); assertHasVitalRecordDefinition(mhContainer11, false, null); assertHasVitalRecordDefinition(mhContainer12, true, PERIOD_MONTH); @@ -399,13 +399,13 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertHasVitalRecordDefinition(mhContainer33, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhContainer34, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhContainer35, true, PERIOD_MONTH); - + assertHasVitalRecordDefinition(mhRecordFolder41, false, null); assertHasVitalRecordDefinition(mhRecordFolder42, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhRecordFolder43, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhRecordFolder44, true, PERIOD_MONTH); assertHasVitalRecordDefinition(mhRecordFolder45, true, PERIOD_MONTH); - + assertVitalRecord(mhRecord51, false, null); assertVitalRecord(mhRecord52, true, PERIOD_MONTH); assertVitalRecord(mhRecord53, true, PERIOD_MONTH); @@ -413,22 +413,22 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertVitalRecord(mhRecord55, true, PERIOD_MONTH); } }); - + } - + @SuppressWarnings("deprecation") private void assertHasVitalRecordDefinition(NodeRef nodeRef, boolean enabled, Period period) { assertTrue(nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION)); - + VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef); assertNotNull(def); - + Boolean vitalRecordIndicator = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); assertNotNull(vitalRecordIndicator); assertEquals(enabled, vitalRecordIndicator.booleanValue()); assertEquals(enabled, def.isEnabled()); - + if (enabled == true) { Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); @@ -438,17 +438,17 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase assertEquals(period.getNextDate(new Date()).getDate(), def.getNextReviewDate().getDate()); } } - + @SuppressWarnings("deprecation") private void assertVitalRecord(NodeRef nodeRef, boolean enabled, Period period) { - assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)); + assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD)); if (enabled == true) { Date reviewAsOf = (Date)nodeService.getProperty(nodeRef, PROP_REVIEW_AS_OF); assertNotNull(reviewAsOf); assertEquals(period.getNextDate(new Date()).getDate(), reviewAsOf.getDate()); - + assertEquals(period.getPeriodType(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD)); assertEquals(period.getExpression(), nodeService.getProperty(nodeRef, RecordsManagementSearchBehaviour.PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION)); } 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 520b9b7d94..a6822911c1 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 @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Set; import org.alfresco.model.ContentModel; -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.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; @@ -38,6 +37,7 @@ 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.behaviour.RmSiteType; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; @@ -124,7 +124,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase protected TaggingService taggingService; /** RM Services */ - protected RecordsManagementService rmService; protected DispositionService dispositionService; protected RecordsManagementEventService eventService; protected RecordsManagementAdminService adminService; @@ -139,6 +138,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase protected RecordService recordService; protected FilePlanService filePlanService; protected FilePlanAuthenticationService filePlanAuthenticationService; + protected RecordFolderService recordFolderService; /** test data */ protected String siteId; @@ -295,7 +295,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase // Get the application context applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); utils = new CommonRMTestUtils(applicationContext); - + // Initialise the service beans initServices(); @@ -358,7 +358,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase taggingService = (TaggingService)applicationContext.getBean("TaggingService"); // Get RM services - rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService"); dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); @@ -373,6 +372,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase recordService = (RecordService) applicationContext.getBean("RecordService"); filePlanService = (FilePlanService) applicationContext.getBean("FilePlanService"); filePlanAuthenticationService = (FilePlanAuthenticationService) applicationContext.getBean("FilePlanAuthenticationService"); + recordFolderService = (RecordFolderService) applicationContext.getBean("RecordFolderService"); } /** @@ -414,19 +414,19 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase freezeService.relinquish(hold); } } - + if (nodeService.exists(folder) == true) { // Delete the folder nodeService.deleteNode(folder); } - + if (siteService.getSite(siteId) != null) { // Delete the site siteService.deleteSite(siteId); } - + // delete the collaboration site (if required) if (isCollaborationSiteTest() == true && siteService.getSite(COLLABORATION_SITE_ID) != null) { @@ -510,7 +510,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase ContentModel.TYPE_FOLDER, containerProps).getChildRef(); assertNotNull("Could not create base folder", folder); - + permissionService.setPermission(folder, "rmadmin", PermissionService.WRITE, true); permissionService.setPermission(folder, "rmadmin", PermissionService.ADD_CHILDREN, true); @@ -534,7 +534,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase dispositionSchedule = utils.createBasicDispositionSchedule(rmContainer); // Create RM folder - rmFolder = rmService.createRecordFolder(rmContainer, "rmFolder"); + rmFolder = recordFolderService.createRecordFolder(rmContainer, "rmFolder"); assertNotNull("Could not create rm folder", rmFolder); } @@ -687,11 +687,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase mhDispositionSchedule35 = utils.createBasicDispositionSchedule(mhContainer35, "ds35", CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, true, true); // Record folders - mhRecordFolder41 = rmService.createRecordFolder(mhContainer31, "mhFolder41"); - mhRecordFolder42 = rmService.createRecordFolder(mhContainer32, "mhFolder42"); - mhRecordFolder43 = rmService.createRecordFolder(mhContainer33, "mhFolder43"); - mhRecordFolder44 = rmService.createRecordFolder(mhContainer34, "mhFolder44"); - mhRecordFolder45 = rmService.createRecordFolder(mhContainer35, "mhFolder45"); + mhRecordFolder41 = recordFolderService.createRecordFolder(mhContainer31, "mhFolder41"); + mhRecordFolder42 = recordFolderService.createRecordFolder(mhContainer32, "mhFolder42"); + mhRecordFolder43 = recordFolderService.createRecordFolder(mhContainer33, "mhFolder43"); + mhRecordFolder44 = recordFolderService.createRecordFolder(mhContainer34, "mhFolder44"); + mhRecordFolder45 = recordFolderService.createRecordFolder(mhContainer35, "mhFolder45"); } protected void setupCollaborationSiteTestData() diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java index e43803aef9..4287efc95a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMWebScriptTestCase.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; -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.admin.RecordsManagementAdminService; import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService; @@ -34,6 +33,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventSe 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.model.behaviour.RmSiteType; +import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; @@ -96,7 +96,6 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest protected TaggingService taggingService; /** RM Services */ - protected RecordsManagementService rmService; protected DispositionService dispositionService; protected RecordsManagementEventService eventService; protected RecordsManagementAdminService adminService; @@ -108,6 +107,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest protected CapabilityService capabilityService; protected VitalRecordService vitalRecordService; protected FilePlanService filePlanService; + protected RecordFolderService recordFolderService; /** test data */ protected String siteId; @@ -169,7 +169,6 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest taggingService = (TaggingService)applicationContext.getBean("TaggingService"); // Get RM services - rmService = (RecordsManagementService)applicationContext.getBean("RecordsManagementService"); dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); eventService = (RecordsManagementEventService)applicationContext.getBean("RecordsManagementEventService"); adminService = (RecordsManagementAdminService)applicationContext.getBean("RecordsManagementAdminService"); @@ -181,6 +180,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); vitalRecordService = (VitalRecordService)applicationContext.getBean("VitalRecordService"); filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService"); + recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService"); } /** @@ -293,9 +293,9 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest dispositionSchedule = utils.createBasicDispositionSchedule(recordCategory); // Create RM folder - recordFolder = rmService.createRecordFolder(recordCategory, "rmFolder"); + recordFolder = recordFolderService.createRecordFolder(recordCategory, "rmFolder"); assertNotNull("Could not create rm folder", recordFolder); - recordFolder2 = rmService.createRecordFolder(recordCategory, "rmFolder2"); + recordFolder2 = recordFolderService.createRecordFolder(recordCategory, "rmFolder2"); assertNotNull("Could not create rm folder 2", recordFolder2); // Create collaboration data diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/DispositionRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/DispositionRestApiTest.java index 5a1365e742..6406691418 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/DispositionRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/DispositionRestApiTest.java @@ -38,7 +38,7 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * This class tests the Rest API for disposition related operations - * + * * @author Gavin Cornwell */ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel @@ -52,7 +52,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R protected static final String GET_LIST_URL = "/api/rma/admin/listofvalues"; protected static final String SERVICE_URL_PREFIX = "/alfresco/service"; protected static final String APPLICATION_JSON = "application/json"; - + public void testGetDispositionSchedule() throws Exception { @@ -61,50 +61,50 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R String nonExistentNode = "workspace/SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"; String nonExistentUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, nonExistentNode); Response rsp = sendRequest(new GetRequest(nonExistentUrl), expectedStatus); - + // Test 404 status for node that doesn't have dispostion schedule i.e. a record series String seriesNodeUrl = recordSeries.toString().replace("://", "/"); String wrongNodeUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, seriesNodeUrl); rsp = sendRequest(new GetRequest(wrongNodeUrl), expectedStatus); - + // Test data structure returned from "AIS Audit Records" expectedStatus = 200; - + String categoryNodeUrl = recordCategory.toString().replace("://", "/"); String requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - + // get response as JSON JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); assertNotNull(jsonParsedObject); - + // check JSON data JSONObject dataObj = jsonParsedObject.getJSONObject("data"); assertNotNull(dataObj); JSONObject rootDataObject = (JSONObject)dataObj; assertEquals(10, rootDataObject.length()); - + // check individual data items String serviceUrl = SERVICE_URL_PREFIX + requestUrl; String url = rootDataObject.getString("url"); assertEquals(serviceUrl, url); - + String authority = rootDataObject.getString("authority"); - + assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, authority); - + String instructions = rootDataObject.getString("instructions"); assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, instructions); - + String actionsUrl = rootDataObject.getString("actionsUrl"); assertEquals(serviceUrl + "/dispositionactiondefinitions", actionsUrl); - + boolean recordLevel = rootDataObject.getBoolean("recordLevelDisposition"); assertFalse(recordLevel); - + assertFalse(rootDataObject.getBoolean("canStepsBeRemoved")); - + JSONArray actions = rootDataObject.getJSONArray("actions"); assertNotNull(actions); assertEquals(2, actions.length()); @@ -115,25 +115,25 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertEquals(0, action1.getInt("index")); assertEquals("cutoff", action1.getString("name")); assertTrue(action1.getBoolean("eligibleOnFirstCompleteEvent")); - + JSONObject action2 = (JSONObject)actions.get(1); assertEquals(8, action2.length()); - + // make sure the disposition schedule node ref is present and valid String scheduleNodeRefJSON = rootDataObject.getString("nodeRef"); NodeRef scheduleNodeRef = new NodeRef(scheduleNodeRefJSON); assertTrue(this.nodeService.exists(scheduleNodeRef)); - + // create a new recordCategory node in the recordSeries and then get // the disposition schedule NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); dispositionService.createDispositionSchedule(newRecordCategory, null); - + categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); requestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); //System.out.println("GET response: " + rsp.getContentAsString()); rsp = sendRequest(new GetRequest(requestUrl), expectedStatus); - + // get response as JSON jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); System.out.println(rsp.getContentAsString()); @@ -148,24 +148,24 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertNotNull(actions); assertEquals(0, actions.length()); } - + public void testPostDispositionAction() throws Exception { // create a new recordCategory node in the recordSeries and then get // the disposition schedule NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); dispositionService.createDispositionSchedule(newRecordCategory, null); - + String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); String requestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); - + // Construct the JSON request. String name = "destroy"; String desc = "Destroy this record after 5 years"; String period = "year|5"; String periodProperty = "rma:cutOffDate"; boolean eligibleOnFirstCompleteEvent = true; - + JSONObject jsonPostData = new JSONObject(); jsonPostData.put("name", name); jsonPostData.put("description", desc); @@ -177,11 +177,11 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R events.put("superseded"); events.put("no_longer_needed"); jsonPostData.put("events", events); - + // Submit the JSON request. String jsonPostString = jsonPostData.toString(); Response rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); - + // check the returned data is what was expected JSONObject jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); JSONObject dataObj = jsonResponse.getJSONObject("data"); @@ -201,13 +201,13 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertEquals(2, events.length()); assertEquals("superseded", events.get(0)); assertEquals("no_longer_needed", events.get(1)); - + // test the minimum amount of data required to create an action definition jsonPostData = new JSONObject(); jsonPostData.put("name", name); jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 200); - + // check the returned data is what was expected jsonResponse = new JSONObject(new JSONTokener(rsp.getContentAsString())); dataObj = jsonResponse.getJSONObject("data"); @@ -220,7 +220,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertFalse(dataObj.has("periodProperty")); assertFalse(dataObj.has("events")); assertTrue(dataObj.getBoolean("eligibleOnFirstCompleteEvent")); - + // negative test to ensure not supplying mandatory data results in an error jsonPostData = new JSONObject(); jsonPostData.put("description", desc); @@ -228,12 +228,12 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R jsonPostString = jsonPostData.toString(); sendRequest(new PostRequest(requestUrl, jsonPostString, APPLICATION_JSON), 400); } - + public void testPutDispositionAction() throws Exception { NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); dispositionService.createDispositionSchedule(newRecordCategory, null); - + // create an action definition to then update String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); @@ -241,7 +241,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R jsonPostData.put("name", "cutoff"); String jsonPostString = jsonPostData.toString(); sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); - + // verify the action definition is present and retrieve it's id String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); @@ -252,7 +252,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertEquals("none|0", actionDef.getString("period")); assertFalse(actionDef.has("description")); assertFalse(actionDef.has("events")); - + // define body for PUT request String name = "destroy"; String desc = "Destroy this record after 5 years"; @@ -260,7 +260,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R String location = "my location"; String periodProperty = "rma:cutOffDate"; boolean eligibleOnFirstCompleteEvent = false; - + jsonPostData = new JSONObject(); jsonPostData.put("name", name); jsonPostData.put("description", desc); @@ -273,15 +273,15 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R events.put("no_longer_needed"); jsonPostData.put("events", events); jsonPostString = jsonPostData.toString(); - + // try and update a non existent action definition to check for 404 String putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 404); - + // update the action definition putRequestUrl = MessageFormat.format(PUT_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); rsp = sendRequest(new PutRequest(putRequestUrl, jsonPostString, APPLICATION_JSON), 200); - + // check the update happened correctly json = new JSONObject(new JSONTokener(rsp.getContentAsString())); actionDef = json.getJSONObject("data"); @@ -296,12 +296,12 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertEquals("superseded", actionDef.getJSONArray("events").getString(0)); assertEquals("no_longer_needed", actionDef.getJSONArray("events").getString(1)); } - + public void testDeleteDispositionAction() throws Exception { NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate()); dispositionService.createDispositionSchedule(newRecordCategory, null); - + // create an action definition to then delete String categoryNodeUrl = newRecordCategory.toString().replace("://", "/"); String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl); @@ -309,21 +309,21 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R jsonPostData.put("name", "cutoff"); String jsonPostString = jsonPostData.toString(); sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200); - + // verify the action definition is present and retrieve it's id String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); Response rsp = sendRequest(new GetRequest(getRequestUrl), 200); JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString())); String actionDefId = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0).getString("id"); - + // try and delete a non existent action definition to check for 404 String deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz"); rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 404); - + // now delete the action defintion created above deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId); rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 200); - + // verify it got deleted getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl); rsp = sendRequest(new GetRequest(getRequestUrl), 200); @@ -331,30 +331,30 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R JSONArray actions = json.getJSONObject("data").getJSONArray("actions"); assertEquals(0, actions.length()); } - + public void testGetDispositionLifecycle() throws Exception { // Test 404 for disposition lifecycle request on incorrect node String categoryUrl = recordCategory.toString().replace("://", "/"); String requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, categoryUrl); Response rsp = sendRequest(new GetRequest(requestUrl), 200); - + JSONObject notFound = new JSONObject(new JSONTokener(rsp.getContentAsString())); assertEquals(true, notFound.getJSONObject("data").getBoolean("notFound")); - - NodeRef newRecordFolder = rmService.createRecordFolder(recordCategory, "recordFolder"); - - + + NodeRef newRecordFolder = recordFolderService.createRecordFolder(recordCategory, "recordFolder"); + + // there should now be a disposition lifecycle for the record requestUrl = MessageFormat.format(GET_LIFECYCLE_URL_FORMAT, newRecordFolder.toString().replace("://", "/")); rsp = sendRequest(new GetRequest(requestUrl), 200); System.out.println("GET : " + rsp.getContentAsString()); assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - + // get response as JSON JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); assertNotNull(jsonParsedObject); - + // check mandatory stuff is present JSONObject dataObj = jsonParsedObject.getJSONObject("data"); assertEquals(SERVICE_URL_PREFIX + requestUrl, dataObj.getString("url")); @@ -368,7 +368,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertEquals("Case Closed", event1.get("label")); assertFalse(event1.getBoolean("complete")); assertFalse(event1.getBoolean("automatic")); - + // check stuff expected to be missing is missing assertFalse(dataObj.has("asOf")); assertFalse(dataObj.has("startedAt")); @@ -378,18 +378,18 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertFalse(event1.has("completedAt")); assertFalse(event1.has("completedBy")); } - + public void testGetListOfValues() throws Exception { // call the list service - Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); + Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - + // get response as JSON JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); assertNotNull(jsonParsedObject); JSONObject data = jsonParsedObject.getJSONObject("data"); - + // check dispostion actions JSONObject actions = data.getJSONObject("dispositionActions"); assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/dispositionactions", actions.getString("url")); @@ -400,7 +400,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertTrue(item.length() == 2); assertTrue(item.has("label")); assertTrue(item.has("value")); - + // check events JSONObject events = data.getJSONObject("events"); assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/events", events.getString("url")); @@ -412,7 +412,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertTrue(item.has("label")); assertTrue(item.has("value")); assertTrue(item.has("automatic")); - + // check period types JSONObject periodTypes = data.getJSONObject("periodTypes"); assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodtypes", periodTypes.getString("url")); @@ -423,7 +423,7 @@ public class DispositionRestApiTest extends BaseRMWebScriptTestCase implements R assertTrue(item.length() == 2); assertTrue(item.has("label")); assertTrue(item.has("value")); - + // check period properties JSONObject periodProperties = data.getJSONObject("periodProperties"); assertEquals(SERVICE_URL_PREFIX + GET_LIST_URL + "/periodproperties", periodProperties.getString("url")); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/RmRestApiTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/RmRestApiTest.java index ac18accf26..355ac72b9c 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/RmRestApiTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/webscript/RmRestApiTest.java @@ -49,7 +49,7 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * This class tests the Rest API for RM. - * + * * @author Neil McErlean */ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsManagementModel @@ -73,7 +73,6 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // protected ImporterService importService; // protected TransactionService transactionService; // protected ServiceRegistry services; -// protected RecordsManagementService rmService; // protected RecordsManagementActionService rmActionService; // protected RecordsManagementAuditService rmAuditService; // protected RecordsManagementAdminService rmAdminService; @@ -83,12 +82,12 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan private static final String BI_DI = "BiDi"; private static final String CHILD_SRC = "childSrc"; private static final String CHILD_TGT = "childTgt"; - + // @Override // protected void setUp() throws Exception // { // setCustomContext("classpath:test-context.xml"); -// +// // super.setUp(); // this.namespaceService = (NamespaceService) getServer().getApplicationContext().getBean("NamespaceService"); // this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); @@ -98,13 +97,12 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // this.importService = (ImporterService)getServer().getApplicationContext().getBean("ImporterService"); // this.transactionService = (TransactionService)getServer().getApplicationContext().getBean("TransactionService"); // this.services = (ServiceRegistry)getServer().getApplicationContext().getBean("ServiceRegistry"); -// this.rmService = (RecordsManagementService)getServer().getApplicationContext().getBean("RecordsManagementService"); // this.rmActionService = (RecordsManagementActionService)getServer().getApplicationContext().getBean("RecordsManagementActionService"); // this.rmAuditService = (RecordsManagementAuditService)getServer().getApplicationContext().getBean("RecordsManagementAuditService"); // this.rmAdminService = (RecordsManagementAdminService)getServer().getApplicationContext().getBean("RecordsManagementAdminService"); -// transactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper"); +// transactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper"); // dispositionService = (DispositionService)getServer().getApplicationContext().getBean("DispositionService"); -// +// // AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); // // // Bring the filePlan into the test database. @@ -114,22 +112,22 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() // { // public NodeRef execute() throws Throwable -// { +// { // return TestUtilities.loadFilePlanData(getServer().getApplicationContext()); -// } -// }); +// } +// }); // } /** * This test method ensures that a POST of an RM action to a non-existent node * will result in a 404 status. - * + * * @throws Exception */ public void testPostActionToNonExistentNode() throws Exception { NodeRef nonExistentNode = new NodeRef("workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); - + // Construct the JSON request. JSONObject jsonPostData = new JSONObject(); jsonPostData.put("nodeRef", nonExistentNode.toString()); @@ -137,10 +135,10 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // action is specified here, as the non-existent Node should trigger a 404 // before the action is executed. jsonPostData.put("name", "reviewed"); - + // Submit the JSON request. String jsonPostString = jsonPostData.toString(); - + final int expectedStatus = 404; sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonPostString, APPLICATION_JSON), expectedStatus); } @@ -148,10 +146,10 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan public void testPostReviewedAction() throws IOException, JSONException { NodeRef testRecord = utils.createRecord(recordFolder, "test.txt"); - + // In this test, this property has a date-value equal to the model import time. Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); - + // Construct the JSON request for 'reviewed'. String jsonString = new JSONStringer().object() .key("name").value("reviewed") @@ -163,15 +161,15 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .endObject() .endObject() .toString(); - + // Submit the JSON request. final int expectedStatus = 200; Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonString, APPLICATION_JSON), expectedStatus); - + String rspContent = rsp.getContentAsString(); assertTrue(rspContent.contains("Successfully queued action [reviewed]")); - + Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, pristineReviewAsOf.equals(newReviewAsOfDate)); @@ -182,16 +180,16 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan NodeRef testRecord = utils.createRecord(recordFolder, "test1.txt"); NodeRef testRecord2 = utils.createRecord(recordFolder, "test2.txt"); NodeRef testRecord3 = utils.createRecord(recordFolder, "test3.txt"); - + // In this test, this property has a date-value equal to the model import time. Serializable pristineReviewAsOf = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); Serializable pristineReviewAsOf2 = this.nodeService.getProperty(testRecord2, PROP_REVIEW_AS_OF); Serializable pristineReviewAsOf3 = this.nodeService.getProperty(testRecord3, PROP_REVIEW_AS_OF); - + // Construct the JSON request for 'reviewed'. String jsonString = new JSONStringer().object() .key("name").value("reviewed") - .key("nodeRefs").array() + .key("nodeRefs").array() .value(testRecord.toString()) .value(testRecord2.toString()) .value(testRecord3.toString()) @@ -203,15 +201,15 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .endObject() .endObject() .toString(); - + // Submit the JSON request. final int expectedStatus = 200; Response rsp = sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonString, APPLICATION_JSON), expectedStatus); - + String rspContent = rsp.getContentAsString(); assertTrue(rspContent.contains("Successfully queued action [reviewed]")); - + Serializable newReviewAsOfDate = this.nodeService.getProperty(testRecord, PROP_REVIEW_AS_OF); assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf, pristineReviewAsOf.equals(newReviewAsOfDate)); @@ -222,13 +220,13 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertFalse("The reviewAsOf property should have changed. Was " + pristineReviewAsOf3, pristineReviewAsOf3.equals(newReviewAsOfDate3)); } - + public void testActionParams() throws Exception { // Construct the JSON request for 'reviewed'. String jsonString = new JSONStringer().object() .key("name").value("testActionParams") - .key("nodeRef").array() + .key("nodeRef").array() .value("nothing://nothing/nothing") .endArray() // These JSON params are just to test the submission of params. They'll be ignored. @@ -240,14 +238,14 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .endObject() .endObject() .toString(); - + // Submit the JSON request. final int expectedStatus = 200; //TODO Currently failing unit test. sendRequest(new PostRequest(RMA_ACTIONS_URL, jsonString, APPLICATION_JSON), expectedStatus); } - + public void testPostCustomReferenceDefinitions() throws IOException, JSONException { postCustomReferenceDefinitions(); @@ -255,14 +253,14 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan /** * This method creates a child and a non-child reference and returns their generated ids. - * - * + * + * * @return String[] with element 0 = refId of p/c ref, 1 = refId pf bidi. */ private String[] postCustomReferenceDefinitions() throws JSONException, IOException, UnsupportedEncodingException { String[] result = new String[2]; - + // 1. Child association. String jsonString = new JSONStringer().object() .key("referenceType").value(CustomReferenceType.PARENT_CHILD) @@ -270,17 +268,17 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("target").value(CHILD_TGT) .endObject() .toString(); - + // System.out.println(jsonString); - + // Submit the JSON request. final int expectedStatus = 200; Response rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, jsonString, APPLICATION_JSON), expectedStatus); - + String rspContent = rsp.getContentAsString(); assertTrue(rspContent.contains("success")); - + // System.out.println(rspContent); JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); @@ -293,16 +291,16 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("label").value(BI_DI) .endObject() .toString(); - + // System.out.println(jsonString); - + // Submit the JSON request. rsp = sendRequest(new PostRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL, jsonString, APPLICATION_JSON), expectedStatus); - + rspContent = rsp.getContentAsString(); assertTrue(rspContent.contains("success")); - + // System.out.println(rspContent); jsonRsp = new JSONObject(new JSONTokener(rspContent)); @@ -313,14 +311,14 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan AspectDefinition customAssocsAspect = dictionaryService.getAspect(QName.createQName(RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS, namespaceService)); assertNotNull("Missing customAssocs aspect", customAssocsAspect); - + QName newRefQname = adminService.getQNameForClientId(generatedChildRefId); Map associations = customAssocsAspect.getAssociations(); assertTrue("Custom child assoc not returned by dataDictionary.", associations.containsKey(newRefQname)); newRefQname = adminService.getQNameForClientId(generatedBidiRefId); assertTrue("Custom std assoc not returned by dataDictionary.", customAssocsAspect.getAssociations().containsKey(newRefQname)); - + return result; } @@ -329,14 +327,14 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // POST to create a property definition with a known propId final String propertyLabel = "Original label åçîéøü"; String propId = postCustomPropertyDefinition(propertyLabel, null); - + // PUT an updated label. final String updatedLabel = "Updated label πø^¨¥†®"; String jsonString = new JSONStringer().object() .key("label").value(updatedLabel) .endObject() .toString(); - + String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; Response rsp = sendRequest(new PutRequest(propDefnUrl, jsonString, APPLICATION_JSON), 200); @@ -344,7 +342,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // GET from the URL again to ensure it's valid rsp = sendRequest(new GetRequest(propDefnUrl), 200); String rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); // PUT an updated constraint ref. @@ -353,23 +351,23 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("constraintRef").value(updatedConstraint) .endObject() .toString(); - + propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; rsp = sendRequest(new PutRequest(propDefnUrl, jsonString, APPLICATION_JSON), 200); - + rspContent = rsp.getContentAsString(); - + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); String urlOfNewPropDef = jsonRsp.getString("url"); assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); - + // GET from the URL again to ensure it's valid rsp = sendRequest(new GetRequest(propDefnUrl), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); @@ -378,7 +376,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); Object keyToSoleProp = customPropsObject.keys().next(); - + JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); JSONArray constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); @@ -391,21 +389,21 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("constraintRef").value(null) .endObject() .toString(); - + rsp = sendRequest(new PutRequest(propDefnUrl, jsonString, APPLICATION_JSON), 200); - + rspContent = rsp.getContentAsString(); // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); - + // GET from the URL again to ensure it's valid rsp = sendRequest(new GetRequest(propDefnUrl), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); @@ -414,12 +412,12 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); keyToSoleProp = customPropsObject.keys().next(); - + newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); assertEquals("ConstraintRefsArray wrong length.", 0, constraintRefsArray.length()); - + // Finally PUT a constraint on a PropertyDefn that has been cleared of constraints. // This was raised as an issue final String readdedConstraint = "rmc:tlList"; @@ -427,23 +425,23 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("constraintRef").value(readdedConstraint) .endObject() .toString(); - + propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + propId; rsp = sendRequest(new PutRequest(propDefnUrl, jsonString, APPLICATION_JSON), 200); - + rspContent = rsp.getContentAsString(); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); // System.out.println("PUTting a constraint back again."); // System.out.println(rspContent); - + // And GET from the URL again rsp = sendRequest(new GetRequest(propDefnUrl), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); @@ -452,7 +450,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); keyToSoleProp = customPropsObject.keys().next(); - + newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); assertEquals("Wrong property label.", updatedLabel, newPropObject.getString("label")); constraintRefsArray = newPropObject.getJSONArray("constraintRefs"); @@ -474,10 +472,10 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan JSONObject dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + JSONArray customRefsObj = (JSONArray)dataObj.get("customReferences"); assertNotNull("JSON 'customReferences' object was null", customRefsObj); - + // for (int i = 0; i < customRefsObj.length(); i++) { // System.out.println(customRefsObj.getString(i)); // } @@ -493,7 +491,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + customRefsObj = (JSONArray)dataObj.get("customReferences"); assertNotNull("JSON 'customProperties' object was null", customRefsObj); @@ -509,13 +507,13 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); // System.out.println(rspContent); - + JSONObject dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + JSONArray customTypesObj = (JSONArray)dataObj.get("dodCustomTypes"); assertNotNull("JSON 'dodCustomTypes' object was null", customTypesObj); - + assertEquals("Wrong DOD custom types count.", 4, customTypesObj.length()); } @@ -529,53 +527,53 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // Create reference types. String[] generatedRefIds = postCustomReferenceDefinitions(); - + // Add a standard ref String jsonString = new JSONStringer().object() .key("toNode").value(testRecord2.toString()) .key("refId").value(generatedRefIds[1]) .endObject() .toString(); - + Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, jsonString, APPLICATION_JSON), 200); - + // Add a child ref jsonString = new JSONStringer().object() .key("toNode").value(testRecord2.toString()) .key("refId").value(generatedRefIds[0]) .endObject() .toString(); - + // System.out.println(jsonString); - + rsp = sendRequest(new PostRequest(refInstancesRecord1Url, jsonString, APPLICATION_JSON), 200); - + // System.out.println(rsp.getContentAsString()); - + // Now retrieve the applied references from the REST API // 1. references on the 'from' record. rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); String contentAsString = rsp.getContentAsString(); // System.out.println(contentAsString); - + JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString)); JSONObject dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + JSONArray customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); int customRefsCount = customRefsFromArray.length(); assertTrue("There should be at least one custom reference. Found " + customRefsFromArray, customRefsCount > 0); - + JSONArray customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); assertEquals("customReferencesTo wrong length.", 0, customRefsToArray.length()); - + // 2. Back-references on the 'to' record String node2Url = testRecord2.toString().replace("://", "/"); String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); @@ -583,24 +581,24 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); contentAsString = rsp.getContentAsString(); - + jsonRsp = new JSONObject(new JSONTokener(contentAsString)); dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + customRefsToArray = (JSONArray)dataObj.get("customReferencesTo"); assertNotNull("JSON 'customReferencesTo' object was null", customRefsToArray); customRefsCount = customRefsToArray.length(); assertTrue("There should be at least one custom reference. Found " + customRefsToArray, customRefsCount > 0); - + customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); assertNotNull("JSON 'customReferencesFrom' object was null", customRefsFromArray); assertEquals("customReferencesFrom wrong length.", 0, customRefsFromArray.length()); - + // Now to delete a reference instance of each type String protocol = testRecord2.getStoreRef().getProtocol(); String identifier = testRecord2.getStoreRef().getIdentifier(); @@ -615,15 +613,15 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan + generatedRefIds[0] + urlQueryString), 200); assertTrue(rsp.getContentAsString().contains("success")); - + // Get the reference instances back and confirm they've been removed. rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + customRefsFromArray = (JSONArray)dataObj.get("customReferencesFrom"); assertNotNull("JSON 'customReferences' object was null", customRefsFromArray); assertTrue("customRefsArray was unexpectedly not empty.", customRefsFromArray.length() == 0); @@ -639,10 +637,10 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan String node2Url = testRecord2.toString().replace("://", "/"); String refInstancesRecord1Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node1Url); String refInstancesRecord2Url = MessageFormat.format(REF_INSTANCES_URL_FORMAT, node2Url); - + {// Sanity check. There should be no references defined on these new records. Response rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - + String rspContent = rsp.getContentAsString(); JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObj = jsonRsp.getJSONObject("data"); @@ -659,18 +657,18 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("refId").value(supersedesRefLocalName) .endObject() .toString(); - + Response rsp = sendRequest(new PostRequest(refInstancesRecord1Url, jsonString, APPLICATION_JSON), 200); - + // The bug is that we can apply two such references which should not be allowed rsp = sendRequest(new PostRequest(refInstancesRecord1Url, jsonString, APPLICATION_JSON), 500); - + {// Retrieve reference instances on this pair of records. // The first record rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - + String rspContent = rsp.getContentAsString(); JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObj = jsonRsp.getJSONObject("data"); @@ -681,7 +679,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // The second record - the back-reference rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); - + rspContent = rsp.getContentAsString(); jsonRsp = new JSONObject(new JSONTokener(rspContent)); dataObj = jsonRsp.getJSONObject("data"); @@ -690,7 +688,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertEquals("Incorrect from-refs count.", 0, refsFrom.length()); assertEquals("Incorrect to-refs count.", 1, refsTo.length()); } - + // Delete the reference instance String protocol = testRecord2.getStoreRef().getProtocol(); String identifier = testRecord2.getStoreRef().getIdentifier(); @@ -704,7 +702,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan {// Retrieve reference instances on this pair of records. // The first record rsp = sendRequest(new GetRequest(refInstancesRecord1Url), 200); - + String rspContent = rsp.getContentAsString(); JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObj = jsonRsp.getJSONObject("data"); @@ -715,7 +713,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan // The second record - the back-reference rsp = sendRequest(new GetRequest(refInstancesRecord2Url), 200); - + rspContent = rsp.getContentAsString(); jsonRsp = new JSONObject(new JSONTokener(rspContent)); dataObj = jsonRsp.getJSONObject("data"); @@ -740,7 +738,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan /** * Creates a new property definition using a POST call. * GETs the resultant property definition. - * + * * @param propertyLabel the label to use * @param propId the propId to use - null to have one generated. * @return the propId of the new property definition @@ -775,42 +773,42 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .endObject() .toString(); } - + // Submit the JSON request. final int expectedStatus = 200; Response rsp = sendRequest(new PostRequest("/api/rma/admin/custompropertydefinitions?element=record", jsonString, APPLICATION_JSON), expectedStatus); - + String rspContent = rsp.getContentAsString(); // System.out.println(rspContent); - + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); String urlOfNewPropDef = jsonRsp.getString("url"); String newPropId = jsonRsp.getString("propId"); assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef); - + // GET from the URL we're given to ensure it's valid rsp = sendRequest(new GetRequest(urlOfNewPropDef), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); JSONObject customPropsObject = dataObject.getJSONObject("customProperties"); assertNotNull("JSON customProperties object was null", customPropsObject); assertEquals("Wrong customProperties length.", 1, customPropsObject.length()); - + Object keyToSoleProp = customPropsObject.keys().next(); - + // System.out.println("New property defn: " + keyToSoleProp); - + JSONObject newPropObject = customPropsObject.getJSONObject((String)keyToSoleProp); assertEquals("Wrong property label.", propertyLabel, newPropObject.getString("label")); - + return newPropId; } @@ -819,7 +817,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan String[] generatedRefIds = postCustomReferenceDefinitions(); final String pcRefId = generatedRefIds[0]; final String bidiRefId = generatedRefIds[1]; - + // GET the custom refs in order to retrieve the label/source/target String refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; Response rsp = sendRequest(new GetRequest(refDefnUrl), 200); @@ -834,38 +832,38 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan rspContent = rsp.getContentAsString(); // System.out.println(rspContent); jsonRsp = new JSONObject(new JSONTokener(rspContent)); - + // Update the bidirectional reference. final String updatedBiDiLabel = "Updated label üøéîçå"; String jsonString = new JSONStringer().object() .key("label").value(updatedBiDiLabel) .endObject() .toString(); - + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + bidiRefId; rsp = sendRequest(new PutRequest(refDefnUrl, jsonString, APPLICATION_JSON), 200); - + rspContent = rsp.getContentAsString(); // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); String urlOfNewRefDef = jsonRsp.getString("url"); assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); - + // GET the bidi reference to ensure it's valid rsp = sendRequest(new GetRequest(refDefnUrl), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); JSONArray customRefsObject = dataObject.getJSONArray("customReferences"); assertNotNull("JSON customReferences object was null", customRefsObject); assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); - + JSONObject newRefObject = customRefsObject.getJSONObject(0); assertEquals("Wrong property label.", updatedBiDiLabel, newRefObject.getString("label")); @@ -877,33 +875,33 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("target").value(updatedPcTarget) .endObject() .toString(); - + refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; rsp = sendRequest(new PutRequest(refDefnUrl, jsonString, APPLICATION_JSON), 200); - + rspContent = rsp.getContentAsString(); // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); urlOfNewRefDef = jsonRsp.getString("url"); assertNotNull("urlOfNewRefDef was null.", urlOfNewRefDef); - + // GET the parent/child reference to ensure it's valid refDefnUrl = "/api/rma/admin/customreferencedefinitions/" + pcRefId; rsp = sendRequest(new GetRequest(refDefnUrl), 200); rspContent = rsp.getContentAsString(); - + // System.out.println(rspContent); - + jsonRsp = new JSONObject(new JSONTokener(rspContent)); dataObject = jsonRsp.getJSONObject("data"); assertNotNull("JSON data object was null", dataObject); customRefsObject = dataObject.getJSONArray("customReferences"); assertNotNull("JSON customReferences object was null", customRefsObject); assertEquals("Wrong customReferences length.", 1, customRefsObject.length()); - + newRefObject = customRefsObject.getJSONObject(0); assertEquals("Wrong reference source.", updatedPcSource, newRefObject.getString("source")); assertEquals("Wrong reference target.", updatedPcTarget, newRefObject.getString("target")); @@ -929,16 +927,16 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan JSONObject dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + JSONObject customPropsObj = (JSONObject)dataObj.get("customProperties"); assertNotNull("JSON 'customProperties' object was null", customPropsObj); - + final int customPropsCount = customPropsObj.length(); assertTrue("There should be at least one custom property. Found " + customPropsObj, customPropsCount > 0); - + return contentAsString; } - + public void testGetRecordMetaDataAspects() throws Exception { Response rsp = sendRequest(new GetRequest("/api/rma/recordmetadataaspects"), 200); @@ -948,18 +946,18 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan JSONObject dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); - + JSONArray aspects = dataObj.getJSONArray("recordMetaDataAspects"); assertNotNull(aspects); assertEquals(4, aspects.length()); - + // TODO test the items themselves } - + public void testExport() throws Exception { String exportUrl = "/api/rma/admin/export"; - + // define JSON POST body JSONObject jsonPostData = new JSONObject(); JSONArray nodeRefs = new JSONArray(); @@ -967,16 +965,16 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan nodeRefs.put(recordFolder2.toString()); jsonPostData.put("nodeRefs", nodeRefs); String jsonPostString = jsonPostData.toString(); - + // make the export request Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); assertEquals("application/acp", rsp.getContentType()); } - + public void testExportInTransferFormat() throws Exception { String exportUrl = "/api/rma/admin/export"; - + // define JSON POST body JSONObject jsonPostData = new JSONObject(); JSONArray nodeRefs = new JSONArray(); @@ -985,19 +983,19 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan jsonPostData.put("nodeRefs", nodeRefs); jsonPostData.put("transferFormat", true); String jsonPostString = jsonPostData.toString(); - + // make the export request Response rsp = sendRequest(new PostRequest(exportUrl, jsonPostString, APPLICATION_JSON), 200); assertEquals("application/zip", rsp.getContentType()); } - + public void testAudit() throws Exception { // call the list service to get audit events Response rsp = sendRequest(new GetRequest(GET_LIST_URL), 200); //System.out.println("GET : " + rsp.getContentAsString()); assertEquals("application/json;charset=UTF-8", rsp.getContentType()); - + // get response as JSON and check JSONObject jsonParsedObject = new JSONObject(new JSONTokener(rsp.getContentAsString())); assertNotNull(jsonParsedObject); @@ -1015,49 +1013,49 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL), 200); assertEquals("application/json", rsp.getContentType()); JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + // get the full RM audit log as an HTML report and check response rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?format=html"), 200); assertEquals("text/html", rsp.getContentType()); - + // export the full RM audit log and check response rsp = sendRequest(new GetRequest(RMA_AUDITLOG_URL + "?export=true"), 200); assertEquals("application/json", rsp.getContentType()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + // construct the URL String nodeUrl = recordCategory.toString().replace("://", "/"); String auditUrl = MessageFormat.format(GET_NODE_AUDITLOG_URL_FORMAT, nodeUrl); - + // send request rsp = sendRequest(new GetRequest(auditUrl), 200); // check response assertEquals("application/json", rsp.getContentType()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + // get the audit log with all restrictions in place String filteredAuditUrl = auditUrl + "?user=gavinc&size=5&from=2009-01-01&to=2009-12-31&event=Login"; rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); // check response assertEquals("application/json", rsp.getContentType()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + // attempt to get the audit log with invalid restrictions in place filteredAuditUrl = auditUrl + "?user=fred&size=abc&from=2009&to=2010&property=wrong"; rsp = sendRequest(new GetRequest(filteredAuditUrl), 200); assertEquals("application/json", rsp.getContentType()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); - + checkAuditStatus(true); - + // start the RM audit log JSONObject jsonPostData = new JSONObject(); jsonPostData.put("enabled", true); String jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - + checkAuditStatus(true); - + // check the response //System.out.println(rsp.getContentAsString()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); @@ -1066,22 +1064,22 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertTrue(dataObj.getBoolean("enabled")); assertTrue(dataObj.has("started")); assertTrue(dataObj.has("stopped")); - + // stop the RM audit log jsonPostData = new JSONObject(); jsonPostData.put("enabled", false); jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PutRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - + checkAuditStatus(false); - + // check the response //System.out.println(rsp.getContentAsString()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); dataObj = (JSONObject)jsonRsp.get("data"); assertNotNull("JSON 'data' object was null", dataObj); assertFalse(dataObj.getBoolean("enabled")); - + // clear the RM audit log rsp = sendRequest(new DeleteRequest(RMA_AUDITLOG_URL), 200); //System.out.println(rsp.getContentAsString()); @@ -1090,17 +1088,17 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertNotNull("JSON 'data' object was null", dataObj); assertFalse(dataObj.getBoolean("enabled")); } - - private void checkAuditStatus(boolean expected) throws Exception + + private void checkAuditStatus(boolean expected) throws Exception { Response rsp = sendRequest(new GetRequest(RMA_AUDITLOG_STATUS_URL), 200); JSONObject rspObj = new JSONObject(rsp.getContentAsString()); JSONObject data = rspObj.getJSONObject("data"); boolean enabled = data.getBoolean("enabled"); assertEquals("Audit log status does not match expected status.", expected, enabled); - + } - + public void testFileAuditLogAsRecord() throws Exception { // Attempt to store audit log at non existent destination, make sure we get 404 @@ -1108,20 +1106,20 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan jsonPostData.put("destination", "workspace://SpacesStore/09ca1e02-1c87-4a53-97e7-xxxxxxxxxxxx"); String jsonPostString = jsonPostData.toString(); Response rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 404); - + // Attempt to store audit log at wrong type of destination, make sure we get 400 jsonPostData = new JSONObject(); jsonPostData.put("destination", recordCategory.toString()); jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 400); - - + + // Store the full audit log as a record jsonPostData = new JSONObject(); jsonPostData.put("destination", recordFolder2); jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - + // check the response System.out.println(rsp.getContentAsString()); JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); @@ -1133,7 +1131,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan assertTrue(jsonRsp.has("recordName")); assertNotNull(jsonRsp.get("recordName")); assertTrue(jsonRsp.getString("recordName").startsWith("audit_")); - + // Store a filtered audit log as a record jsonPostData = new JSONObject(); jsonPostData.put("destination", recordFolder2); @@ -1143,7 +1141,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan jsonPostData.put("property", "{http://www.alfresco.org/model/content/1.0}modified"); jsonPostString = jsonPostData.toString(); rsp = sendRequest(new PostRequest(RMA_AUDITLOG_URL, jsonPostString, APPLICATION_JSON), 200); - + // check the response System.out.println(rsp.getContentAsString()); jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString())); @@ -1160,7 +1158,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan public void testPropertyLabelWithAccentedChars() throws Exception { final long number = System.currentTimeMillis(); - + // Create a property with a simple name final String simplePropId = "simpleId" + number; postCustomPropertyDefinition("simple", simplePropId); @@ -1178,10 +1176,10 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan putCustomPropDefinition("three", simplePropId); putCustomPropDefinition("four", simplePropId); putCustomPropDefinition("five", simplePropId); - + // Now get all the custom properties back. String rspContent = getCustomProperties(); - + JSONObject rspObject = new JSONObject(new JSONTokener(rspContent)); JSONObject dataObj = rspObject.getJSONObject("data"); assertNotNull("jsonObject was null", dataObj); @@ -1204,14 +1202,14 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan .key("label").value(label) .endObject() .toString(); - + String propDefnUrl = "/api/rma/admin/custompropertydefinitions/" + id; Response rsp = sendRequest(new PutRequest(propDefnUrl, jsonString, APPLICATION_JSON), 200); - + String rspContent = rsp.getContentAsString(); // System.out.println(rspContent); - + JSONObject jsonRsp = new JSONObject(new JSONTokener(rspContent)); String urlOfNewPropDef = jsonRsp.getString("url"); assertNotNull("urlOfNewPropDef was null.", urlOfNewPropDef);