X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Frpc%2Fimpl%2FAbstractRpcExecutor.java;h=417cca653365bf96e925925226ee313513a79417;hp=0bc8428d76f85fae184b577040ee4d52f9cc682d;hb=c3acce135d19955f72616c4c956668bb539f80f2;hpb=26da3c2a206a753356b507b018052cbb9cccca7d diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/AbstractRpcExecutor.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/AbstractRpcExecutor.java index 0bc8428d76..417cca6533 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/AbstractRpcExecutor.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/AbstractRpcExecutor.java @@ -30,6 +30,28 @@ public abstract class AbstractRpcExecutor implements RpcExecutor { return rpcDef; } + @Override + public RpcResult invokeRpc( CompositeNode rpcRequest ) + throws RestconfDocumentedException { + try { + return getRpcResult( invokeRpcUnchecked( rpcRequest ) ); + } + catch( IllegalArgumentException e ) { + throw new RestconfDocumentedException( + e.getMessage(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE ); + } + catch( UnsupportedOperationException e ) { + throw new RestconfDocumentedException( + e.getMessage(), ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED ); + } + catch( Exception e ) { + throw new RestconfDocumentedException( + "The operation encountered an unexpected error while executing.", e ); + } + } + + protected abstract Future> invokeRpcUnchecked( CompositeNode rpcRequest ); + protected RpcResult getRpcResult( Future> fromFuture ) { try {