import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import com.google.common.base.Optional;
+
public abstract class AbstractNetconfOperation implements NetconfOperation {
private final String netconfSessionIdForReporting;
return canHandle(operationNameAndNamespace.getOperationName(), operationNameAndNamespace.getNamespace());
}
- public static class OperationNameAndNamespace {
+ public static final class OperationNameAndNamespace {
private final String operationName, namespace;
public OperationNameAndNamespace(Document message) {
Map<String, Attr> attributes = requestElement.getAttributes();
Element response = handle(document, operationElement, subsequentOperation);
- Element rpcReply = document.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
- XmlNetconfConstants.RPC_REPLY_KEY);
+ 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 {
- Element responseNS = document.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, response.getNodeName());
+ Element responseNS = XmlUtil.createElement(document, response.getNodeName(), Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
NodeList list = response.getChildNodes();
while(list.getLength()!=0) {
responseNS.appendChild(list.item(0));
@Override
public String toString() {
- final StringBuffer sb = new StringBuffer("AbstractConfigNetconfOperation{");
- sb.append("name=").append(getOperationName());
+ final StringBuffer sb = new StringBuffer(getClass().getName());
+ try {
+ sb.append("{name=").append(getOperationName());
+ } catch(UnsupportedOperationException e) {
+ // no problem
+ }
sb.append(", namespace=").append(getOperationNamespace());
sb.append(", session=").append(netconfSessionIdForReporting);
sb.append('}');