- protected ListenableFuture<DOMRpcResult> perfomRequestWithTimeout(String operation, ListenableFuture<DOMRpcResult> future) {
- try {
- future.get(defaultRequestTimeoutMillis, TimeUnit.MILLISECONDS);
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("{}: {} failed with error", operation, id, e);
- return Futures.immediateFailedCheckedFuture(new RuntimeException(id + ": " + operation + " failed"));
- } catch (TimeoutException e) {
- LOG.warn("{}: Unable to {} after {} milliseconds", id, operation, defaultRequestTimeoutMillis, e);
- return Futures.immediateFailedCheckedFuture(new SchemaSourceException(e.getMessage()));
+ return transformed;
+ }
+
+ 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();
+ }