Bug 1010: Implement restconf error responses
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / restconf / rpc / impl / MountPointRpcExecutor.java
index b56db21951ee2d2eb01f6e3208ebb8912d0a5530..da19a0034de26103afd793e0ebb4a5d002f3bffa 100644 (file)
@@ -7,18 +7,13 @@
 */
 package org.opendaylight.controller.sal.restconf.rpc.impl;
 
-import java.util.concurrent.ExecutionException;
-
-import javax.ws.rs.core.Response.Status;
-
 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
-import org.opendaylight.controller.sal.restconf.impl.ResponseException;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ListenableFuture;
 
 /**
  * Provides an implementation which invokes rpc methods via a mounted yang data model.
@@ -35,14 +30,8 @@ public class MountPointRpcExecutor extends AbstractRpcExecutor {
     }
 
     @Override
-    public RpcResult<CompositeNode> invokeRpc( CompositeNode rpcRequest ) throws ResponseException {
-        ListenableFuture<RpcResult<CompositeNode>> rpcFuture =
-                mountPoint.rpc( getRpcDefinition().getQName(), rpcRequest);
-        try {
-            return rpcFuture.get();
-        } catch (InterruptedException | ExecutionException e) {
-            throw new ResponseException(Status.INTERNAL_SERVER_ERROR,
-                                        e.getCause().getMessage() );
-        }
+    public RpcResult<CompositeNode> invokeRpc( CompositeNode rpcRequest )
+                                                   throws RestconfDocumentedException {
+        return getRpcResult( mountPoint.rpc( getRpcDefinition().getQName(), rpcRequest ) );
     }
 }
\ No newline at end of file