import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.netconf.api.DocumentedException;
final Collection<? extends RpcError> errors = result.getErrors();
if (!allWarnings(errors)) {
Futures.whenAllComplete(discardAndUnlock()).run(
- () -> commitResult.setException(mapRpcErrorsToNetconfDocException(errors)),
+ () -> commitResult.setException(toCommitFailedException(errors)),
MoreExecutors.directExecutor());
return;
}
MoreExecutors.directExecutor());
} else {
Futures.whenAllComplete(discardAndUnlock()).run(
- () -> commitResult.setException(mapRpcErrorsToNetconfDocException(errors)),
+ () -> commitResult.setException(toCommitFailedException(errors)),
MoreExecutors.directExecutor());
}
}
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static NetconfDocumentedException mapRpcErrorsToNetconfDocException(
- final Collection<? extends RpcError> errors) {
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
+ private static TransactionCommitFailedException toCommitFailedException(
+ final Collection<? extends RpcError> errors) {
DocumentedException.ErrorType errType = DocumentedException.ErrorType.APPLICATION;
DocumentedException.ErrorSeverity errSeverity = DocumentedException.ErrorSeverity.ERROR;
StringJoiner msgBuilder = new StringJoiner(" ");
String errorTag = "operation-failed";
for (final RpcError error : errors) {
- final RpcError.ErrorType errorType = error.getErrorType();
- switch (errorType) {
+ switch (error.getErrorType()) {
case RPC:
errType = DocumentedException.ErrorType.RPC;
break;
errType = DocumentedException.ErrorType.APPLICATION;
break;
}
- final RpcError.ErrorSeverity severity = error.getSeverity();
- switch (severity) {
+ switch (error.getSeverity()) {
case WARNING:
errSeverity = DocumentedException.ErrorSeverity.WARNING;
break;
msgBuilder.add(error.getInfo());
errorTag = error.getTag();
}
- return new NetconfDocumentedException("RPC during tx failed. " + msgBuilder.toString(), errType,
- DocumentedException.ErrorTag.from(errorTag), errSeverity);
+
+ return new TransactionCommitFailedException("Netconf transaction commit failed",
+ new NetconfDocumentedException("RPC during tx failed. " + msgBuilder.toString(), errType,
+ DocumentedException.ErrorTag.from(errorTag), errSeverity));
}
private static void executeWithLogging(final Supplier<ListenableFuture<? extends DOMRpcResult>> operation) {