use of org.alfresco.service.cmr.view.ExporterCrawlerParameters in project alfresco-remote-api by Alfresco.
the class SiteExportGet method doUserACPExport.
protected void doUserACPExport(List<NodeRef> userNodes, SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException {
// Build the parameters
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
parameters.setExportFrom(new Location(userNodes.toArray(new NodeRef[userNodes.size()])));
parameters.setCrawlChildNodes(true);
parameters.setCrawlSelf(true);
parameters.setCrawlContent(true);
// And the export handler
ACPExportPackageHandler handler = new ACPExportPackageHandler(writeTo, new File(site.getShortName() + "-users.xml"), new File(site.getShortName() + "-users"), mimetypeService);
// Do the export
exporterService.exportView(handler, parameters, null);
}
use of org.alfresco.service.cmr.view.ExporterCrawlerParameters in project alfresco-remote-api by Alfresco.
the class SiteExportGet method doSiteACPExport.
protected void doSiteACPExport(SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException {
// Build the parameters
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
parameters.setExportFrom(new Location(site.getNodeRef()));
parameters.setCrawlChildNodes(true);
parameters.setCrawlSelf(true);
parameters.setCrawlContent(true);
// And the export handler
ACPExportPackageHandler handler = new ACPExportPackageHandler(writeTo, new File(site.getShortName() + ".xml"), new File(site.getShortName()), mimetypeService);
// Do the export
exporterService.exportView(handler, parameters, null);
}
use of org.alfresco.service.cmr.view.ExporterCrawlerParameters in project alfresco-remote-api by Alfresco.
the class StreamACP method execute.
/**
* @see org.springframework.extensions.webscripts.WebScript#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse)
*/
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
File tempACPFile = null;
try {
NodeRef[] nodeRefs = null;
String contentType = req.getContentType();
if (MULTIPART_FORMDATA.equals(contentType)) {
// get nodeRefs parameter from form
nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS));
} else {
// presume the request is a JSON request so get nodeRefs from JSON body
nodeRefs = getNodeRefs(new JSONObject(new JSONTokener(req.getContent().getContent())));
}
// setup the ACP parameters
ExporterCrawlerParameters params = new ExporterCrawlerParameters();
params.setCrawlSelf(true);
params.setCrawlChildNodes(true);
params.setExportFrom(new Location(nodeRefs));
// create an ACP of the nodes
tempACPFile = createACP(params, ACPExportPackageHandler.ACP_EXTENSION, false);
// stream the ACP back to the client as an attachment (forcing save as)
streamContent(req, res, tempACPFile, true, tempACPFile.getName(), null);
} catch (IOException ioe) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", ioe);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
} finally {
// try and delete the temporary file
if (tempACPFile != null) {
if (logger.isDebugEnabled())
logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath());
tempACPFile.delete();
}
}
}
use of org.alfresco.service.cmr.view.ExporterCrawlerParameters in project records-management by Alfresco.
the class ExportPost method execute.
/**
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
@SuppressWarnings("deprecation")
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
File tempACPFile = null;
try {
NodeRef[] nodeRefs = null;
boolean transferFormat = false;
String contentType = req.getContentType();
if (MULTIPART_FORMDATA.equals(contentType)) {
// get nodeRefs parameter from form
nodeRefs = getNodeRefs(req.getParameter(PARAM_NODE_REFS));
// look for the transfer format
String transferFormatParam = req.getParameter(PARAM_TRANSFER_FORMAT);
if (transferFormatParam != null && transferFormatParam.length() > 0) {
transferFormat = Boolean.parseBoolean(transferFormatParam);
}
} else {
// presume the request is a JSON request so get nodeRefs from JSON body
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
nodeRefs = getNodeRefs(json);
if (json.has(PARAM_TRANSFER_FORMAT)) {
transferFormat = json.getBoolean(PARAM_TRANSFER_FORMAT);
}
}
// setup the ACP parameters
ExporterCrawlerParameters params = new ExporterCrawlerParameters();
params.setCrawlSelf(true);
params.setCrawlChildNodes(true);
params.setExportFrom(new Location(nodeRefs));
// if transfer format has been requested we need to exclude certain aspects
if (transferFormat) {
// restrict specific aspects from being returned
QName[] excludedAspects = new QName[] { RenditionModel.ASPECT_RENDITIONED, ContentModel.ASPECT_THUMBNAILED, RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH, RecordsManagementModel.ASPECT_EXTENDED_SECURITY };
params.setExcludeAspects(excludedAspects);
} else {
// restrict specific aspects from being returned
QName[] excludedAspects = new QName[] { RecordsManagementModel.ASPECT_EXTENDED_SECURITY };
params.setExcludeAspects(excludedAspects);
}
// create an ACP of the nodes
tempACPFile = createACP(params, transferFormat ? ZIP_EXTENSION : ACPExportPackageHandler.ACP_EXTENSION, transferFormat);
// stream the ACP back to the client as an attachment (forcing save as)
contentStreamer.streamContent(req, res, tempACPFile, null, true, tempACPFile.getName(), null);
} catch (IOException ioe) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", ioe);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
StringWriter stack = new StringWriter();
e.printStackTrace(new PrintWriter(stack));
logger.debug("Caught exception; decorating with appropriate status template : " + stack.toString());
}
throw createStatusException(e, req, res);
} finally {
// try and delete the temporary file
if (tempACPFile != null) {
if (logger.isDebugEnabled()) {
logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath());
}
tempACPFile.delete();
}
}
}
use of org.alfresco.service.cmr.view.ExporterCrawlerParameters in project records-management by Alfresco.
the class TransferGet method executeTransfer.
@Override
protected File executeTransfer(NodeRef transferNode, WebScriptRequest req, WebScriptResponse res, Status status, Cache cache) throws IOException {
// get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
// setup the ACP parameters
ExporterCrawlerParameters params = new ExporterCrawlerParameters();
params.setCrawlSelf(true);
params.setCrawlChildNodes(true);
params.setExportFrom(new Location(itemsToTransfer));
QName[] excludedAspects = new QName[] { RenditionModel.ASPECT_RENDITIONED, ContentModel.ASPECT_THUMBNAILED, RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE, RecordsManagementSearchBehaviour.ASPECT_RM_SEARCH };
params.setExcludeAspects(excludedAspects);
// create an archive of all the nodes to transfer
File tempFile = createACP(params, ZIP_EXTENSION, true);
if (logger.isDebugEnabled()) {
logger.debug("Creating transfer archive for " + itemsToTransfer.length + " items into file: " + tempFile.getAbsolutePath());
}
// stream the archive back to the client as an attachment (forcing save as)
contentStreamer.streamContent(req, res, tempFile, null, true, tempFile.getName(), null);
// return the temp file for deletion
return tempFile;
}
Aggregations