本文整理汇总了Java中org.alfresco.repo.exporter.ACPExportPackageHandler类的典型用法代码示例。如果您正苦于以下问题:Java ACPExportPackageHandler类的具体用法?Java ACPExportPackageHandler怎么用?Java ACPExportPackageHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ACPExportPackageHandler类属于org.alfresco.repo.exporter包,在下文中一共展示了ACPExportPackageHandler类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSiteACPExport
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
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);
}
示例2: doPeopleACPExport
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
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);
}
}
示例3: doUserACPExport
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
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);
}
示例4: createACP
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
/**
* 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);
}
}
示例5: executeImpl
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
/**
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(Action, NodeRef)
*/
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
File zipFile = null;
try
{
String packageName = (String)ruleAction.getParameterValue(PARAM_PACKAGE_NAME);
File dataFile = new File(packageName);
File contentDir = new File(packageName);
// create a temporary file to hold the zip
zipFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, ACPExportPackageHandler.ACP_EXTENSION);
ACPExportPackageHandler zipHandler = new ACPExportPackageHandler(new FileOutputStream(zipFile),
dataFile, contentDir, mimetypeService);
ExporterCrawlerParameters params = new ExporterCrawlerParameters();
boolean includeChildren = true;
Boolean withKids = (Boolean)ruleAction.getParameterValue(PARAM_INCLUDE_CHILDREN);
if (withKids != null)
{
includeChildren = withKids.booleanValue();
}
params.setCrawlChildNodes(includeChildren);
boolean includeSelf = false;
Boolean andMe = (Boolean)ruleAction.getParameterValue(PARAM_INCLUDE_SELF);
if (andMe != null)
{
includeSelf = andMe.booleanValue();
}
params.setCrawlSelf(includeSelf);
params.setExportFrom(new Location(actionedUponNodeRef));
// perform the actual export
this.exporterService.exportView(zipHandler, params, null);
// now the export is done we need to create a node in the repository
// to hold the exported package
NodeRef zip = createExportZip(ruleAction, actionedUponNodeRef);
ContentWriter writer = this.contentService.getWriter(zip, ContentModel.PROP_CONTENT, true);
writer.setEncoding((String)ruleAction.getParameterValue(PARAM_ENCODING));
writer.setMimetype(MimetypeMap.MIMETYPE_ACP);
writer.putContent(zipFile);
}
catch (FileNotFoundException fnfe)
{
throw new ActionServiceException("export.package.error", fnfe);
}
finally
{
// try and delete the temporary file
if (zipFile != null)
{
zipFile.delete();
}
}
}
示例6: createExportZip
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
/**
* Creates the ZIP file node in the repository for the export
*
* @param ruleAction The rule being executed
* @return The NodeRef of the newly created ZIP file
*/
private NodeRef createExportZip(Action ruleAction, NodeRef actionedUponNodeRef)
{
// create a node in the repository to represent the export package
NodeRef exportDest = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
String packageName = (String)ruleAction.getParameterValue(PARAM_PACKAGE_NAME);
// add the default Alfresco content package extension if an extension hasn't been given
if (!packageName.endsWith("." + ACPExportPackageHandler.ACP_EXTENSION))
{
packageName += (packageName.charAt(packageName.length() -1) == '.') ? ACPExportPackageHandler.ACP_EXTENSION : "." + ACPExportPackageHandler.ACP_EXTENSION;
}
// set the name for the new node
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(1);
contentProps.put(ContentModel.PROP_NAME, packageName);
// create the node to represent the zip file
String assocName = QName.createValidLocalName(packageName);
ChildAssociationRef assocRef = this.nodeService.createNode(
exportDest, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, assocName),
ContentModel.TYPE_CONTENT, contentProps);
NodeRef zipNodeRef = assocRef.getChildRef();
// build a description string to be set on the node representing the content package
String desc = "";
String storeRef = (String)ruleAction.getParameterValue(PARAM_STORE);
NodeRef rootNode = this.nodeService.getRootNode(new StoreRef(storeRef));
if (rootNode.equals(actionedUponNodeRef))
{
desc = I18NUtil.getMessage("export.root.package.description");
}
else
{
String spaceName = (String)this.nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
String pattern = I18NUtil.getMessage("export.package.description");
if (pattern != null && spaceName != null)
{
desc = MessageFormat.format(pattern, spaceName);
}
}
// apply the titled aspect to behave in the web client
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, packageName);
titledProps.put(ContentModel.PROP_DESCRIPTION, desc);
this.nodeService.addAspect(zipNodeRef, ContentModel.ASPECT_TITLED, titledProps);
return zipNodeRef;
}
示例7: execute
import org.alfresco.repo.exporter.ACPExportPackageHandler; //导入依赖的package包/类
/**
* @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();
}
}
}