diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl index e90adc9968..91592740fd 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl @@ -39,12 +39,11 @@ ${message("file.report.performed.by")}: - ${node.properties["cm:creator"]?html} + ${node.properties["cm:creator"]?html} ${message("file.report.disposition.authority")}: - <#-- FIXME: Disposition Authority - Check, escape --> - + ${properties["dispositionAuthority"]?html}

${message("file.report.transferred.items")}

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 36861531e3..bea19e02c1 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 @@ -93,22 +93,29 @@ - + + + + + + + - + - + - + - - + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW @@ -116,10 +123,29 @@ - - + + + + + + + + + + + + + + + + + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.execute=RM_CAP.0.rma:filePlanComponent.FileDestructionReport + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction.*=RM_ALLOW + org.alfresco.repo.action.executer.ActionExecuter.*=RM_ALLOW + + \ 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/BaseReportAction.java similarity index 85% rename from rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/FileReportAction.java rename to rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/BaseReportAction.java index a8b9f1f3b8..6e919229d7 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/BaseReportAction.java @@ -18,11 +18,15 @@ */ package org.alfresco.module.org_alfresco_module_rm.report.action; +import java.io.Serializable; +import java.util.Map; + import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase; 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.repo.content.MimetypeMap; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; @@ -30,12 +34,12 @@ import org.apache.commons.lang.StringUtils; import org.springframework.extensions.surf.util.I18NUtil; /** - * File report action + * Base class for the report action classes * * @author Tuna Aksoy * @since 2.2 */ -public class FileReportAction extends RMActionExecuterAbstractBase implements ReportModel +public abstract class BaseReportAction extends RMActionExecuterAbstractBase implements ReportModel { /** Constants for the parameters passed from the UI */ public static final String REPORT_TYPE = "reportType"; @@ -67,12 +71,19 @@ public class FileReportAction extends RMActionExecuterAbstractBase implements Re // TODO allow the mimetype of the report to be specified as a parameter QName reportType = getReportType(action); - Report report = reportService.generateReport(reportType, actionedUponNodeRef); + Report report = reportService.generateReport(reportType, actionedUponNodeRef, MimetypeMap.MIMETYPE_HTML, addProperties(actionedUponNodeRef)); NodeRef destination = getDestination(action); reportService.fileReport(destination, report); } + /** + * Gives other action classes to pass additional properties for the template model + * + * @return Properties which are passed to the template model + */ + protected abstract Map addProperties(NodeRef nodeRef); + /** * Retrieves the value of the given parameter. If the parameter has not been passed from the UI an error will be thrown * diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/DestructionReportAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/DestructionReportAction.java new file mode 100644 index 0000000000..2118b31d28 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/DestructionReportAction.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2005-2013 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.action; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Destruction report action + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class DestructionReportAction extends BaseReportAction +{ + @Override + protected Map addProperties(NodeRef nodeRef) + { + return new HashMap(1); + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/TransferReportAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/TransferReportAction.java new file mode 100644 index 0000000000..eef2c84d49 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/report/action/TransferReportAction.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2005-2013 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.report.action; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.RegexQNamePattern; +import org.apache.commons.lang.StringUtils; + +/** + * Transfer report action + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class TransferReportAction extends BaseReportAction +{ + @Override + protected Map addProperties(NodeRef nodeRef) + { + // Get all 'transferred' nodes + NodeRef[] transferNodes = getTransferNodes(nodeRef); + + // Get the disposition authority + String dispositionAuthority = getDispositionAuthority(transferNodes); + + // Save to the properties map + Map properties = new HashMap(2); + properties.put("transferNodes", transferNodes); + properties.put("dispositionAuthority", dispositionAuthority); + + return properties; + } + + /** + * Returns an array of NodeRefs representing the items to be transferred. + * + * @param transferNode The transfer object + * @return Array of NodeRefs + */ + private NodeRef[] getTransferNodes(NodeRef transferNode) + { + List assocs = this.nodeService.getChildAssocs(transferNode, + RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL); + NodeRef[] itemsToTransfer = new NodeRef[assocs.size()]; + for (int idx = 0; idx < assocs.size(); idx++) + { + itemsToTransfer[idx] = assocs.get(idx).getChildRef(); + } + return itemsToTransfer; + } + + /** + * Gets the disposition authority from the array of the transfer objects + * + * @param itemsToTransfer The transfer objects + * @return Disposition authority + */ + private String getDispositionAuthority(NodeRef[] itemsToTransfer) + { + // use RMService to get disposition authority + String dispositionAuthority = null; + if (itemsToTransfer.length > 0) + { + // use the first transfer item to get to disposition schedule + DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); + if (ds != null) + { + dispositionAuthority = ds.getDispositionAuthority(); + } + } + return dispositionAuthority == null ? StringUtils.EMPTY : dispositionAuthority; + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ReportServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ReportServiceImplTest.java index 8722c08536..d3508f4e2e 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ReportServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ReportServiceImplTest.java @@ -28,7 +28,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; 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.action.FileReportAction; +import org.alfresco.module.org_alfresco_module_rm.report.action.DestructionReportAction; import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; import org.alfresco.service.cmr.repository.NodeRef; @@ -120,8 +120,8 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel rmActionService.executeRecordsManagementAction(rmFolder, CutOffAction.NAME); rmActionService.executeRecordsManagementAction(rmFolder, DestroyAction.NAME); Map fileReportParams = new HashMap(2); - fileReportParams.put(FileReportAction.REPORT_TYPE, "rmr:destructionReport"); - fileReportParams.put(FileReportAction.DESTINATION, filePlan.toString()); + fileReportParams.put(DestructionReportAction.REPORT_TYPE, "rmr:destructionReport"); + fileReportParams.put(DestructionReportAction.DESTINATION, filePlan.toString()); rmActionService.executeRecordsManagementAction(rmFolder, "fileReport", fileReportParams); return null; }