From 05aefebbdf32a16dea7573e599053e1eeed2cda9 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Thu, 28 Nov 2013 17:46:16 +0000 Subject: [PATCH] RM-1099 (Refactor Transfer and Accession reports) * Fixed failing tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58401 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../messages/actions.properties | 6 +- .../rm-report-context.xml | 5 +- ....java => FileDestructionReportAction.java} | 118 ++++++++---------- .../report/action/FileReportAction.java | 118 ++++++++++-------- 4 files changed, 123 insertions(+), 124 deletions(-) rename rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/{FileTransferAction.java => FileDestructionReportAction.java} (51%) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties index 4be8313bd3..dacd5b43c5 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties @@ -160,9 +160,9 @@ retain.description=Retain # Add Record Types addRecordTypes.title=Add record types addRecordTypes.description=Adds the selected type(s) to the record -# File Transfer Report -fileTransferReport.title=File transfer report -fileTransferReport.description=File transfer report +# File Report +fileReport.title=File transfer report +fileReport.description=File transfer report # Action parameter constraints diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml index 4c5b7a0a7d..ca06ad2f2e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-report-context.xml @@ -87,7 +87,6 @@ - @@ -116,7 +115,7 @@ @@ -147,7 +146,7 @@ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileTransferAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileDestructionReportAction.java similarity index 51% rename from rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileTransferAction.java rename to rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileDestructionReportAction.java index f4a3feb646..5a83ca2b8e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileTransferAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileDestructionReportAction.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -20,33 +20,33 @@ package org.alfresco.module.org_alfresco_module_rm.report.action; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.report.Report; import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; import org.alfresco.module.org_alfresco_module_rm.report.ReportService; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; -import org.apache.commons.lang.StringUtils; -import org.springframework.extensions.surf.util.I18NUtil; +import org.alfresco.util.ParameterCheck; /** - * File transfer action - * - * @author Tuna Aksoy - * @since 2.2 + * File Report Action + * + * @author Roy Wetherall + * @since 2.1 */ -public class FileTransferAction extends RMActionExecuterAbstractBase implements ReportModel +public class FileDestructionReportAction extends RMActionExecuterAbstractBase + implements ReportModel { - /** Constants for the parameters passed from UI */ - private static final String REPORT_TYPE = "reportType"; - private static final String DESTINATION = "destination"; - - /** I18N */ - private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied"; - /** report service */ protected ReportService reportService; - + + /** file plan service */ + protected FilePlanService filePlanService; + + /** report type string value */ + private String reportType; + /** * @param reportService report service */ @@ -54,7 +54,32 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements { this.reportService = reportService; } - + + /** + * @param filePlanService file plan service + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * @param reportType report type string value + */ + public void setReportType(String reportType) + { + this.reportType = reportType; + } + + /** + * @return QName report type + */ + protected QName getReportType() + { + ParameterCheck.mandatory("this.reportType", reportType); + return QName.createQName(reportType, namespaceService); + } + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -63,54 +88,17 @@ public class FileTransferAction extends RMActionExecuterAbstractBase implements { // TODO check that the actionedUponNodeRef is in a state to generate a destruction report // ie: is it eligable for destruction .. use fileDestructionReport capability! - + // TODO allow the mimetype of the report to be specified as a parameter - - QName reportType = getReportType(action); - Report report = reportService.generateReport(reportType, actionedUponNodeRef); - - NodeRef destination = getDestination(action); - reportService.fileReport(destination, report); - } - - /** - * Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown - * - * @param action The action - * @param parameter The parameter for which the value should be retrieved - * @return The value of the given parameter - */ - private String getParameterValue(Action action, String parameter) - { - String paramValue = (String) action.getParameterValue(parameter); - if (StringUtils.isBlank(paramValue) == true) + + NodeRef filePlan = filePlanService.getFilePlan(actionedUponNodeRef); + if (filePlan == null) { - throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARAM_NOT_SUPPLIED, parameter)); + throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved."); } - return paramValue; - } - - /** - * Helper method for getting the destination. - * - * @param action The action - * @return The file plan node reference - */ - private NodeRef getDestination(Action action) - { - String destination = getParameterValue(action, DESTINATION); - return new NodeRef(destination); - } - - /** - * Helper method for getting the report type. - * - * @param action The action - * @return The report type - */ - private QName getReportType(Action action) - { - String reportType = getParameterValue(action, REPORT_TYPE); - return QName.createQName(reportType, namespaceService); - } -} + + Report report = reportService.generateReport(getReportType(), actionedUponNodeRef); + reportService.fileReport(filePlan, report); + + } +} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileReportAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileReportAction.java index bb544d97e2..07a1725f40 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileReportAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileReportAction.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -20,33 +20,33 @@ package org.alfresco.module.org_alfresco_module_rm.report.action; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.report.Report; import org.alfresco.module.org_alfresco_module_rm.report.ReportModel; import org.alfresco.module.org_alfresco_module_rm.report.ReportService; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; +import org.springframework.extensions.surf.util.I18NUtil; /** - * File Report Action - * - * @author Roy Wetherall - * @since 2.1 + * File report action + * + * @author Tuna Aksoy + * @since 2.2 */ -public class FileReportAction extends RMActionExecuterAbstractBase - implements ReportModel +public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel { + /** Constants for the parameters passed from UI */ + private static final String REPORT_TYPE = "reportType"; + private static final String DESTINATION = "destination"; + + /** I18N */ + private static final String MSG_PARAM_NOT_SUPPLIED = "rm.action.parameter-not-supplied"; + /** report service */ protected ReportService reportService; - - /** file plan service */ - protected FilePlanService filePlanService; - - /** report type string value */ - private String reportType; - + /** * @param reportService report service */ @@ -54,32 +54,7 @@ public class FileReportAction extends RMActionExecuterAbstractBase { this.reportService = reportService; } - - /** - * @param filePlanService file plan service - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * @param reportType report type string value - */ - public void setReportType(String reportType) - { - this.reportType = reportType; - } - - /** - * @return QName report type - */ - protected QName getReportType() - { - ParameterCheck.mandatory("this.reportType", reportType); - return QName.createQName(reportType, namespaceService); - } - + /** * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @@ -88,17 +63,54 @@ public class FileReportAction extends RMActionExecuterAbstractBase { // TODO check that the actionedUponNodeRef is in a state to generate a destruction report // ie: is it eligable for destruction .. use fileDestructionReport capability! - + // TODO allow the mimetype of the report to be specified as a parameter - - NodeRef filePlan = filePlanService.getFilePlan(actionedUponNodeRef); - if (filePlan == null) + + QName reportType = getReportType(action); + Report report = reportService.generateReport(reportType, actionedUponNodeRef); + + NodeRef destination = getDestination(action); + reportService.fileReport(destination, report); + } + + /** + * Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown + * + * @param action The action + * @param parameter The parameter for which the value should be retrieved + * @return The value of the given parameter + */ + private String getParameterValue(Action action, String parameter) + { + String paramValue = (String) action.getParameterValue(parameter); + if (StringUtils.isBlank(paramValue) == true) { - throw new AlfrescoRuntimeException("Unable to file destruction report, because file plan could not be resolved."); + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PARAM_NOT_SUPPLIED, parameter)); } - - Report report = reportService.generateReport(getReportType(), actionedUponNodeRef); - reportService.fileReport(filePlan, report); - - } -} \ No newline at end of file + return paramValue; + } + + /** + * Helper method for getting the destination. + * + * @param action The action + * @return The file plan node reference + */ + private NodeRef getDestination(Action action) + { + String destination = getParameterValue(action, DESTINATION); + return new NodeRef(destination); + } + + /** + * Helper method for getting the report type. + * + * @param action The action + * @return The report type + */ + private QName getReportType(Action action) + { + String reportType = getParameterValue(action, REPORT_TYPE); + return QName.createQName(reportType, namespaceService); + } +}