本文整理汇总了Java中org.alfresco.util.XMLUtil类的典型用法代码示例。如果您正苦于以下问题:Java XMLUtil类的具体用法?Java XMLUtil怎么用?Java XMLUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLUtil类属于org.alfresco.util包,在下文中一共展示了XMLUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimplestStringTemplate
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testSimplestStringTemplate() throws Exception
{
try
{
FileInfo file = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(file.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.processString(verySimpleXSLT, model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例2: testSimplestNodeTemplate
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testSimplestNodeTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process(xslFile.getNodeRef().toString(), model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例3: testLocalisedNodeTemplate
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testLocalisedNodeTemplate() throws Exception
{
// This should have the same result as testSimplestNodeTemplate as the localization should be ignored for node templates.
try
{
FileInfo xmlFile = createXmlFile(companyHome);
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process(xslFile.getNodeRef().toString(), model, writer, Locale.FRANCE);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例4: testSimplestClasspathTemplate
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testSimplestClasspathTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例5: testTemplateServiceBinding
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testTemplateServiceBinding() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
templateService.processTemplate("xslt", "org/alfresco/repo/template/test_template1.xsl", model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例6: 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());
}
示例7: 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());
}
示例8: 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);
}
示例9: 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;
}
示例10: 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;
}
示例11: testLocalisedClasspathTemplate
import org.alfresco.util.XMLUtil; //导入依赖的package包/类
public void testLocalisedClasspathTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("en", "AU"));
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("G'day, Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("en", "GB"));
output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("fr", "FR"));
output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Bonjour, Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例12: 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;
}
});
}