Search in sources :

Example 1 with ACPExportPackageHandler

use of org.alfresco.repo.exporter.ACPExportPackageHandler 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);
}
Also used : ACPExportPackageHandler(org.alfresco.repo.exporter.ACPExportPackageHandler) ExporterCrawlerParameters(org.alfresco.service.cmr.view.ExporterCrawlerParameters) File(java.io.File) Location(org.alfresco.service.cmr.view.Location)

Example 2 with ACPExportPackageHandler

use of org.alfresco.repo.exporter.ACPExportPackageHandler 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);
}
Also used : ACPExportPackageHandler(org.alfresco.repo.exporter.ACPExportPackageHandler) ExporterCrawlerParameters(org.alfresco.service.cmr.view.ExporterCrawlerParameters) File(java.io.File) Location(org.alfresco.service.cmr.view.Location)

Example 3 with ACPExportPackageHandler

use of org.alfresco.repo.exporter.ACPExportPackageHandler in project alfresco-remote-api by Alfresco.

the class StreamACP method createACP.

/**
 * Returns an ACP file containing the nodes represented by the given list of NodeRefs.
 *
 * @param params The parameters for the ACP exporter
 * @param extension The file extenstion to use for the ACP file
 * @param keepFolderStructure Determines whether the folder structure is maintained for
 *        the content inside the ACP file
 * @return File object representing the created ACP
 */
protected File createACP(ExporterCrawlerParameters params, String extension, boolean keepFolderStructure) {
    try {
        // generate temp file and folder name
        File dataFile = new File(GUID.generate());
        File contentDir = new File(GUID.generate());
        // setup export package handler
        File acpFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, "." + extension);
        ACPExportPackageHandler handler = new ACPExportPackageHandler(new FileOutputStream(acpFile), dataFile, contentDir, this.mimetypeService);
        handler.setExportAsFolders(keepFolderStructure);
        handler.setNodeService(this.nodeService);
        // perform the actual export
        this.exporterService.exportView(handler, params, null);
        if (logger.isDebugEnabled())
            logger.debug("Created temporary archive: " + acpFile.getAbsolutePath());
        return acpFile;
    } catch (FileNotFoundException fnfe) {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to create archive", fnfe);
    }
}
Also used : WebScriptException(org.springframework.extensions.webscripts.WebScriptException) ACPExportPackageHandler(org.alfresco.repo.exporter.ACPExportPackageHandler) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Example 4 with ACPExportPackageHandler

use of org.alfresco.repo.exporter.ACPExportPackageHandler in project alfresco-remote-api by Alfresco.

the class SiteExportGet method doPeopleACPExport.

protected void doPeopleACPExport(final List<NodeRef> peopleNodes, SiteInfo site, CloseIgnoringOutputStream writeTo) throws IOException {
    if (!peopleNodes.isEmpty()) {
        // Build the parameters
        ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
        parameters.setExportFrom(new Location(peopleNodes.toArray(new NodeRef[peopleNodes.size()])));
        parameters.setCrawlChildNodes(true);
        parameters.setCrawlSelf(true);
        parameters.setCrawlContent(true);
        // And the export handler
        ACPExportPackageHandler handler = new ACPExportPackageHandler(writeTo, new File(site.getShortName() + "-people.xml"), new File(site.getShortName() + "-people"), mimetypeService);
        // Do the export
        exporterService.exportView(handler, parameters, null);
    }
}
Also used : ACPExportPackageHandler(org.alfresco.repo.exporter.ACPExportPackageHandler) ExporterCrawlerParameters(org.alfresco.service.cmr.view.ExporterCrawlerParameters) File(java.io.File) Location(org.alfresco.service.cmr.view.Location)

Aggregations

File (java.io.File)4 ACPExportPackageHandler (org.alfresco.repo.exporter.ACPExportPackageHandler)4 ExporterCrawlerParameters (org.alfresco.service.cmr.view.ExporterCrawlerParameters)3 Location (org.alfresco.service.cmr.view.Location)3 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1