Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-577

Issue in casting a anyxml leaf to anyXMLNode type

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Cannot Reproduce
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 5099

    Description

      I am getting WARNING when trying to get values of datastore-contents-xml anyxml node for below notification.

      Is there any modification to anyXML implementation? How to convert anyxml data to a DOMSource in current implementation?

      NOTE: It was working fine during Dec time line.

      The value I am getting for below notification looks
      2016-01-26 15:58:47,020 | INFO | oupCloseable-5-2 | YangpushDOMNotificationListener | 247 - org.opendaylight.yang-push.yangpush-impl - 1.1.0.SNAPSHOT | Notification recieved ImmutableContainerNode{nodeIdentifier=(urn:ietf:params:xml:ns:yang:ietf-datastore-push?revision=2015-10-15)push-update, value=[ImmutableLeafNode{nodeIdentifier=(urn:ietf:params:xml:ns:yang:ietf-datastore-push?revision=2015-10-15)time-of-update, value=2011-01-04T12:30:46Z, attributes={}}, ImmutableLeafNode{nodeIdentifier=(urn:ietf:params:xml:ns:yang:ietf-datastore-push?revision=2015-10-15)subscription-id, value=201, attributes={}}, ImmutableChoiceNode{nodeIdentifier=(urn:ietf:params:xml:ns:yang:ietf-datastore-push?revision=2015-10-15)encoding, value=[ImmutableLeafNode{nodeIdentifier=(urn:ietf:params:xml:ns:yang:ietf-datastore-push?revision=2015-10-15)datastore-contents-xml, value=actMgmtEth0/0/CPU0/010.0.2.15255.255.255.0, attributes={}}]}], attributes={}}

      2016-01-26 15:58:47,021 | WARN | oupCloseable-5-2 | YangpushDOMNotificationListener | 247 - org.opendaylight.yang-push.yangpush-impl - 1.1.0.SNAPSHOT | java.lang.ClassCastException: org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder$ImmutableLeafNode cannot be cast to org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode

      Notification schema:
      notification push-update {
      leaf subscription-id

      { type subscription-id; mandatory true; }

      leaf time-of-update

      { type yang:date-and-time; }

      choice encoding {
      case encode-xml

      { anyxml datastore-contents-xml; }

      case encode-json {
      if-feature json;
      leaf datastore-contents-json

      { type datastore-contents-json; }

      }
      }
      }

      Sample code:
      private void pushUpdateHandlder(DOMNotification notification) {
      ContainerNode conNode = notification.getBody();
      ChoiceNode valueNode = null;
      AnyXmlNode anyXmlValue = null;
      DOMSource domSource = null;
      String sub_id = "";
      String timeofeventupdate = "";
      try

      { sub_id = conNode.getChild(subid).get().getValue().toString(); timeofeventupdate = conNode.getChild(timeofevent).get().getValue().toString(); valueNode = (ChoiceNode) conNode.getChild(encoding).get(); anyXmlValue = (AnyXmlNode) valueNode.getChild(contents).get(); domSource = anyXmlValue.getValue(); }

      catch (Exception e)

      { LOG.warn(e.toString()); }

      String notificationAsString = domSourceToString(domSource);
      LOG.info("Notification recieved for sub_id :{} at : {}:\n {}", sub_id, timeofeventupdate, notificationAsString);
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ifoltin Igor Foltin
            ambika.tripathy@cisco.com Ambika Prasad Tripathy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: