Integrate netconf-mapping-api into netconf-server
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / customrpc / SettableRpc.java
index ed43703e3ec413c6e961162e9ec076bcd336768a..fd53b97e93fe5cc40671743adc2448c9159f946c 100644 (file)
@@ -5,7 +5,6 @@
  * 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.test.tool.customrpc;
 
 import java.io.File;
@@ -14,9 +13,12 @@ import org.opendaylight.netconf.api.DocumentedException;
 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.mapping.api.HandlingPriority;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.netconf.server.api.operations.HandlingPriority;
+import org.opendaylight.netconf.server.api.operations.NetconfOperation;
+import org.opendaylight.netconf.server.api.operations.NetconfOperationChainedExecution;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.w3c.dom.Document;
 
 /**
@@ -25,7 +27,6 @@ import org.w3c.dom.Document;
  * {@link NetconfOperation} which is able to handle it.
  */
 class SettableRpc implements NetconfOperation {
-
     private final RpcMapping mapping;
 
     SettableRpc(final File rpcConfig) {
@@ -45,14 +46,13 @@ class SettableRpc implements NetconfOperation {
         final String msgId = requestElement.getAttribute(XmlNetconfConstants.MESSAGE_ID);
         final Optional<Document> response = mapping.getResponse(rpcElement);
         if (response.isPresent()) {
-            final Document document = response.get();
+            final Document document = response.orElseThrow();
             checkForError(document);
             document.getDocumentElement().setAttribute(XmlNetconfConstants.MESSAGE_ID, msgId);
             return document;
         } else if (subsequentOperation.isExecutionTermination()) {
             throw new DocumentedException("Mapping not found " + XmlUtil.toString(requestMessage),
-                    DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_NOT_SUPPORTED,
-                    DocumentedException.ErrorSeverity.ERROR);
+                    ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED, ErrorSeverity.ERROR);
         } else {
             return subsequentOperation.execute(requestMessage);
         }
@@ -64,5 +64,4 @@ class SettableRpc implements NetconfOperation {
             throw DocumentedException.fromXMLDocument(document);
         }
     }
-
 }