gpt4 book ai didi

org.opendaylight.controller.netconf.util.xml.XmlElement.fromDomDocument()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 13:17:05 26 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.controller.netconf.util.xml.XmlElement.fromDomDocument()方法的一些代码示例,展示了XmlElement.fromDomDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlElement.fromDomDocument()方法的具体详情如下:
包路径:org.opendaylight.controller.netconf.util.xml.XmlElement
类名称:XmlElement
方法名:fromDomDocument

XmlElement.fromDomDocument介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/netconf-util

public static boolean isErrorMessage(Document document) throws NetconfDocumentedException {
  return isErrorMessage(XmlElement.fromDomDocument(document));
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

public static boolean isOKMessage(Document document) throws NetconfDocumentedException {
  return isOKMessage(XmlElement.fromDomDocument(document));
}

代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector

private static boolean isNotification(final NetconfMessage message) {
  final XmlElement xmle = XmlElement.fromDomDocument(message.getDocument());
  return XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME.equals(xmle.getName()) ;
}

代码示例来源:origin: org.opendaylight.controller/netconf-util

public static Document checkIsMessageOk(Document response) throws NetconfDocumentedException {
    XmlElement element = XmlElement.fromDomDocument(response);
    Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY));
    element = element.getOnlyChildElement();
    if (element.getName().equals(XmlNetconfConstants.OK)) {
      return response;
    }
    LOG.warn("Can not load last configuration. Operation failed.");
    throw new IllegalStateException("Can not load last configuration. Operation failed: "
        + XmlUtil.toString(response));
  }
}

代码示例来源: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-netty-util

@Override
public final void startExiCommunication(final NetconfMessage startExiMessage) {
  final EXIParameters exiParams;
  try {
    exiParams = EXIParameters.fromXmlElement(XmlElement.fromDomDocument(startExiMessage.getDocument()));
  } catch (final EXIOptionsException e) {
    LOG.warn("Unable to parse EXI parameters from {} on session {}", startExiMessage, this, e);
    throw new IllegalArgumentException("Cannot parse options", e);
  }
  final NetconfEXICodec exiCodec = new NetconfEXICodec(exiParams.getOptions());
  final NetconfMessageToEXIEncoder exiEncoder;
  try {
    exiEncoder = NetconfMessageToEXIEncoder.create(exiCodec);
  } catch (EXIOptionsException | TransmogrifierException e) {
    LOG.warn("Failed to instantiate EXI encoder for {} on session {}", exiCodec, this, e);
    throw new IllegalStateException("Cannot instantiate encoder for options", e);
  }
  final NetconfEXIToMessageDecoder exiDecoder;
  try {
    exiDecoder = NetconfEXIToMessageDecoder.create(exiCodec);
  } catch (EXIOptionsException e) {
    LOG.warn("Failed to instantiate EXI decodeer for {} on session {}", exiCodec, this, e);
    throw new IllegalStateException("Cannot instantiate encoder for options", e);
  }
  addExiHandlers(exiDecoder, exiEncoder);
  LOG.debug("Session {} EXI handlers added to pipeline", this);
}

代码示例来源:origin: org.opendaylight.controller/sal-netconf-connector

Preconditions.checkArgument(XmlElement.fromDomDocument(message.getDocument()).getOnlyChildElementWithSameNamespaceOptionally("ok").isPresent(),
    "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message);
normalizedNode = null;

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com