当前位置: 首页>>代码示例>>Java>>正文


Java XMLUtil.print方法代码示例

本文整理汇总了Java中org.alfresco.util.XMLUtil.print方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUtil.print方法的具体用法?Java XMLUtil.print怎么用?Java XMLUtil.print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.util.XMLUtil的用法示例。


在下文中一共展示了XMLUtil.print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExtensionModule

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
protected String getExtensionModule(InputStream inputStream, String fileName)
{
    Element rootElement = null;
    try
    {
        final DocumentBuilder db = XMLUtil.getDocumentBuilder();
        rootElement = db.parse(inputStream).getDocumentElement();
    }
    catch (IOException io)
    {
        throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "cmm.rest_api.model.import_process_ext_module_file_failure", io);
    }
    catch (SAXException ex)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "cmm.rest_api.model.import_invalid_ext_module_entry", new Object[] { fileName }, ex);
    }

    if (rootElement != null && SHARE_EXT_MODULE_ROOT_ELEMENT.equals(rootElement.getNodeName()))
    {
        StringWriter sw = new StringWriter();
        XMLUtil.print(rootElement, sw, false);

        return sw.toString();
    }

    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:CustomModelUploadPost.java

示例2: createCustomModelShareExtModuleRef

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
/**
 * Finds the {@code module} element within the Share persisted-extension
 * XML file and then writes the XML fragment as the content of a newly created node.
 *
 * @param modelName the model name
 * @return the created nodeRef
 */
protected NodeRef createCustomModelShareExtModuleRef(final String modelName)
{
    final String moduleId = "CMM_" + modelName;

    final NodeRef formNodeRef = getShareExtModule();
    ContentReader reader = contentService.getReader(formNodeRef, ContentModel.PROP_CONTENT);

    if (reader == null)
    {
        throw new CustomModelException("cmm.service.download.share_ext_node_read_err");
    }

    InputStream in = reader.getContentInputStream();
    Node moduleIdXmlNode = null;
    try
    {
        Document document = XMLUtil.parse(in); // the stream will be closed

        final String xpathQuery = "/extension//modules//module//id[.= '" + moduleId + "']";

        XPath xPath = XPathFactory.newInstance().newXPath();
        XPathExpression expression = xPath.compile(xpathQuery);

        moduleIdXmlNode = (Node) expression.evaluate(document, XPathConstants.NODE);
    }
    catch (Exception ex)
    {
        throw new CustomModelException("cmm.service.download.share_ext_file_parse_err", ex);
    }

    if (moduleIdXmlNode == null)
    {
        throw new CustomModelException("cmm.service.download.share_ext_module_not_found", new Object[] { moduleId });
    }

    final File moduleFile = TempFileProvider.createTempFile(moduleId, ".xml");
    try
    {
        XMLUtil.print(moduleIdXmlNode.getParentNode(), moduleFile);
    }
    catch (IOException error)
    {
        throw new CustomModelException("cmm.service.download.share_ext_write_err", new Object[] { moduleId }, error);
    }

    return doInTransaction(MSG_DOWNLOAD_CREATE_SHARE_EXT_ERR, true, new RetryingTransactionCallback<NodeRef>()
    {
        @Override
        public NodeRef execute() throws Exception
        {
            final NodeRef nodeRef = createDownloadTypeNode(moduleId + SHARE_EXT_MODULE_SUFFIX);
            ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
            writer.setMimetype(MimetypeMap.MIMETYPE_XML);
            writer.setEncoding("UTF-8");
            writer.putContent(moduleFile);

            return nodeRef;
        }
    });
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:68,代码来源:CustomModelServiceImpl.java


注:本文中的org.alfresco.util.XMLUtil.print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。