import com.google.common.collect.Sets;
import java.util.Optional;
import java.util.Set;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
if (!isHelloMessage(doc)) {
throw new IllegalArgumentException(String.format(
"Hello message invalid format, should contain %s tag from namespace %s, but is: %s", HELLO_TAG,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlUtil.toString(doc)));
+ NamespaceURN.BASE, XmlUtil.toString(doc)));
}
}
private static Document createHelloMessageDoc(final Iterable<String> capabilities) {
Document doc = UntrustedXML.newDocumentBuilder().newDocument();
- Element helloElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- HELLO_TAG);
- Element capabilitiesElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.CAPABILITIES);
+ Element helloElement = doc.createElementNS(NamespaceURN.BASE, HELLO_TAG);
+ Element capabilitiesElement = doc.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.CAPABILITIES);
for (String capability : Sets.newHashSet(capabilities)) {
- Element capElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.CAPABILITY);
+ Element capElement = doc.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.CAPABILITY);
capElement.setTextContent(capability);
capabilitiesElement.appendChild(capElement);
}
public static HelloMessage createServerHello(final Set<String> capabilities, final SessionIdType sessionId) {
Document doc = createHelloMessageDoc(capabilities);
- Element sessionIdElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.SESSION_ID);
+ Element sessionIdElement = doc.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.SESSION_ID);
sessionIdElement.setTextContent(sessionId.getValue().toCanonicalString());
doc.getDocumentElement().appendChild(sessionIdElement);
return new HelloMessage(doc);
final var namespace = element.namespace();
// accept even if hello has no namespace
- return namespace == null || XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(namespace);
+ return namespace == null || NamespaceURN.BASE.equals(namespace);
}
}