X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Ftools%2Fnetconf-testtool%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Ftest%2Ftool%2Frpchandler%2FSettableRpc.java;h=d4ef01240011114f858a09de659105c4cbb240f2;hb=aafa2fb9d206df54b7088f449f6e3cfc7bcae50d;hp=1f2b97df6264f05bc382e5786efeb882169a2479;hpb=b7e50e0f8090ada7b0113e1cb56cb21b44e7a3fe;p=netconf.git diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableRpc.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableRpc.java index 1f2b97df62..d4ef012400 100644 --- a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableRpc.java +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/rpchandler/SettableRpc.java @@ -5,17 +5,19 @@ * 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.rpchandler; import java.util.Optional; -import org.opendaylight.controller.config.util.xml.DocumentedException; -import org.opendaylight.controller.config.util.xml.XmlElement; -import org.opendaylight.controller.config.util.xml.XmlUtil; +import org.opendaylight.netconf.api.DocumentedException; +import org.opendaylight.netconf.api.xml.XmlElement; import org.opendaylight.netconf.api.xml.XmlNetconfConstants; -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.api.xml.XmlUtil; +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; /** @@ -24,15 +26,14 @@ import org.w3c.dom.Document; * {@link NetconfOperation} which is able to handle it. */ class SettableRpc implements NetconfOperation { - private final RpcHandler rpcHandler; - SettableRpc(RpcHandler rpcHandler) { + SettableRpc(final RpcHandler rpcHandler) { this.rpcHandler = rpcHandler; } @Override - public HandlingPriority canHandle(final Document message) throws DocumentedException { + public HandlingPriority canHandle(final Document message) { return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1000); } @@ -44,24 +45,22 @@ class SettableRpc implements NetconfOperation { final String msgId = requestElement.getAttribute(XmlNetconfConstants.MESSAGE_ID); final Optional response = rpcHandler.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); } } - private void checkForError(final Document document) throws DocumentedException { + private static void checkForError(final Document document) throws DocumentedException { final XmlElement rpcReply = XmlElement.fromDomDocument(document); if (rpcReply.getOnlyChildElementOptionally("rpc-error").isPresent()) { throw DocumentedException.fromXMLDocument(document); } } - }