本文整理汇总了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());
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
});
}