2 * Copyright (c) 2019 Nordix Foundation. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.remote.rpc;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.controller.remote.rpc.messages.ActionResponse;
12 import org.opendaylight.mdsal.dom.api.DOMActionException;
13 import org.opendaylight.mdsal.dom.api.DOMActionResult;
14 import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import scala.concurrent.Future;
19 final class RemoteDOMActionFuture extends AbstractRemoteFuture<DOMActionResult, DOMActionException> {
20 RemoteDOMActionFuture(final @NonNull SchemaPath type, final @NonNull Future<Object> requestFuture) {
21 super(type, requestFuture);
25 DOMActionResult processReply(final Object reply) {
26 if (reply instanceof ActionResponse) {
27 final ActionResponse actionReply = (ActionResponse) reply;
28 final ContainerNode output = actionReply.getOutput();
29 return output == null ? new SimpleDOMActionResult(actionReply.getErrors())
30 : new SimpleDOMActionResult(output, actionReply.getErrors());
37 Class<DOMActionException> exceptionClass() {
38 return DOMActionException.class;
42 DOMActionException wrapCause(final Throwable cause) {
43 return new RemoteDOMActionException("Exception during invoking ACTION", cause);