+ private void extractResult(final List<DOMRpcResult> domRpcResults,
+ final SettableFuture<RpcResult<Void>> transformed) {
+ DocumentedException.ErrorType errType = DocumentedException.ErrorType.APPLICATION;
+ DocumentedException.ErrorSeverity errSeverity = DocumentedException.ErrorSeverity.ERROR;
+ StringBuilder msgBuilder = new StringBuilder();
+ boolean errorsEncouneterd = false;
+ String errorTag = "operation-failed";
+
+ for (final DOMRpcResult domRpcResult : domRpcResults) {
+ if (!domRpcResult.getErrors().isEmpty()) {
+ errorsEncouneterd = true;
+ final RpcError error = domRpcResult.getErrors().iterator().next();
+ final RpcError.ErrorType errorType = error.getErrorType();
+ switch (errorType) {
+ case RPC:
+ errType = DocumentedException.ErrorType.RPC;
+ break;
+ case PROTOCOL:
+ errType = DocumentedException.ErrorType.PROTOCOL;
+ break;
+ case TRANSPORT:
+ errType = DocumentedException.ErrorType.TRANSPORT;
+ break;
+ case APPLICATION:
+ errType = DocumentedException.ErrorType.APPLICATION;
+ break;
+ default:
+ errType = DocumentedException.ErrorType.APPLICATION;
+ break;
+ }
+ final RpcError.ErrorSeverity severity = error.getSeverity();
+ switch (severity) {
+ case ERROR:
+ errSeverity = DocumentedException.ErrorSeverity.ERROR;
+ break;
+ case WARNING:
+ errSeverity = DocumentedException.ErrorSeverity.WARNING;
+ break;
+ default:
+ errSeverity = DocumentedException.ErrorSeverity.ERROR;
+ break;
+ }
+ msgBuilder.append(error.getMessage());
+ errorTag = error.getTag();
+ }
+ }
+ if (errorsEncouneterd) {
+ final NetconfDocumentedException exception = new NetconfDocumentedException(id
+ + ":RPC during tx failed. " + msgBuilder.toString(),
+ errType,
+ DocumentedException.ErrorTag.from(errorTag),
+ errSeverity);
+ transformed.setException(exception);
+ return;
+ }
+ transformed.set(RpcResultBuilder.<Void>success().build());
+ }
+