RM-781: RM Dependency update (update to HEAD QA build #165, Deleted overriding files, Bug fixes)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/UPDATE@52789 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-07-17 17:39:25 +00:00
parent 9f59392fd2
commit 9b838876c2
6 changed files with 136 additions and 77 deletions

View File

@@ -180,7 +180,6 @@
class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogPost" class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogPost"
parent="webscript"> parent="webscript">
<property name="nodeService" ref="nodeService" /> <property name="nodeService" ref="nodeService" />
<property name="contentService" ref="ContentService" />
<property name="permissionService" ref="PermissionService" /> <property name="permissionService" ref="PermissionService" />
<property name="mimetypeService" ref="mimetypeService" /> <property name="mimetypeService" ref="mimetypeService" />
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService" /> <property name="recordsManagementAuditService" ref="RecordsManagementAuditService" />
@@ -205,10 +204,10 @@
class="org.alfresco.module.org_alfresco_module_rm.script.ExportPost" class="org.alfresco.module.org_alfresco_module_rm.script.ExportPost"
parent="webscript"> parent="webscript">
<property name="nodeService" ref="nodeService" /> <property name="nodeService" ref="nodeService" />
<property name="contentService" ref="ContentService" />
<property name="permissionService" ref="PermissionService" /> <property name="permissionService" ref="PermissionService" />
<property name="mimetypeService" ref="mimetypeService" /> <property name="mimetypeService" ref="mimetypeService" />
<property name="exporterService" ref="ExporterService" /> <property name="exporterService" ref="ExporterService" />
<property name="contentStreamer" ref="webscript.content.streamer" />
</bean> </bean>
<!-- REST impl for POST import --> <!-- REST impl for POST import -->
@@ -226,7 +225,6 @@
<!-- Base bean for transfer web scripts --> <!-- Base bean for transfer web scripts -->
<bean id="rmBaseTransferWebscript" parent="webscript" abstract="true"> <bean id="rmBaseTransferWebscript" parent="webscript" abstract="true">
<property name="nodeService" ref="nodeService" /> <property name="nodeService" ref="nodeService" />
<property name="contentService" ref="ContentService" />
<property name="permissionService" ref="PermissionService" /> <property name="permissionService" ref="PermissionService" />
<property name="mimetypeService" ref="mimetypeService" /> <property name="mimetypeService" ref="mimetypeService" />
<property name="exporterService" ref="ExporterService" /> <property name="exporterService" ref="ExporterService" />
@@ -236,6 +234,7 @@
<bean id="webscript.org.alfresco.rma.transfer.get" <bean id="webscript.org.alfresco.rma.transfer.get"
class="org.alfresco.module.org_alfresco_module_rm.script.TransferGet" class="org.alfresco.module.org_alfresco_module_rm.script.TransferGet"
parent="rmBaseTransferWebscript"> parent="rmBaseTransferWebscript">
<property name="contentStreamer" ref="webscript.content.streamer" />
</bean> </bean>
<!-- REST impl for GET transfer report --> <!-- REST impl for GET transfer report -->
@@ -245,6 +244,7 @@
<property name="dictionaryService" ref="DictionaryService" /> <property name="dictionaryService" ref="DictionaryService" />
<property name="recordsManagementService" ref="RecordsManagementService" /> <property name="recordsManagementService" ref="RecordsManagementService" />
<property name="dispositionService" ref="DispositionService" /> <property name="dispositionService" ref="DispositionService" />
<property name="contentStreamer" ref="webscript.content.streamer" />
</bean> </bean>
<!-- REST impl for POST transfer report --> <!-- REST impl for POST transfer report -->
@@ -255,6 +255,7 @@
<property name="recordsManagementService" ref="RecordsManagementService" /> <property name="recordsManagementService" ref="RecordsManagementService" />
<property name="recordsManagementActionService" ref="RecordsManagementActionService" /> <property name="recordsManagementActionService" ref="RecordsManagementActionService" />
<property name="dispositionService" ref="DispositionService" /> <property name="dispositionService" ref="DispositionService" />
<property name="contentService" ref="ContentService"/>
</bean> </bean>
<!-- RM Role API--> <!-- RM Role API-->
@@ -513,7 +514,7 @@
<bean id="webscript.org.alfresco.repository.rule.rm-actionconditiondefinitions.get" <bean id="webscript.org.alfresco.repository.rule.rm-actionconditiondefinitions.get"
class="org.alfresco.repo.web.scripts.rule.RmActionConditionDefinitionsGet" class="org.alfresco.repo.web.scripts.rule.RmActionConditionDefinitionsGet"
parent="webscript"> parent="webscript">
<property name="actionService" ref="ActionService"/> <property name="actionService" ref="ActionService"/>
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/> <property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
</bean> </bean>
@@ -522,10 +523,10 @@
<!-- REST impl for GET Audit Log --> <!-- REST impl for GET Audit Log -->
<bean id="webscript.org.alfresco.rma.rmauditlog.get" class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogGet" parent="webscript"> <bean id="webscript.org.alfresco.rma.rmauditlog.get" class="org.alfresco.module.org_alfresco_module_rm.script.AuditLogGet" parent="webscript">
<property name="nodeService" ref="nodeService"/> <property name="nodeService" ref="nodeService"/>
<property name="contentService" ref="ContentService"/>
<property name="permissionService" ref="PermissionService"/> <property name="permissionService" ref="PermissionService"/>
<property name="mimetypeService" ref="mimetypeService"/> <property name="mimetypeService" ref="mimetypeService"/>
<property name="recordsManagementAuditService" ref="RecordsManagementAuditService"/> <property name="recordsManagementAuditService" ref="RecordsManagementAuditService"/>
<property name="contentStreamer" ref="webscript.content.streamer" />
</bean> </bean>
<!-- REST impl for GET Class Definitions for RM/DM --> <!-- REST impl for GET Class Definitions for RM/DM -->
@@ -558,6 +559,6 @@
<property name="filePlanService" ref="FilePlanService" /> <property name="filePlanService" ref="FilePlanService" />
<property name="filePlanRoleService" ref="FilePlanRoleService" /> <property name="filePlanRoleService" ref="FilePlanRoleService" />
<property name="authorityService" ref="AuthorityService" /> <property name="authorityService" ref="AuthorityService" />
</bean> </bean>
</beans> </beans>

View File

@@ -23,35 +23,47 @@ import java.io.IOException;
import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse; import org.springframework.extensions.webscripts.WebScriptResponse;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
/** /**
* Implementation for Java backed webscript to return audit * Implementation for Java backed webscript to return audit
* log of RM events, optionally scoped to an RM node. * log of RM events, optionally scoped to an RM node.
* *
* @author Gavin Cornwell * @author Gavin Cornwell
*/ */
public class AuditLogGet extends BaseAuditRetrievalWebScript public class AuditLogGet extends BaseAuditRetrievalWebScript
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(AuditLogGet.class); private static Log logger = LogFactory.getLog(AuditLogGet.class);
protected final static String PARAM_EXPORT = "export"; protected final static String PARAM_EXPORT = "export";
/** Content Streamer */
protected ContentStreamer contentStreamer;
/**
* @param contentStreamer
*/
public void setContentStreamer(ContentStreamer contentStreamer)
{
this.contentStreamer = contentStreamer;
}
@Override @Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{ {
File auditTrail = null; File auditTrail = null;
try try
{ {
// parse the parameters and get a file containing the audit trail // parse the parameters and get a file containing the audit trail
auditTrail = this.rmAuditService.getAuditTrailFile(parseQueryParameters(req), parseReportFormat(req)); auditTrail = this.rmAuditService.getAuditTrailFile(parseQueryParameters(req), parseReportFormat(req));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath()); logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath());
boolean attach = false; boolean attach = false;
String attachFileName = null; String attachFileName = null;
String export = req.getParameter(PARAM_EXPORT); String export = req.getParameter(PARAM_EXPORT);
@@ -59,13 +71,13 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
{ {
attach = true; attach = true;
attachFileName = auditTrail.getName(); attachFileName = auditTrail.getName();
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Exporting audit trail using file name: " + attachFileName); logger.debug("Exporting audit trail using file name: " + attachFileName);
} }
// stream the file back to the client // stream the file back to the client
streamContent(req, res, auditTrail, attach, attachFileName); contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null);
} }
finally finally
{ {

View File

@@ -28,6 +28,7 @@ import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; 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.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.repo.exporter.ACPExportPackageHandler; import org.alfresco.repo.exporter.ACPExportPackageHandler;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
import org.alfresco.repo.web.scripts.content.StreamACP; import org.alfresco.repo.web.scripts.content.StreamACP;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.view.ExporterCrawlerParameters; import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
@@ -46,7 +47,7 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
/** /**
* Creates an RM specific ACP file of nodes to export then streams it back * Creates an RM specific ACP file of nodes to export then streams it back
* to the client. * to the client.
* *
* @author Gavin Cornwell * @author Gavin Cornwell
*/ */
public class ExportPost extends StreamACP public class ExportPost extends StreamACP
@@ -55,7 +56,18 @@ public class ExportPost extends StreamACP
private static Log logger = LogFactory.getLog(ExportPost.class); private static Log logger = LogFactory.getLog(ExportPost.class);
protected static final String PARAM_TRANSFER_FORMAT = "transferFormat"; protected static final String PARAM_TRANSFER_FORMAT = "transferFormat";
/** Content Streamer */
private ContentStreamer contentStreamer;
/**
* @param contentStreamer
*/
public void setContentStreamer(ContentStreamer contentStreamer)
{
this.contentStreamer = contentStreamer;
}
/** /**
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/ */
@@ -73,7 +85,7 @@ public class ExportPost extends StreamACP
{ {
// get nodeRefs parameter from form // get nodeRefs parameter from form
nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS)); nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS));
// look for the transfer format // look for the transfer format
String transferFormatParam = req.getParameter(PARAM_TRANSFER_FORMAT); String transferFormatParam = req.getParameter(PARAM_TRANSFER_FORMAT);
if (transferFormatParam != null && transferFormatParam.length() > 0) if (transferFormatParam != null && transferFormatParam.length() > 0)
@@ -86,39 +98,39 @@ public class ExportPost extends StreamACP
// presume the request is a JSON request so get nodeRefs from JSON body // presume the request is a JSON request so get nodeRefs from JSON body
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
nodeRefs = getNodeRefs(json); nodeRefs = getNodeRefs(json);
if (json.has(PARAM_TRANSFER_FORMAT)) if (json.has(PARAM_TRANSFER_FORMAT))
{ {
transferFormat = json.getBoolean(PARAM_TRANSFER_FORMAT); transferFormat = json.getBoolean(PARAM_TRANSFER_FORMAT);
} }
} }
// setup the ACP parameters // setup the ACP parameters
ExporterCrawlerParameters params = new ExporterCrawlerParameters(); ExporterCrawlerParameters params = new ExporterCrawlerParameters();
params.setCrawlSelf(true); params.setCrawlSelf(true);
params.setCrawlChildNodes(true); params.setCrawlChildNodes(true);
params.setExportFrom(new Location(nodeRefs)); params.setExportFrom(new Location(nodeRefs));
// if transfer format has been requested we need to exclude certain aspects // if transfer format has been requested we need to exclude certain aspects
if (transferFormat) if (transferFormat)
{ {
// restrict specific aspects from being returned // restrict specific aspects from being returned
QName[] excludedAspects = new QName[] { QName[] excludedAspects = new QName[] {
RenditionModel.ASPECT_RENDITIONED, RenditionModel.ASPECT_RENDITIONED,
ContentModel.ASPECT_THUMBNAILED, ContentModel.ASPECT_THUMBNAILED,
RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE,
RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH}; RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH};
params.setExcludeAspects(excludedAspects); params.setExcludeAspects(excludedAspects);
} }
// create an ACP of the nodes // create an ACP of the nodes
tempACPFile = createACP(params, tempACPFile = createACP(params,
transferFormat ? ZIP_EXTENSION : ACPExportPackageHandler.ACP_EXTENSION, transferFormat ? ZIP_EXTENSION : ACPExportPackageHandler.ACP_EXTENSION,
transferFormat); transferFormat);
// stream the ACP back to the client as an attachment (forcing save as) // stream the ACP back to the client as an attachment (forcing save as)
streamContent(req, res, tempACPFile, true, tempACPFile.getName()); contentStreamer.streamContent(req, res, tempACPFile, null, true, tempACPFile.getName(), null);
} }
catch (IOException ioe) catch (IOException ioe)
{ {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, throw new WebScriptException(Status.STATUS_BAD_REQUEST,
@@ -147,7 +159,7 @@ public class ExportPost extends StreamACP
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath()); logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath());
tempACPFile.delete(); tempACPFile.delete();
} }
} }

View File

@@ -25,6 +25,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel; import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; 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.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.view.ExporterCrawlerParameters; import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
import org.alfresco.service.cmr.view.Location; import org.alfresco.service.cmr.view.Location;
@@ -39,23 +40,34 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
/** /**
* Streams the nodes of a transfer object to the client in the form of an * Streams the nodes of a transfer object to the client in the form of an
* ACP file. * ACP file.
* *
* @author Gavin Cornwell * @author Gavin Cornwell
*/ */
public class TransferGet extends BaseTransferWebScript public class TransferGet extends BaseTransferWebScript
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(TransferGet.class); private static Log logger = LogFactory.getLog(TransferGet.class);
/** Content Streamer */
private ContentStreamer contentStreamer;
/**
* @param contentStreamer
*/
public void setContentStreamer(ContentStreamer contentStreamer)
{
this.contentStreamer = contentStreamer;
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected File executeTransfer(NodeRef transferNode, protected File executeTransfer(NodeRef transferNode,
WebScriptRequest req, WebScriptResponse res, WebScriptRequest req, WebScriptResponse res,
Status status, Cache cache) throws IOException Status status, Cache cache) throws IOException
{ {
// get all 'transferred' nodes // get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode); NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
// setup the ACP parameters // setup the ACP parameters
ExporterCrawlerParameters params = new ExporterCrawlerParameters(); ExporterCrawlerParameters params = new ExporterCrawlerParameters();
params.setCrawlSelf(true); params.setCrawlSelf(true);
@@ -67,19 +79,19 @@ public class TransferGet extends BaseTransferWebScript
RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE,
RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH}; RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH};
params.setExcludeAspects(excludedAspects); params.setExcludeAspects(excludedAspects);
// create an archive of all the nodes to transfer // create an archive of all the nodes to transfer
File tempFile = createACP(params, ZIP_EXTENSION, true); File tempFile = createACP(params, ZIP_EXTENSION, true);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Creating transfer archive for " + itemsToTransfer.length + logger.debug("Creating transfer archive for " + itemsToTransfer.length +
" items into file: " + tempFile.getAbsolutePath()); " items into file: " + tempFile.getAbsolutePath());
} }
// stream the archive back to the client as an attachment (forcing save as) // stream the archive back to the client as an attachment (forcing save as)
streamContent(req, res, tempFile, true, tempFile.getName()); contentStreamer.streamContent(req, res, tempFile, null, true, tempFile.getName(), null);
// return the temp file for deletion // return the temp file for deletion
return tempFile; return tempFile;
} }

View File

@@ -31,6 +31,7 @@ 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.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -46,69 +47,78 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
/** /**
* Returns a JSON representation of a transfer report. * Returns a JSON representation of a transfer report.
* *
* @author Gavin Cornwell * @author Gavin Cornwell
*/ */
public class TransferReportGet extends BaseTransferWebScript public class TransferReportGet extends BaseTransferWebScript
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(TransferReportGet.class); private static Log logger = LogFactory.getLog(TransferReportGet.class);
protected static final String REPORT_FILE_PREFIX = "report_"; protected static final String REPORT_FILE_PREFIX = "report_";
protected static final String REPORT_FILE_SUFFIX = ".json"; protected static final String REPORT_FILE_SUFFIX = ".json";
protected DictionaryService ddService; protected DictionaryService ddService;
protected RecordsManagementService rmService; protected RecordsManagementService rmService;
protected DispositionService dispositionService; protected DispositionService dispositionService;
protected ContentStreamer contentStreamer;
/** /**
* Sets the DictionaryService instance * Sets the DictionaryService instance
* *
* @param ddService The DictionaryService instance * @param ddService The DictionaryService instance
*/ */
public void setDictionaryService(DictionaryService ddService) public void setDictionaryService(DictionaryService ddService)
{ {
this.ddService = ddService; this.ddService = ddService;
} }
/** /**
* Sets the disposition service * Sets the disposition service
* *
* @param dispositionService the disposition service * @param dispositionService the disposition service
*/ */
public void setDispositionService(DispositionService dispositionService) public void setDispositionService(DispositionService dispositionService)
{ {
this.dispositionService = dispositionService; this.dispositionService = dispositionService;
} }
/** /**
* Sets the RecordsManagementService instance * Sets the RecordsManagementService instance
* *
* @param rmService RecordsManagementService instance * @param rmService RecordsManagementService instance
*/ */
public void setRecordsManagementService(RecordsManagementService rmService) public void setRecordsManagementService(RecordsManagementService rmService)
{ {
this.rmService = rmService; this.rmService = rmService;
} }
/**
* @param contentStreamer
*/
public void setContentStreamer(ContentStreamer contentStreamer)
{
this.contentStreamer = contentStreamer;
}
@Override @Override
protected File executeTransfer(NodeRef transferNode, protected File executeTransfer(NodeRef transferNode,
WebScriptRequest req, WebScriptResponse res, WebScriptRequest req, WebScriptResponse res,
Status status, Cache cache) throws IOException Status status, Cache cache) throws IOException
{ {
// generate the report (will be in JSON format) // generate the report (will be in JSON format)
File report = generateJSONTransferReport(transferNode); File report = generateJSONTransferReport(transferNode);
// stream the report back to the client // stream the report back to the client
streamContent(req, res, report, false); contentStreamer.streamContent(req, res, report, null, false, null, null);
// return the file for deletion // return the file for deletion
return report; return report;
} }
/** /**
* Generates a File containing the JSON representation of a transfer report. * Generates a File containing the JSON representation of a transfer report.
* *
* @param transferNode The transfer node * @param transferNode The transfer node
* @return File containing JSON representation of a transfer report * @return File containing JSON representation of a transfer report
* @throws IOException * @throws IOException
@@ -121,16 +131,16 @@ public class TransferReportGet extends BaseTransferWebScript
{ {
// get all 'transferred' nodes // get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode); NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Generating JSON transfer report for " + itemsToTransfer.length + logger.debug("Generating JSON transfer report for " + itemsToTransfer.length +
" items into file: " + report.getAbsolutePath()); " items into file: " + report.getAbsolutePath());
} }
// create the writer // create the writer
writer = new FileWriter(report); writer = new FileWriter(report);
// use RMService to get disposition authority // use RMService to get disposition authority
String dispositionAuthority = null; String dispositionAuthority = null;
if (itemsToTransfer.length > 0) if (itemsToTransfer.length > 0)
@@ -142,7 +152,7 @@ public class TransferReportGet extends BaseTransferWebScript
dispositionAuthority = ds.getDispositionAuthority(); dispositionAuthority = ds.getDispositionAuthority();
} }
} }
// write the JSON header // write the JSON header
writer.write("{\n\t\"data\":\n\t{"); writer.write("{\n\t\"data\":\n\t{");
writer.write("\n\t\t\"transferDate\": \""); writer.write("\n\t\t\"transferDate\": \"");
@@ -153,10 +163,10 @@ public class TransferReportGet extends BaseTransferWebScript
writer.write("\",\n\t\t\"dispositionAuthority\": \""); writer.write("\",\n\t\t\"dispositionAuthority\": \"");
writer.write(dispositionAuthority != null ? dispositionAuthority : ""); writer.write(dispositionAuthority != null ? dispositionAuthority : "");
writer.write("\",\n\t\t\"items\":\n\t\t["); writer.write("\",\n\t\t\"items\":\n\t\t[");
// write out JSON representation of items to transfer // write out JSON representation of items to transfer
generateTransferItemsJSON(writer, itemsToTransfer); generateTransferItemsJSON(writer, itemsToTransfer);
// write the JSON footer // write the JSON footer
writer.write("\n\t\t]\n\t}\n}"); writer.write("\n\t\t]\n\t}\n}");
} }
@@ -167,13 +177,13 @@ public class TransferReportGet extends BaseTransferWebScript
try { writer.close(); } catch (IOException ioe) {} try { writer.close(); } catch (IOException ioe) {}
} }
} }
return report; return report;
} }
/** /**
* Generates the JSON to represent the given NodeRefs * Generates the JSON to represent the given NodeRefs
* *
* @param writer Writer to write to * @param writer Writer to write to
* @param itemsToTransfer NodeRefs being transferred * @param itemsToTransfer NodeRefs being transferred
* @throws IOException * @throws IOException
@@ -192,7 +202,7 @@ public class TransferReportGet extends BaseTransferWebScript
{ {
writer.write(","); writer.write(",");
} }
if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER)) if (ddService.isSubClass(nodeService.getType(item), ContentModel.TYPE_FOLDER))
{ {
generateTransferFolderJSON(writer, item); generateTransferFolderJSON(writer, item);
@@ -203,10 +213,10 @@ public class TransferReportGet extends BaseTransferWebScript
} }
} }
} }
/** /**
* Generates the JSON to represent the given folder. * Generates the JSON to represent the given folder.
* *
* @param writer Writer to write to * @param writer Writer to write to
* @param folderNode Folder being transferred * @param folderNode Folder being transferred
* @throws IOException * @throws IOException
@@ -215,7 +225,7 @@ public class TransferReportGet extends BaseTransferWebScript
throws IOException throws IOException
{ {
// TODO: Add identation // TODO: Add identation
writer.write("\n{\n\"type\":\"folder\",\n"); writer.write("\n{\n\"type\":\"folder\",\n");
writer.write("\"name\":\""); writer.write("\"name\":\"");
writer.write((String)nodeService.getProperty(folderNode, ContentModel.PROP_NAME)); writer.write((String)nodeService.getProperty(folderNode, ContentModel.PROP_NAME));
@@ -224,9 +234,9 @@ public class TransferReportGet extends BaseTransferWebScript
writer.write("\",\n\"id\":\""); writer.write("\",\n\"id\":\"");
writer.write((String)nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER)); writer.write((String)nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER));
writer.write("\",\n\"children\":\n["); writer.write("\",\n\"children\":\n[");
boolean first = true; boolean first = true;
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(folderNode, List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(folderNode,
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef child : assocs) for (ChildAssociationRef child : assocs)
{ {
@@ -238,7 +248,7 @@ public class TransferReportGet extends BaseTransferWebScript
{ {
writer.write(","); writer.write(",");
} }
NodeRef childRef = child.getChildRef(); NodeRef childRef = child.getChildRef();
if (ddService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER)) if (ddService.isSubClass(nodeService.getType(childRef), ContentModel.TYPE_FOLDER))
{ {
@@ -249,13 +259,13 @@ public class TransferReportGet extends BaseTransferWebScript
generateTransferRecordJSON(writer, childRef); generateTransferRecordJSON(writer, childRef);
} }
} }
writer.write("\n]\n}"); writer.write("\n]\n}");
} }
/** /**
* Generates the JSON to represent the given record. * Generates the JSON to represent the given record.
* *
* @param writer Writer to write to * @param writer Writer to write to
* @param recordNode Record being transferred * @param recordNode Record being transferred
* @throws IOException * @throws IOException
@@ -271,7 +281,7 @@ public class TransferReportGet extends BaseTransferWebScript
writer.write("\",\n\"id\":\""); writer.write("\",\n\"id\":\"");
writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER)); writer.write((String)nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER));
writer.write("\""); writer.write("\"");
if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD)) if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD))
{ {
writer.write(",\n\"declaredBy\":\""); writer.write(",\n\"declaredBy\":\"");
@@ -281,7 +291,7 @@ public class TransferReportGet extends BaseTransferWebScript
(Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT))); (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT)));
writer.write("\""); writer.write("\"");
} }
writer.write("\n}"); writer.write("\n}");
} }
} }

View File

@@ -39,6 +39,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
@@ -78,6 +79,7 @@ public class TransferReportPost extends BaseTransferWebScript
protected RecordsManagementActionService rmActionService; protected RecordsManagementActionService rmActionService;
protected RecordsManagementService rmService; protected RecordsManagementService rmService;
protected DispositionService dispositionService; protected DispositionService dispositionService;
protected ContentService contentService;
/** /**
* Sets the DictionaryService instance * Sets the DictionaryService instance
@@ -119,6 +121,16 @@ public class TransferReportPost extends BaseTransferWebScript
this.rmActionService = rmActionService; this.rmActionService = rmActionService;
} }
/**
* Sets the ContentSerivce instance
*
* @param contentService ContentService instance
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
@Override @Override
protected File executeTransfer(NodeRef transferNode, protected File executeTransfer(NodeRef transferNode,
WebScriptRequest req, WebScriptResponse res, WebScriptRequest req, WebScriptResponse res,
@@ -436,10 +448,10 @@ public class TransferReportPost extends BaseTransferWebScript
ContentModel.TYPE_CONTENT, properties).getChildRef(); ContentModel.TYPE_CONTENT, properties).getChildRef();
// Set the content // Set the content
ContentWriter writer = this.contentService.getWriter(record, ContentModel.PROP_CONTENT, true); ContentWriter writer = contentService.getWriter(record, ContentModel.PROP_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_HTML); writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
writer.setEncoding("UTF-8"); writer.setEncoding("UTF-8");
writer.putContent(report); writer.putContent(report);
return record; return record;
} }