import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.netconf.api.CapabilityURN;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfSessionListener;
}
private static boolean containsBase11Capability(final Document doc) {
- final NodeList nList = doc.getElementsByTagNameNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.CAPABILITY);
+ final NodeList nList = doc.getElementsByTagNameNS(NamespaceURN.BASE, XmlNetconfConstants.CAPABILITY);
for (int i = 0; i < nList.getLength(); i++) {
if (nList.item(i).getTextContent().contains(CapabilityURN.BASE_1_1)) {
return true;
import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
public static NetconfStartExiMessage create(final EXIParameters exiOptions, final String messageId) {
final Document doc = XmlUtil.newDocument();
- final Element rpcElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.RPC_KEY);
- rpcElement.setAttributeNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.MESSAGE_ID, messageId);
+ final Element rpcElement = doc.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.RPC_KEY);
+ rpcElement.setAttributeNS(NamespaceURN.BASE, XmlNetconfConstants.MESSAGE_ID, messageId);
// TODO draft http://tools.ietf.org/html/draft-varga-netconf-exi-capability-02#section-3.5.1 has no namespace
// for start-exi element in xml
- final Element startExiElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0,
- START_EXI);
+ final Element startExiElement = doc.createElementNS(NamespaceURN.EXI, START_EXI);
addAlignment(exiOptions, doc, startExiElement);
addFidelity(exiOptions, doc, startExiElement);
private static void addAlignment(final EXIParameters exiOptions, final Document doc,
final Element startExiElement) {
- final Element alignmentElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0,
- EXIParameters.EXI_PARAMETER_ALIGNMENT);
+ final Element alignmentElement = doc.createElementNS(NamespaceURN.EXI, EXIParameters.EXI_PARAMETER_ALIGNMENT);
alignmentElement.setTextContent(exiOptions.getAlignment());
startExiElement.appendChild(alignmentElement);
createFidelityElement(doc, fidelityElements, exiOptions.getPreservePrefixes());
if (!fidelityElements.isEmpty()) {
- final Element fidelityElement = doc.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0, EXIParameters.EXI_PARAMETER_FIDELITY);
+ final Element fidelityElement = doc.createElementNS(NamespaceURN.EXI, EXIParameters.EXI_PARAMETER_FIDELITY);
for (final Element element : fidelityElements) {
fidelityElement.appendChild(element);
}
private static void addSchema(final EXIParameters exiOptions, final Document doc, final Element startExiElement) {
final String schema = exiOptions.getSchema();
if (schema != null) {
- final Element child = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0,
- EXIParameters.EXI_PARAMETER_SCHEMAS);
+ final Element child = doc.createElementNS(NamespaceURN.EXI, EXIParameters.EXI_PARAMETER_SCHEMAS);
child.setTextContent(schema);
startExiElement.appendChild(child);
}
private static void createFidelityElement(final Document doc, final List<Element> elements,
final String fidelity) {
if (fidelity != null) {
- elements.add(doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0, fidelity));
+ elements.add(doc.createElementNS(NamespaceURN.EXI, fidelity));
}
}
}
import java.util.Map;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.server.api.monitoring.NetconfMonitoringService;
private static Element getPlaceholder(final Document innerResult) throws DocumentedException {
return XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
- XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)
+ XmlNetconfConstants.RPC_REPLY_KEY, NamespaceURN.BASE)
.getOnlyChildElement(XmlNetconfConstants.DATA_KEY)
.getDomElement();
}
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.withSettings;
-import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
import com.google.common.base.CharMatcher;
import com.google.common.base.Strings;
import org.mockito.MockMakers;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.netconf.api.CapabilityURN;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfTerminationReason;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
private static NetconfMessage createSuccessResponseMessage(final String messageID)
throws ParserConfigurationException {
Document doc = UntrustedXML.newDocumentBuilder().newDocument();
- Element rpcReply =
- doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.RPC_REPLY_KEY);
+ Element rpcReply = doc.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.RPC_REPLY_KEY);
rpcReply.setAttribute("message-id", messageID);
Element element = doc.createElementNS("ns", "data");
element.setTextContent(messageID);
import java.util.Base64;
import java.util.Optional;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.server.api.operations.AbstractSingletonNetconfOperation;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
ErrorType.PROTOCOL, ErrorTag.MISSING_ELEMENT, ErrorSeverity.ERROR));
final Document document = getDocumentFromUrl(urlElement.getTextContent());
- return XmlElement.fromDomElementWithExpected(document.getDocumentElement(), CONFIG_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ return XmlElement.fromDomElementWithExpected(document.getDocumentElement(), CONFIG_KEY, NamespaceURN.BASE);
}
/**
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMResult;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.server.api.operations.AbstractSingletonNetconfOperation;
private static Optional<Datastore> parseSource(final XmlElement xml) throws DocumentedException {
final Optional<XmlElement> sourceElement = xml.getOnlyChildElementOptionally(XmlNetconfConstants.SOURCE_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ NamespaceURN.BASE);
return sourceElement.isEmpty() ? Optional.empty()
: Optional.of(Datastore.valueOf(sourceElement.orElseThrow().getOnlyChildElement().getName()));
}
- private static void validateInputRpc(final XmlElement xml, final String operationName) throws
- DocumentedException {
+ private static void validateInputRpc(final XmlElement xml, final String operationName)
+ throws DocumentedException {
xml.checkName(operationName);
- xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ xml.checkNamespace(NamespaceURN.BASE);
}
public Optional<Datastore> getDatastore() {
*/
package org.opendaylight.netconf.server.mdsal.operations;
-import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
-
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
private Node transformNormalizedNode(final Document document, final ContainerNode data) {
- final Element configElement = document.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, CONFIG_KEY);
+ final Element configElement = document.createElementNS(NamespaceURN.BASE, CONFIG_KEY);
final DOMResult result = new DOMResult(configElement);
try {
final XMLStreamWriter xmlWriter = XML_OUTPUT_FACTORY.createXMLStreamWriter(result);
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
throw DocumentedException.wrap(e);
}
if (result.value() == null) {
- return XmlUtil.createElement(document, XmlNetconfConstants.OK,
- Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.of(NamespaceURN.BASE));
}
return transformNormalizedNode(document, result.value(),
Absolute.of(rpcDefinition.getQName(), rpcDefinition.getOutput().getQName()));
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));
+ Optional.of(NamespaceURN.BASE));
if (XmlElement.fromDomElement(response).hasNamespace()) {
rpcReply.appendChild(response);
package org.opendaylight.netconf.api;
import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.RPC_REPLY_KEY;
-import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
import java.util.HashMap;
import java.util.Map;
// FIXME: NETCONF-793: remove all of these in favor of YangNetconfErrorAware
public ErrorType getErrorType() {
- return this.errorType;
+ return errorType;
}
public ErrorTag getErrorTag() {
- return this.errorTag;
+ return errorTag;
}
public ErrorSeverity getErrorSeverity() {
- return this.errorSeverity;
+ return errorSeverity;
}
public Map<String, String> getErrorInfo() {
- return this.errorInfo;
+ return errorInfo;
}
// FIXME: this really should be an spi/util method (or even netconf-util-w3c-dom?) as this certainly is not the
try {
doc = BUILDER_FACTORY.newDocumentBuilder().newDocument();
- Node rpcReply = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, RPC_REPLY_KEY);
+ Node rpcReply = doc.createElementNS(NamespaceURN.BASE, RPC_REPLY_KEY);
doc.appendChild(rpcReply);
- Node rpcError = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, RPC_ERROR);
+ Node rpcError = doc.createElementNS(NamespaceURN.BASE, RPC_ERROR);
rpcReply.appendChild(rpcError);
rpcError.appendChild(createTextNode(doc, ERROR_TYPE, getErrorType().elementBody()));
* <bad-element>rpc</bad-element> </error-info>
*/
- Node errorInfoNode = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, ERROR_INFO);
+ Node errorInfoNode = doc.createElementNS(NamespaceURN.BASE, ERROR_INFO);
errorInfoNode.setPrefix(rpcReply.getPrefix());
rpcError.appendChild(errorInfoNode);
}
private static Node createTextNode(final Document doc, final String tag, final String textContent) {
- Node node = doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, tag);
+ Node node = doc.createElementNS(NamespaceURN.BASE, tag);
node.setTextContent(textContent);
return node;
}
@Override
public String toString() {
- return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + this.errorType
- + ", errorTag=" + this.errorTag + ", errorSeverity=" + this.errorSeverity + ", errorInfo="
- + this.errorInfo + '}';
+ return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + errorType
+ + ", errorTag=" + errorTag + ", errorSeverity=" + errorSeverity + ", errorInfo="
+ + errorInfo + '}';
}
}
--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.api;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * The contents of
+ * <a href="https://www.iana.org/assignments/xml-registry/xml-registry.xhtml#ns">IETF XML ns Registry</a>relevant to
+ * NETCONF.
+ */
+@NonNullByDefault
+public final class NamespaceURN {
+ /**
+ * The NETCONF protocol XML namespace, as defined by <a href="https://www.rfc-editor.org/rfc/rfc6241">RFC6241</a>.
+ */
+ public static final String BASE = "urn:ietf:params:xml:ns:netconf:base:1.0";
+ /**
+ * The namespace used by the
+ * <a href="https://www.rfc-editor.org/rfc/rfc6243">With-defaults Capability for NETCONF</a> extension.
+ */
+ public static final String DEFAULT = "urn:ietf:params:xml:ns:netconf:default:1.0";
+ /**
+ * The namespace used by the
+ * <a href="https://datatracker.ietf.org/doc/html/draft-varga-netconf-exi-capability-01">
+ * Efficient XML Interchange Capability for NETCONF</a> extension. Note this is an expired IETF draft capability and
+ * subject to change.
+ */
+ @Beta
+ public static final String EXI = "urn:ietf:params:xml:ns:netconf:exi:1.0";
+ /**
+ * The namespace used by the <a href="https://www.rfc-editor.org/rfc/rfc5277">NETCONF Event Notifications</a>
+ * extension.
+ */
+ public static final String NOTIFICATION = "urn:ietf:params:xml:ns:netconf:notification:1.0";
+ /**
+ * The namespace used by the <a href="https://www.rfc-editor.org/rfc/rfc5717">
+ * Partial Lock Remote Procedure Call (RPC) for NETCONF</a> extension.
+ */
+ public static final String PARTIAL_LOCK = "urn:ietf:params:xml:ns:netconf:partial-lock:1.0";
+
+ private NamespaceURN() {
+ // Hidden on purpose
+ }
+}
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);
}
}
import java.time.temporal.TemporalAccessor;
import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.slf4j.Logger;
final Element baseNotification = notificationContent.getDocumentElement();
final Element entireNotification = notificationContent.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0,
- XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME);
+ NamespaceURN.NOTIFICATION, XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME);
entireNotification.appendChild(baseNotification);
final Element eventTimeElement = notificationContent.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME);
+ NamespaceURN.NOTIFICATION, XmlNetconfConstants.EVENT_TIME);
eventTimeElement.setTextContent(RFC3339_DATE_FORMATTER.apply(eventTime));
entireNotification.appendChild(eventTimeElement);
public static final String RPC_REPLY_KEY = "rpc-reply";
- public static final String URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0";
- public static final String URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0 = "urn:ietf:params:xml:ns:netconf:exi:1.0";
- public static final String URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0 =
- "urn:ietf:params:xml:ns:netconf:notification:1.0";
-
private XmlNetconfConstants() {
// Hidden on purpose
}
import javax.xml.xpath.XPathFactory;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
@Override
public String getNamespaceURI(final String prefix) {
- return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
+ return NamespaceURN.BASE;
}
});
}
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.NamespaceURN;
final class XMLNetconfUtil {
private static final XPathFactory FACTORY = XPathFactory.newInstance();
- private static final NamespaceContext NS_CONTEXT = new HardcodedNamespaceResolver("netconf",
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ private static final NamespaceContext NS_CONTEXT = new HardcodedNamespaceResolver("netconf", NamespaceURN.BASE);
private XMLNetconfUtil() {
// Hidden on purpose
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfSessionListener;
import org.opendaylight.netconf.api.NetconfTerminationReason;
}
private static void checkMessageId(final Node rootNode) throws DocumentedException {
-
final NamedNodeMap attributes = rootNode.getAttributes();
-
- if (attributes.getNamedItemNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.MESSAGE_ID) != null) {
+ if (attributes.getNamedItemNS(NamespaceURN.BASE, XmlNetconfConstants.MESSAGE_ID) != null) {
return;
}
-
if (attributes.getNamedItem(XmlNetconfConstants.MESSAGE_ID) != null) {
return;
}
import io.netty.channel.ChannelFutureListener;
import javax.xml.XMLConstants;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfSession;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
final Element incommingRpc = incommingDocument.getDocumentElement();
Preconditions.checkState(
XmlNetconfConstants.RPC_KEY.equals(incommingRpc.getLocalName())
- && XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(incommingRpc.getNamespaceURI()),
+ && NamespaceURN.BASE.equals(incommingRpc.getNamespaceURI()),
"Missing %s element", XmlNetconfConstants.RPC_KEY);
final Element rpcReply = errorDocument.getDocumentElement();
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
protected static XmlElement getRequestElementWithCheck(final Document message) throws DocumentedException {
return XmlElement.fromDomElementWithExpected(message.getDocumentElement(), XmlNetconfConstants.RPC_KEY,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ NamespaceURN.BASE);
}
protected HandlingPriority getHandlingPriority() {
}
protected String getOperationNamespace() {
- return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
+ return NamespaceURN.BASE;
}
protected abstract String getOperationName();
Element response = handle(document, operationElement, subsequentOperation);
Element rpcReply = XmlUtil.createElement(document, XmlNetconfConstants.RPC_REPLY_KEY,
- Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
+ Optional.of(NamespaceURN.BASE));
if (XmlElement.fromDomElement(response).hasNamespace()) {
rpcReply.appendChild(response);
} else {
Element responseNS = XmlUtil.createElement(document, response.getNodeName(),
- Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
+ Optional.of(NamespaceURN.BASE));
NodeList list = response.getChildNodes();
while (list.getLength() != 0) {
responseNS.appendChild(list.item(0));
package org.opendaylight.netconf.server.mapping.operations;
import org.opendaylight.netconf.api.DocumentedException;
+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;
@Override
protected Element handleWithNoSubsequentOperations(final Document document,
final XmlElement operationElement) {
- final Element getSchemaResult = document.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+ final Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
LOG.trace("{} operation successful", START_EXI);
return getSchemaResult;
}
@Override
protected String getOperationNamespace() {
- return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;
+ return NamespaceURN.EXI;
}
@Override
*/
package org.opendaylight.netconf.server.mapping.operations;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
netconfSession.stopExiCommunication();
- Element getSchemaResult = document.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+ Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
LOG.trace("{} operation successful", STOP_EXI);
return getSchemaResult;
}
@Override
protected String getOperationNamespace() {
- return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;
+ return NamespaceURN.EXI;
}
@Override
import java.util.Optional;
import javax.xml.XMLConstants;
import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.NamespaceURN;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
public static Document applyRpcSubtreeFilter(final Document requestDocument,
final Document rpcReply) throws DocumentedException {
OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
- if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace())
+ if (NamespaceURN.BASE.equals(operationNameAndNamespace.getNamespace())
&& XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName())
|| XmlNetconfConstants.GET_CONFIG.equals(operationNameAndNamespace.getOperationName())) {
// process subtree filtering here, in case registered netconf operations do
// not implement filtering.
Optional<XmlElement> maybeFilter = operationNameAndNamespace.getOperationElement()
- .getOnlyChildElementOptionally(XmlNetconfConstants.FILTER,
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ .getOnlyChildElementOptionally(XmlNetconfConstants.FILTER, NamespaceURN.BASE);
if (maybeFilter.isEmpty()) {
return rpcReply;
}
private static void removeEventTimeNode(final Document document) {
final Node eventTimeNode = document.getDocumentElement()
- .getElementsByTagNameNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME)
+ .getElementsByTagNameNS(NamespaceURN.NOTIFICATION, XmlNetconfConstants.EVENT_TIME)
.item(0);
document.getDocumentElement().removeChild(eventTimeNode);
}
private static boolean isSupported(final XmlElement filter) {
return "subtree".equals(filter.getAttribute("type"))
- || "subtree".equals(filter.getAttribute("type",
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
+ || "subtree".equals(filter.getAttribute("type", NamespaceURN.BASE));
}
private static Document extractNotificationContent(final Document notification) throws DocumentedException {
Element rpcReply = originalReplyDocument.getDocumentElement();
Node rpcReplyDst = result.importNode(rpcReply, false);
result.appendChild(rpcReplyDst);
- XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data",
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+ XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data", NamespaceURN.BASE);
Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
rpcReplyDst.appendChild(dataDst);
addSubtree(filter, dataSrc, XmlElement.fromDomElement(dataDst));