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