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


Java XMLUtil.parse方法代码示例

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


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

示例1: testValidUpload_ModelAndExtModule

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
public void testValidUpload_ModelAndExtModule() throws Exception
{
    File zipFile = getResourceFile("validModelAndExtModule.zip");
    PostRequest postRequest = buildMultipartPostRequest(zipFile);

    AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER);
    Response response = sendRequest(postRequest, 403);

    AuthenticationUtil.setFullyAuthenticatedUser(CUSTOM_MODEL_ADMIN);
    response = sendRequest(postRequest, 200);

    JSONObject json = new JSONObject(new JSONTokener(response.getContentAsString()));

    String importedModelName = json.getString("modelName");
    importedModels.add(importedModelName);

    String extModule = json.getString("shareExtModule");
    Document document = XMLUtil.parse(extModule);
    NodeList nodes = document.getElementsByTagName("id");
    assertEquals(1, nodes.getLength());
    assertNotNull(nodes.item(0).getTextContent());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:CustomModelImportTest.java

示例2: testValidUpload_ExtModuleOnly

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
public void testValidUpload_ExtModuleOnly() throws Exception
{
    File zipFile = getResourceFile("validExtModule.zip");
    PostRequest postRequest = buildMultipartPostRequest(zipFile);

    AuthenticationUtil.setFullyAuthenticatedUser(NON_ADMIN_USER);
    Response response = sendRequest(postRequest, 403);

    AuthenticationUtil.setFullyAuthenticatedUser(CUSTOM_MODEL_ADMIN);
    response = sendRequest(postRequest, 200);

    JSONObject json = new JSONObject(new JSONTokener(response.getContentAsString()));
    assertFalse(json.has("modelName"));

    String extModule = json.getString("shareExtModule");
    Document document = XMLUtil.parse(extModule);
    NodeList nodes = document.getElementsByTagName("id");
    assertEquals(1, nodes.getLength());
    assertNotNull(nodes.item(0).getTextContent());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:CustomModelImportTest.java

示例3: parseXMLDocument

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
public Document parseXMLDocument(final NodeRef root, String repoPath) throws IOException, SAXException,
        FileNotFoundException
{
    String[] pathElements = breakDownPath(repoPath);
    FileInfo file = fileService.resolveNamePath(root, Arrays.asList(pathElements));
    return XMLUtil.parse(file.getNodeRef(), contentService);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:XSLTFunctions.java

示例4: parseXMLDocuments

import org.alfresco.util.XMLUtil; //导入方法依赖的package包/类
public Map<String, Document> parseXMLDocuments(final String typeName, NodeRef rootNode, String repoPath)
        throws IOException, SAXException
{
    final Map<String, Document> result = new TreeMap<String, Document>();

    String[] pathElements = breakDownPath(repoPath);

    try
    {
        FileInfo file = fileService.resolveNamePath(rootNode, Arrays.asList(pathElements));

        if (file.isFolder())
        {
            QName typeQName = QName.createQName(typeName, namespaceService);
            Set<QName> types = new HashSet<QName>(dictionaryService.getSubTypes(typeQName, true));
            types.add(typeQName);
            List<ChildAssociationRef> children = nodeService.getChildAssocs(file.getNodeRef(), types);
            for (ChildAssociationRef child : children)
            {
                String name = (String) nodeService.getProperty(child.getChildRef(), ContentModel.PROP_NAME);
                Document doc = XMLUtil.parse(child.getChildRef(), contentService);
                result.put(name, doc);
            }
        }
    }
    catch (Exception ex)
    {
        log.warn("Unexpected exception caught in call to parseXMLDocuments", ex);
    }
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:XSLTFunctions.java

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