From 30e3ea689fc0cf6ada9eac5da343bdd4b7a0de04 Mon Sep 17 00:00:00 2001 From: Sara Aspery Date: Mon, 18 Nov 2019 15:59:54 +0000 Subject: [PATCH] RM-7028 review updates --- .../audit/event/AddToHoldAuditEvent.java | 14 +- .../extractor/NamePathDataExtractor.java | 3 +- .../test/util/CommonRMTestUtils.java | 142 +++++++++--------- 3 files changed, 82 insertions(+), 77 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToHoldAuditEvent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToHoldAuditEvent.java index eb784ef9bb..6cac5e2cf6 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToHoldAuditEvent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/event/AddToHoldAuditEvent.java @@ -27,6 +27,11 @@ package org.alfresco.module.org_alfresco_module_rm.audit.event; +import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.EVERY_EVENT; + +import java.io.Serializable; +import java.util.Map; + import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.hold.HoldServicePolicies; import org.alfresco.repo.policy.annotation.Behaviour; @@ -36,11 +41,6 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; -import java.io.Serializable; -import java.util.Map; - -import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.EVERY_EVENT; - /** * Add to hold audit event. * @@ -50,7 +50,9 @@ import static org.alfresco.repo.policy.Behaviour.NotificationFrequency.EVERY_EVE @BehaviourBean public class AddToHoldAuditEvent extends AuditEvent implements HoldServicePolicies.OnAddToHoldPolicy { - /** Node Service */ + /** + * Node Service + */ private NodeService nodeService; /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java index 986c3b5af7..d3a1097b9b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/audit/extractor/NamePathDataExtractor.java @@ -51,7 +51,8 @@ import org.alfresco.service.cmr.security.PermissionService; * @see FilePlanService#getNodeRefPath(NodeRef) * * @author Derek Hulley - * @since 3.2 + * @author Sara Aspery + * @since 3.3 */ public final class NamePathDataExtractor extends AbstractDataExtractor { diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java index c6e55cf248..cfccf57693 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/CommonRMTestUtils.java @@ -27,6 +27,8 @@ package org.alfresco.module.org_alfresco_module_rm.test.util; +import static org.alfresco.util.GUID.generate; + import java.io.InputStream; import java.io.Serializable; import java.util.ArrayList; @@ -66,8 +68,6 @@ import org.alfresco.service.namespace.QName; import org.apache.commons.lang.StringUtils; import org.springframework.context.ApplicationContext; -import static org.alfresco.util.GUID.generate; - /** * Common RM test utility methods. * @@ -75,6 +75,18 @@ import static org.alfresco.util.GUID.generate; */ public class CommonRMTestUtils implements RecordsManagementModel { + /** + * test values + */ + public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority"; + public static final String DEFAULT_DISPOSITION_INSTRUCTIONS = "disposition instructions"; + public static final String DEFAULT_DISPOSITION_DESCRIPTION = "disposition action description"; + public static final String DEFAULT_EVENT_NAME = "case_closed"; + public static final String PERIOD_NONE = "none|0"; + public static final String PERIOD_IMMEDIATELY = "immediately|0"; + public static final String PERIOD_ONE_WEEK = "week|1"; + public static final String PERIOD_ONE_YEAR = "year|1"; + public static final String PERIOD_THREE_YEARS = "year|3"; private DispositionService dispositionService; private NodeService nodeService; private ContentService contentService; @@ -85,33 +97,22 @@ public class CommonRMTestUtils implements RecordsManagementModel private RecordService recordService; private HoldService holdService; - /** test values */ - public static final String DEFAULT_DISPOSITION_AUTHORITY = "disposition authority"; - public static final String DEFAULT_DISPOSITION_INSTRUCTIONS = "disposition instructions"; - public static final String DEFAULT_DISPOSITION_DESCRIPTION = "disposition action description"; - public static final String DEFAULT_EVENT_NAME = "case_closed"; - public static final String PERIOD_NONE = "none|0"; - public static final String PERIOD_IMMEDIATELY = "immediately|0"; - public static final String PERIOD_ONE_WEEK = "week|1"; - public static final String PERIOD_ONE_YEAR = "year|1"; - public static final String PERIOD_THREE_YEARS = "year|3"; - /** * Constructor * - * @param applicationContext application context + * @param applicationContext application context */ public CommonRMTestUtils(ApplicationContext applicationContext) { - dispositionService = (DispositionService)applicationContext.getBean("DispositionService"); - nodeService = (NodeService)applicationContext.getBean("NodeService"); - contentService = (ContentService)applicationContext.getBean("ContentService"); - actionService = (RecordsManagementActionService)applicationContext.getBean("RecordsManagementActionService"); - modelSecurityService = (ModelSecurityService)applicationContext.getBean("ModelSecurityService"); - filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("FilePlanRoleService"); - capabilityService = (CapabilityService)applicationContext.getBean("CapabilityService"); - recordService = (RecordService)applicationContext.getBean("RecordService"); - holdService = (HoldService)applicationContext.getBean("HoldService"); + dispositionService = (DispositionService) applicationContext.getBean("DispositionService"); + nodeService = (NodeService) applicationContext.getBean("NodeService"); + contentService = (ContentService) applicationContext.getBean("ContentService"); + actionService = (RecordsManagementActionService) applicationContext.getBean("RecordsManagementActionService"); + modelSecurityService = (ModelSecurityService) applicationContext.getBean("ModelSecurityService"); + filePlanRoleService = (FilePlanRoleService) applicationContext.getBean("FilePlanRoleService"); + capabilityService = (CapabilityService) applicationContext.getBean("CapabilityService"); + recordService = (RecordService) applicationContext.getBean("RecordService"); + holdService = (HoldService) applicationContext.getBean("HoldService"); } /** @@ -128,26 +129,26 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Create test disposition schedule */ - public DispositionSchedule createBasicDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions) - { - return createDispositionSchedule(container, dispositionInstructions, dispositionAuthority, isRecordLevel, defaultDispositionActions, false); - } + public DispositionSchedule createBasicDispositionSchedule( + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions) + { + return createDispositionSchedule(container, dispositionInstructions, dispositionAuthority, isRecordLevel, defaultDispositionActions, false); + } /** * Create test disposition schedule */ public DispositionSchedule createDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions, - boolean extendedDispositionSchedule) + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions, + boolean extendedDispositionSchedule) { return createDispositionSchedule( container, @@ -163,13 +164,13 @@ public class CommonRMTestUtils implements RecordsManagementModel * Create test disposition schedule */ public DispositionSchedule createDispositionSchedule( - NodeRef container, - String dispositionInstructions, - String dispositionAuthority, - boolean isRecordLevel, - boolean defaultDispositionActions, - boolean extendedDispositionSchedule, - String defaultEvent) + NodeRef container, + String dispositionInstructions, + String dispositionAuthority, + boolean isRecordLevel, + boolean defaultDispositionActions, + boolean extendedDispositionSchedule, + String defaultEvent) { Map dsProps = new HashMap<>(3); dsProps.put(PROP_DISPOSITION_AUTHORITY, dispositionAuthority); @@ -185,7 +186,7 @@ public class CommonRMTestUtils implements RecordsManagementModel List events = new ArrayList<>(1); events.add(defaultEvent); - adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events); + adParams.put(PROP_DISPOSITION_EVENT, (Serializable) events); dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams); @@ -214,8 +215,8 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to create a record in a record folder. * - * @param recordFolder record folder - * @param name name of record + * @param recordFolder record folder + * @param name name of record * @return {@link NodeRef} record node reference */ public NodeRef createRecord(NodeRef recordFolder, String name) @@ -226,9 +227,9 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to create a record in a record folder. * - * @param recordFolder record folder - * @param name name of the record - * @param title title of the record + * @param recordFolder record folder + * @param name name of the record + * @param title title of the record * @return {@link NodeRef} record node reference */ public NodeRef createRecord(NodeRef recordFolder, String name, String title) @@ -241,10 +242,10 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to create a record in a record folder. * - * @param recordFolder record folder - * @param name name of record - * @param properties properties of the record - * @param content content of the record + * @param recordFolder record folder + * @param name name of record + * @param properties properties of the record + * @param content content of the record * @return {@link NodeRef} record node reference */ public NodeRef createRecord(NodeRef recordFolder, String name, Map properties, String content) @@ -264,10 +265,10 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to create a record in a record folder. * - * @param recordFolder record folder - * @param name name of record - * @param properties properties of the record - * @param content content of the record + * @param recordFolder record folder + * @param name name of record + * @param properties properties of the record + * @param content content of the record * @return {@link NodeRef} record node reference */ public NodeRef createRecord(NodeRef recordFolder, String name, Map properties, String mimetype, InputStream content) @@ -344,8 +345,7 @@ public class CommonRMTestUtils implements RecordsManagementModel nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date()); nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue"); actionService.executeRecordsManagementAction(record, "declareRecord"); - } - finally + } finally { modelSecurityService.setEnabled(true); } @@ -368,8 +368,7 @@ public class CommonRMTestUtils implements RecordsManagementModel try { actionService.executeRecordsManagementAction(recordFolder, "closeRecordFolder"); - } - finally + } finally { modelSecurityService.setEnabled(true); } @@ -378,7 +377,7 @@ public class CommonRMTestUtils implements RecordsManagementModel }, AuthenticationUtil.getAdminUserName()); } - public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames) + public Role createRole(NodeRef filePlan, String roleName, String... capabilityNames) { Set capabilities = new HashSet<>(capabilityNames.length); for (String name : capabilityNames) @@ -397,8 +396,8 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to complete event on disposable item * - * @param disposableItem disposable item (record or record folder) - * @param eventName event name + * @param disposableItem disposable item (record or record folder) + * @param eventName event name */ public void completeEvent(NodeRef disposableItem, String eventName) { @@ -412,7 +411,8 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to create a hold. - * @param holdName hold name + * + * @param holdName hold name * @param holdReason hold reason * @return NodeRef hold node reference */ @@ -423,7 +423,8 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Helper method to delete a hold. - * @param nodeRef hold node reference + * + * @param nodeRef hold node reference */ public void deleteHold(NodeRef nodeRef) { @@ -432,8 +433,9 @@ public class CommonRMTestUtils implements RecordsManagementModel /** * Util method to add content to a hold. - * @param holdNodeRef hold node reference - * @param contentNodeRef content node reference + * + * @param holdNodeRef hold node reference + * @param contentNodeRef content node reference */ public void addItemToHold(NodeRef holdNodeRef, NodeRef contentNodeRef) {