- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement
类的一些代码示例,展示了XmlElement
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement
类的具体详情如下:
包路径:org.opendaylight.controller.netconf.util.xml.XmlElement
类名称:XmlElement
暂无
代码示例来源:origin: org.opendaylight.controller/netconf-impl
private static Document filtered(XmlElement filter, Document originalReplyDocument) throws NetconfDocumentedException {
Document result = XmlUtil.newDocument();
// even if filter is empty, copy /rpc/data
Element rpcReply = originalReplyDocument.getDocumentElement();
Node rpcReplyDst = result.importNode(rpcReply, false);
result.appendChild(rpcReplyDst);
XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data", XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
rpcReplyDst.appendChild(dataDst);
addSubtree(filter, dataSrc, XmlElement.fromDomElement(dataDst));
return result;
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public static boolean isErrorMessage(XmlElement xmlElement) throws NetconfDocumentedException {
if(xmlElement.getChildElements().size() != 1) {
return false;
}
return xmlElement.getOnlyChildElement().getName().equals(XmlNetconfConstants.RPC_ERROR);
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws NetconfDocumentedException{
XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
Map.Entry<String, String> prefixNamespace = typeElement.findNamespaceOfTextContent();
String serviceName = checkPrefixAndExtractServiceName(typeElement, prefixNamespace);
XmlElement nameElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.NAME_KEY);
String dependencyName = nameElement.getTextContent();
return new ObjectNameAttributeMappingStrategy.MappedDependency(prefixNamespace.getValue(), serviceName,
dependencyName);
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public XmlElement getOnlyChildElementWithSameNamespace() throws NetconfDocumentedException {
XmlElement childElement = getOnlyChildElement();
childElement.checkNamespace(getNamespace());
return childElement;
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private static void checkXml(XmlElement xml) throws UnexpectedElementException, UnexpectedNamespaceException, MissingNameSpaceException {
xml.checkName(XmlNetconfConstants.GET);
xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
// Filter option: ignore for now, TODO only load modules specified by the filter
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public static XmlElement fromDomElementWithExpected(Element element, String expectedName) throws NetconfDocumentedException {
XmlElement xmlElement = XmlElement.fromDomElement(element);
xmlElement.checkName(expectedName);
return xmlElement;
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
requestElement = getRequestElementWithCheck(message);
XmlElement operationElement = requestElement.getOnlyChildElement();
final String netconfOperationName = operationElement.getName();
final String netconfOperationNamespace;
try {
netconfOperationNamespace = operationElement.getNamespace();
} catch (MissingNameSpaceException e) {
LOG.debug("Cannot retrieve netconf operation namespace from message due to ", e);
.getOnlyChildElementOptionally(CONTEXT_INSTANCE);
.getTextContent(), netconfOperationName, netconfOperationNamespace);
代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector
private Datastore extractTargetParameter(final XmlElement operationElement) throws NetconfDocumentedException {
final NodeList elementsByTagName = operationElement.getDomElement().getElementsByTagName(TARGET_KEY);
// Direct lookup instead of using XmlElement class due to performance
if (elementsByTagName.getLength() == 0) {
throw new NetconfDocumentedException("Missing target element", ErrorType.rpc, ErrorTag.missing_attribute, ErrorSeverity.error);
} else if (elementsByTagName.getLength() > 1) {
throw new NetconfDocumentedException("Multiple target elements", ErrorType.rpc, ErrorTag.unknown_attribute, ErrorSeverity.error);
} else {
final XmlElement targetChildNode = XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
return Datastore.valueOf(targetChildNode.getName());
}
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
private Element toXml(Document doc, Object result, AttributeIfc returnType, String namespace, String elementName) throws NetconfDocumentedException {
AttributeMappingStrategy<?, ? extends OpenType<?>> mappingStrategy = new ObjectMapper().prepareStrategy(returnType);
Optional<?> mappedAttributeOpt = mappingStrategy.mapAttribute(result);
Preconditions.checkState(mappedAttributeOpt.isPresent(), "Unable to map return value %s as %s", result, returnType.getOpenType());
// FIXME: multiple return values defined as leaf-list and list in yang should not be wrapped in output xml element,
// they need to be appended directly under rpc-reply element
//
// Either allow List of Elements to be returned from NetconfOperation or
// pass reference to parent output xml element for netconf operations to
// append result(s) on their own
Element tempParent = XmlUtil.createElement(doc, "output", Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
new ObjectXmlWriter().prepareWritingStrategy(elementName, returnType, doc).writeElement(tempParent, namespace, mappedAttributeOpt.get());
XmlElement xmlElement = XmlElement.fromDomElement(tempParent);
return xmlElement.getChildElements().size() > 1 ? tempParent : xmlElement.getOnlyChildElement().getDomElement();
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
xml.checkName(EditConfigXmlParser.EDIT_CONFIG);
xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
XmlElement targetChildNode = null;
try {
targetElement = xml.getOnlyChildElementWithSameNamespace(EditConfigXmlParser.TARGET_KEY);
targetChildNode = targetElement.getOnlyChildElementWithSameNamespace();
} catch (final MissingNameSpaceException | UnexpectedNamespaceException e) {
LOG.trace("Can't get only child element with same namespace", e);
throw NetconfDocumentedException.wrap(e);
String datastoreValue = targetChildNode.getName();
Datastore targetDatastore = Datastore.valueOf(datastoreValue);
LOG.debug("Setting {} to '{}'", EditConfigXmlParser.TARGET_KEY, targetDatastore);
.getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.TEST_OPTION_KEY);
if (testOptionElementOpt.isPresent()) {
String testOptionValue = testOptionElementOpt.get().getTextContent();
testOption = EditConfigXmlParser.TestOption.getFromXmlName(testOptionValue);
} else {
.getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.ERROR_OPTION_KEY);
if (errorOptionElement.isPresent()) {
String errorOptionParsed = errorOptionElement.get().getTextContent();
if (!errorOptionParsed.equals(EditConfigXmlParser.DEFAULT_ERROR_OPTION)){
throw new UnsupportedOperationException("Only " + EditConfigXmlParser.DEFAULT_ERROR_OPTION
.getOnlyChildElementWithSameNamespaceOptionally(EditConfigXmlParser.DEFAULT_OPERATION_KEY);
if (defaultContent.isPresent()) {
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
public static Services fromXml(XmlElement xml) throws NetconfDocumentedException {
Map<String, Map<String, Map<String, String>>> retVal = Maps.newHashMap();
List<XmlElement> services = xml.getChildElements(SERVICE_KEY);
xml.checkUnrecognisedElements(services);
XmlElement typeElement = service.getOnlyChildElement(TYPE_KEY);
Entry<String, String> prefixNamespace = typeElement.findNamespaceOfTextContent();
List<XmlElement> instances = service.getChildElements(XmlNetconfConstants.INSTANCE_KEY);
service.checkUnrecognisedElements(instances, typeElement);
XmlElement nameElement = instance.getOnlyChildElement(NAME_KEY);
String refName = nameElement.getTextContent();
instance.getAttribute(
XmlNetconfConstants.OPERATION_ATTR_KEY,
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)))
XmlElement providerElement = instance.getOnlyChildElement(PROVIDER_KEY);
String providerName = providerElement.getTextContent();
instance.checkUnrecognisedElements(nameElement, providerElement);
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
public static Datastore fromXml(XmlElement xml) throws UnexpectedNamespaceException, UnexpectedElementException, MissingNameSpaceException, NetconfDocumentedException {
xml.checkName(GET_CONFIG);
xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY,
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
XmlElement sourceNode = sourceElement.getOnlyChildElement();
String sourceParsed = sourceNode.getName();
LOG.debug("Setting source datastore to '{}'", sourceParsed);
Datastore sourceDatastore = Datastore.valueOf(sourceParsed);
// Filter option: ignore for now, TODO only load modules specified by the filter
return sourceDatastore;
}
代码示例来源:origin: org.opendaylight.controller/config-netconf-connector
List<XmlElement> recognisedChildren = Lists.newArrayList();
XmlElement typeElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY);
XmlElement nameElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.NAME_KEY);
List<XmlElement> typeAndNameElements = Lists.newArrayList(typeElement, nameElement);
int size = moduleElement.getChildElements().size();
int expectedChildNodes = 1 + typeAndNameElements.size();
if (size > expectedChildNodes) {
throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " +
nameElement.getTextContent() + " - Expected " + expectedChildNodes +" child nodes, " +
"one of them with name " + nullableDummyContainerName +
", got " + size + " elements.");
moduleElement = moduleElement.getOnlyChildElement(nullableDummyContainerName, moduleNamespace);
} catch (NetconfDocumentedException e) {
throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " +
nameElement.getTextContent() + " - Expected child node with name " + nullableDummyContainerName +
"." + e.getMessage());
moduleElement.checkUnrecognisedElements(recognisedChildren);
} catch (NetconfDocumentedException e) {
throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " +
nameElement.getTextContent() + " - " +
e.getMessage(), e.getErrorType(), e.getErrorTag(),e.getErrorSeverity(),e.getErrorInfo());
String perInstanceEditStrategy = moduleElement.getAttribute(XmlNetconfConstants.OPERATION_ATTR_KEY,
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
代码示例来源:origin: org.opendaylight.controller/netconf-impl
private static MatchingResult addSubtree2(XmlElement filter, XmlElement src, XmlElement dstParent) throws NetconfDocumentedException {
Document document = dstParent.getDomElement().getOwnerDocument();
MatchingResult matches = matches(src, filter);
if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
boolean shouldAppend = filterHasChildren == false;
if (filterHasChildren) { // this implies TAG_MATCH
for (XmlElement srcChild : src.getChildElements()) {
for (XmlElement filterChild : filter.getChildElements()) {
MatchingResult childMatch = addSubtree2(filterChild, srcChild, XmlElement.fromDomElement(copied));
if (childMatch == MatchingResult.CONTENT_MISMATCH) {
return MatchingResult.NO_MATCH;
if (numberOfTextMatchingChildren == filter.getChildElements().size()) {
copied = (Element) document.importNode(src.getDomElement(), true);
dstParent.getDomElement().appendChild(copied);
代码示例来源:origin: org.opendaylight.controller/mdsal-netconf-connector
@Override
public Document handle(final Document requestMessage,
final NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
final XmlElement requestElement = getRequestElementWithCheck(requestMessage);
final Document document = XmlUtil.newDocument();
final XmlElement operationElement = requestElement.getOnlyChildElement();
final Map<String, Attr> attributes = requestElement.getAttributes();
final Element response = handle(document, operationElement, subsequentOperation);
final Element rpcReply = XmlUtil.createElement(document, XmlNetconfConstants.RPC_REPLY_KEY, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
if(XmlElement.fromDomElement(response).hasNamespace()) {
rpcReply.appendChild(response);
} else {
final NodeList list = response.getChildNodes();
if (list.getLength() == 0) {
rpcReply.appendChild(response);
} else {
while (list.getLength() != 0) {
rpcReply.appendChild(list.item(0));
}
}
}
for (Attr attribute : attributes.values()) {
rpcReply.setAttributeNode((Attr) document.importNode(attribute, true));
}
document.appendChild(rpcReply);
return document;
}
代码示例来源:origin: org.opendaylight.controller/netconf-notifications-impl
private static Element getPlaceholder(final Document innerResult)
throws NetconfDocumentedException {
final XmlElement rootElement = XmlElement.fromDomElementWithExpected(
innerResult.getDocumentElement(), XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
}
代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector
private static Map.Entry<Date, XmlElement> stripNotification(final NetconfMessage message) {
final XmlElement xmlElement = XmlElement.fromDomDocument(message.getDocument());
final List<XmlElement> childElements = xmlElement.getChildElements();
Preconditions.checkArgument(childElements.size() == 2, "Unable to parse notification %s, unexpected format", message);
final XmlElement eventTimeElement;
final XmlElement notificationElement;
if (childElements.get(0).getName().equals(EVENT_TIME)) {
eventTimeElement = childElements.get(0);
notificationElement = childElements.get(1);
}
else if(childElements.get(1).getName().equals(EVENT_TIME)) {
eventTimeElement = childElements.get(1);
notificationElement = childElements.get(0);
} else {
throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message);
}
try {
return new AbstractMap.SimpleEntry<>(EVENT_TIME_FORMAT.get().parse(eventTimeElement.getTextContent()), notificationElement);
} catch (NetconfDocumentedException e) {
throw new IllegalArgumentException("Notification payload does not contain " + EVENT_TIME + " " + message);
} catch (ParseException e) {
LOG.warn("Unable to parse event time from {}. Setting time to {}", eventTimeElement, NetconfNotification.UNKNOWN_EVENT_TIME, e);
return new AbstractMap.SimpleEntry<>(NetconfNotification.UNKNOWN_EVENT_TIME, notificationElement);
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public static Collection<String> extractCapabilitiesFromHello(Document doc) throws NetconfDocumentedException {
XmlElement responseElement = XmlElement.fromDomDocument(doc);
// Extract child element <capabilities> from <hello> with or without(fallback) the same namespace
Optional<XmlElement> capabilitiesElement = responseElement
.getOnlyChildElementWithSameNamespaceOptionally(XmlNetconfConstants.CAPABILITIES)
.or(responseElement
.getOnlyChildElementOptionally(XmlNetconfConstants.CAPABILITIES));
List<XmlElement> caps = capabilitiesElement.get().getChildElements(XmlNetconfConstants.CAPABILITY);
return Collections2.transform(caps, new Function<XmlElement, String>() {
@Override
public String apply(@Nonnull XmlElement input) {
// Trim possible leading/tailing whitespace
try {
return input.getTextContent().trim();
} catch (NetconfDocumentedException e) {
LOG.trace("Error fetching input text content",e);
return null;
}
}
});
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
private static boolean isHelloMessage(final Document document) {
XmlElement element = XmlElement.fromDomElement(document.getDocumentElement());
try {
// accept even if hello has no namespace
return element.getName().equals(HELLO_TAG) &&
(!element.hasNamespace() || element.getNamespace().equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
} catch (MissingNameSpaceException e) {
// Cannot happen, since we check for hasNamespace
throw new IllegalStateException(e);
}
}
}
代码示例来源:origin: org.opendaylight.controller/netconf-util
public OperationNameAndNamespace(final Document message) throws NetconfDocumentedException {
XmlElement requestElement = null;
requestElement = getRequestElementWithCheck(message);
operationElement = requestElement.getOnlyChildElement();
operationName = operationElement.getName();
namespace = operationElement.getNamespace();
}
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我的设备yang如下图- module router { yang-version 1; namespace "urn:sdnhub:odl:tutorial:router";
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 5 年前。 Improve t
我想使用 python 库 ncclient 0.6.6 和 Python 2.7.15 连接到 NETCONF 服务器 (netopeer2) 并读出正在运行的配置。 我尝试按照手册中的示例,在控制
我的 Python 脚本在返回我传递给它的 XML rpc 请求之前会终止我的 netconf session 。当我直接连接到路由器的 Netconf session 时,我的 XML rpc 可以
Microsoft 将于 2024 年 8 月 20 日举办免费的 .NET Conf: Focus on AI。该虚拟活动为开发人员提供了如何集成 .NET 和 AI 以增强应用程序开发和用户体验的
目前我正在用 C++ 实现 netconf 服务器。我找到了这个网站: https://www.appinf.com/docs/poco-2008.2/NetconfUserGuide.html我想也
我已将 ODL Netconf 测试工具 (netconf-testtool-1.1.0-Boron-executable.jar) 部署到我的 Nitrogen ODL Controller 上,以
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement类的一些代码示例,展示了XmlElement类的具体用法。这些代码示例
本文整理了Java中org.opendaylight.controller.netconf.util.capability.YangModuleCapability类的一些代码示例,展示了YangMo
While starting open daylight netconf test tool simulator I am getting the following error: “java -ja
我已经使用 J2ssh 库 (0.2.7) 在我的应用程序中建立 NETCONF 连接。在配置文件监视时,我注意到很少有线程在 j2ssh session 的 connect() 中被阻止。这不是一个
我正在尝试找到一种更好的方法来生成要发送到其中包含 NETCONF 标记的设备的 XML RPC 请求。 我们知道请求应该是什么样子,所以我正在做的是,只是用其中的占位符对 XML-RPC 请求 XM
我正在尝试找到一种更好的方法来生成 XML RPC 请求,以将其发送到其中包含 NETCONF 标记的设备。 我们知道请求应该是什么样子,所以我正在做的是硬编码 XML-RPC 请求 XML,其中包含
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getNamespaceOptionally()方法的一些代码示例,
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.findNamespaceOfTextContent()方法的一些代
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getName()方法的一些代码示例,展示了XmlElement.g
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getOnlyChildElementWithSameNamespa
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getChildElements()方法的一些代码示例,展示了Xml
本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.getChildElementsWithinNamespace()方
我是一名优秀的程序员,十分优秀!