本文整理汇总了Java中org.ofbiz.base.util.UtilXml.readXmlDocument方法的典型用法代码示例。如果您正苦于以下问题:Java UtilXml.readXmlDocument方法的具体用法?Java UtilXml.readXmlDocument怎么用?Java UtilXml.readXmlDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.base.util.UtilXml
的用法示例。
在下文中一共展示了UtilXml.readXmlDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMenuFromLocationOrNull
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
/**
* SCIPIO: Gets widget from location or null if name not within the location.
*/
public static ModelMenu getMenuFromLocationOrNull(String resourceName, String menuName) throws IOException, SAXException, ParserConfigurationException {
Map<String, ModelMenu> modelMenuMap = menuLocationCache.get(resourceName);
if (modelMenuMap == null) {
synchronized (MenuFactory.class) {
modelMenuMap = menuLocationCache.get(resourceName);
if (modelMenuMap == null) {
URL menuFileUrl = FlexibleLocation.resolveLocation(resourceName);
Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true, true);
// SCIPIO: New: Save original location as user data in Document
if (menuFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(menuFileDoc).setResourceLocation(resourceName);
}
modelMenuMap = readMenuDocument(menuFileDoc, resourceName);
menuLocationCache.put(resourceName, modelMenuMap);
}
}
}
if (UtilValidate.isEmpty(modelMenuMap)) {
throw new IllegalArgumentException("Could not find menu file in location [" + resourceName + "]");
}
ModelMenu modelMenu = modelMenuMap.get(menuName);
return modelMenu;
}
示例2: readXmlDocument
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Document readXmlDocument(String str) {
Document document = null;
try {
URL url = FlexibleLocation.resolveLocation(str);
if (url != null) {
InputStream is = url.openStream();
document = UtilXml.readXmlDocument(is, str);
is.close();
} else {
Debug.logError("Unable to locate XML document " + str, module);
}
} catch (Exception e) {
Debug.logError(e, "Error while reading XML document " + str, module);
}
return document;
}
示例3: getDocument
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private Document getDocument(URL url) {
if (url == null)
return null;
Document document = null;
try {
document = UtilXml.readXmlDocument(url, true, true);
} catch (SAXException sxe) {
// Error generated during parsing)
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return document;
}
示例4: getGridFromWebappContext
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static ModelGrid getGridFromWebappContext(String resourceName, String gridName, HttpServletRequest request)
throws IOException, SAXException, ParserConfigurationException {
String webappName = UtilHttp.getApplicationName(request);
String cacheKey = webappName + "::" + resourceName + "::" + gridName;
ModelGrid modelGrid = gridWebappCache.get(cacheKey);
if (modelGrid == null) {
ServletContext servletContext = (ServletContext) request.getAttribute("servletContext");
Delegator delegator = (Delegator) request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
URL gridFileUrl = servletContext.getResource(resourceName);
Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true);
// SCIPIO: New: Save original location as user data in Document
if (gridFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(gridFileDoc).setResourceLocation(resourceName);
}
Element gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "grid", "name", gridName);
modelGrid = createModelGrid(gridElement, delegator.getModelReader(), dispatcher.getDispatchContext(), resourceName, gridName);
modelGrid = gridWebappCache.putIfAbsentAndGet(cacheKey, modelGrid);
}
if (modelGrid == null) {
throw new IllegalArgumentException("Could not find grid with name [" + gridName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]");
}
return modelGrid;
}
示例5: getFormFromLocationOrNull
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
/**
* SCIPIO: Gets widget from location or null if name not within the location.
*/
public static ModelForm getFormFromLocationOrNull(String resourceName, String formName, ModelReader entityModelReader, DispatchContext dispatchContext)
throws IOException, SAXException, ParserConfigurationException {
StringBuilder sb = new StringBuilder(dispatchContext.getDelegator().getDelegatorName());
sb.append(":").append(resourceName).append("#").append(formName);
String cacheKey = sb.toString();
ModelForm modelForm = formLocationCache.get(cacheKey);
if (modelForm == null) {
URL formFileUrl = FlexibleLocation.resolveLocation(resourceName);
Document formFileDoc = UtilXml.readXmlDocument(formFileUrl, true, true);
if (formFileDoc == null) {
throw new IllegalArgumentException("Could not find resource [" + resourceName + "]");
}
// SCIPIO: New: Save original location as user data in Document
if (formFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(formFileDoc).setResourceLocation(resourceName);
}
modelForm = createModelForm(formFileDoc, entityModelReader, dispatchContext, resourceName, formName);
modelForm = formLocationCache.putIfAbsentAndGet(cacheKey, modelForm);
}
return modelForm;
}
示例6: getGridFromLocationOrNull
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
/**
* SCIPIO: Gets widget from location or null if name not within the location.
*/
public static ModelGrid getGridFromLocationOrNull(String resourceName, String gridName, ModelReader entityModelReader, DispatchContext dispatchContext)
throws IOException, SAXException, ParserConfigurationException {
StringBuilder sb = new StringBuilder(dispatchContext.getDelegator().getDelegatorName());
sb.append(":").append(resourceName).append("#").append(gridName);
String cacheKey = sb.toString();
ModelGrid modelGrid = gridLocationCache.get(cacheKey);
if (modelGrid == null) {
URL gridFileUrl = FlexibleLocation.resolveLocation(resourceName);
Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true);
if (gridFileDoc == null) {
throw new IllegalArgumentException("Could not find resource [" + resourceName + "]");
}
// SCIPIO: New: Save original location as user data in Document
if (gridFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(gridFileDoc).setResourceLocation(resourceName);
}
modelGrid = createModelGrid(gridFileDoc, entityModelReader, dispatchContext, resourceName, gridName);
modelGrid = gridLocationCache.putIfAbsentAndGet(cacheKey, modelGrid);
}
return modelGrid;
}
示例7: deserialize
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
/** Deserialize a Java object from an XML string. <p>This method should be used with caution.
* If the XML string contains a serialized <code>GenericValue</code> or <code>GenericPK</code>
* then it is possible to unintentionally corrupt the database.</p>
*
* @param content the content
* @param delegator the delegator
* @return return a deserialized object from XML string
* @throws SerializeException
* @throws SAXException
* @throws ParserConfigurationException
* @throws IOException
*/
public static Object deserialize(String content, Delegator delegator)
throws SerializeException, SAXException, ParserConfigurationException, IOException {
// readXmlDocument with false second parameter to disable validation
Document document = UtilXml.readXmlDocument(content, false);
if (document != null) {
if (!"ofbiz-ser".equals(document.getDocumentElement().getTagName())) {
return UtilXml.fromXml(content);
}
return deserialize(document, delegator);
} else {
Debug.logWarning("Serialized document came back null", module);
return null;
}
}
示例8: getDocumentFromRequest
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Document getDocumentFromRequest(HttpServletRequest request) throws IOException, SAXException, ParserConfigurationException {
Document document = null;
InputStream is = null;
try {
is = request.getInputStream();
document = UtilXml.readXmlDocument(is, false, "WebDAV request");
} finally {
if (is != null) {
is.close();
}
}
return document;
}
示例9: getAllDirectSimpleMethods
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Map<String, SimpleMethod> getAllDirectSimpleMethods(String name, String content, String fromLocation) throws MiniLangException {
if (UtilValidate.isEmpty(fromLocation)) {
fromLocation = "<location not known>";
}
Map<String, SimpleMethod> simpleMethods = new HashMap<String, SimpleMethod>();
Document document = null;
try {
document = UtilXml.readXmlDocument(content, true, true);
} catch (Exception e) {
throw new MiniLangException("Could not read SimpleMethod XML document [" + name + "]: ", e);
}
compileAllSimpleMethods(document.getDocumentElement(), simpleMethods, fromLocation);
return simpleMethods;
}
示例10: getAllSimpleMethods
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Map<String, SimpleMethod> getAllSimpleMethods(URL xmlURL) throws MiniLangException {
Map<String, SimpleMethod> simpleMethods = new LinkedHashMap<String, SimpleMethod>();
Document document = null;
try {
document = UtilXml.readXmlDocument(xmlURL, true, true);
} catch (Exception e) {
throw new MiniLangException("Could not read SimpleMethod XML document [" + xmlURL + "]: ", e);
}
compileAllSimpleMethods(document.getDocumentElement(), simpleMethods, xmlURL.toString());
if (MiniLangUtil.isDocumentAutoCorrected(document)) {
MiniLangUtil.writeMiniLangDocument(xmlURL, document);
}
return simpleMethods;
}
示例11: deserialize
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Object deserialize(String content, Delegator delegator) throws SerializeException, SAXException, ParserConfigurationException, IOException {
Document document = UtilXml.readXmlDocument(content, false);
if (document != null) {
return XmlSerializer.deserialize(document, delegator);
} else {
Debug.logWarning("Serialized document came back null", module);
return null;
}
}
示例12: getXmlDocument
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private static Document getXmlDocument() throws GenericConfigException {
URL confUrl = UtilURL.fromResource(SERVICE_ENGINE_XML_FILENAME);
if (confUrl == null) {
throw new GenericConfigException("Could not find the " + SERVICE_ENGINE_XML_FILENAME + " file");
}
try {
return UtilXml.readXmlDocument(confUrl, true, true);
} catch (Exception e) {
throw new GenericConfigException("Exception thrown while reading " + SERVICE_ENGINE_XML_FILENAME + ": ", e);
}
}
示例13: getLabelsFromOfbizComponents
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
private void getLabelsFromOfbizComponents() throws IOException, SAXException, ParserConfigurationException {
List<File> componentsFiles = FileUtil.findXmlFiles(null, null, "ofbiz-component", "http://ofbiz.apache.org/dtds/ofbiz-component.xsd");
for (File componentFile : componentsFiles) {
String filePath = componentFile.getPath();
Document menuDocument = UtilXml.readXmlDocument(componentFile.toURI().toURL());
Element rootElem = menuDocument.getDocumentElement();
for (Element elem1 : UtilXml.childElementList(rootElem)) {
checkOfbizComponentTag(elem1, filePath);
for (Element elem2 : UtilXml.childElementList(elem1)) {
checkOfbizComponentTag(elem2, filePath);
}
}
}
}
示例14: getMenuFromWebappContext
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static ModelMenu getMenuFromWebappContext(String resourceName, String menuName, HttpServletRequest request)
throws IOException, SAXException, ParserConfigurationException {
String webappName = UtilHttp.getApplicationName(request);
String cacheKey = webappName + "::" + resourceName;
Map<String, ModelMenu> modelMenuMap = menuWebappCache.get(cacheKey);
if (modelMenuMap == null) {
synchronized (MenuFactory.class) {
modelMenuMap = menuWebappCache.get(cacheKey);
if (modelMenuMap == null) {
ServletContext servletContext = (ServletContext) request.getAttribute("servletContext");
URL menuFileUrl = servletContext.getResource(resourceName);
Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true, true);
// SCIPIO: New: Save original location as user data in Document
if (menuFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(menuFileDoc).setResourceLocation(resourceName);
}
modelMenuMap = readMenuDocument(menuFileDoc, cacheKey);
menuWebappCache.put(cacheKey, modelMenuMap);
}
}
}
if (UtilValidate.isEmpty(modelMenuMap)) {
throw new IllegalArgumentException("Could not find menu file in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]");
}
ModelMenu modelMenu = modelMenuMap.get(menuName);
if (modelMenu == null) {
throw new IllegalArgumentException("Could not find menu with name [" + menuName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]");
}
return modelMenu;
}
示例15: getFormsFromLocation
import org.ofbiz.base.util.UtilXml; //导入方法依赖的package包/类
public static Map<String, ModelForm> getFormsFromLocation(String resourceName, ModelReader entityModelReader, DispatchContext dispatchContext)
throws IOException, SAXException, ParserConfigurationException {
URL formFileUrl = FlexibleLocation.resolveLocation(resourceName);
Document formFileDoc = UtilXml.readXmlDocument(formFileUrl, true, true);
// SCIPIO: New: Save original location as user data in Document
if (formFileDoc != null) {
WidgetDocumentInfo.retrieveAlways(formFileDoc).setResourceLocation(resourceName);
}
return readFormDocument(formFileDoc, entityModelReader, dispatchContext, resourceName);
}