當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。