Remove RestconfError.ErrorType
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / utils / FutureCallbackTx.java
index e4c88f22a683aa27aa7a4902fc885a1fc0cfe190..f73e9f1713f4d715ca98a23fd855ff10933ba671 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -75,9 +76,7 @@ final class FutureCallbackTx {
     static <T> void addCallback(final ListenableFuture<T> listenableFuture, final String txType,
                                 final FutureDataFactory<? super T> dataFactory,
                                 @Nullable final RestconfStrategy strategy,
-                                final YangInstanceIdentifier path)
-        throws RestconfDocumentedException {
-
+                                final YangInstanceIdentifier path) throws RestconfDocumentedException {
         try {
             final T result = listenableFuture.get();
             dataFactory.setResult(result);
@@ -110,19 +109,18 @@ final class FutureCallbackTx {
                         if (errorTag.equals(DocumentedException.ErrorTag.DATA_EXISTS)) {
                             LOG.trace("Operation via Restconf was not executed because data at {} already exists",
                                 path);
-                            throw new RestconfDocumentedException(e, new RestconfError(RestconfError.ErrorType.PROTOCOL,
+                            throw new RestconfDocumentedException(e, new RestconfError(ErrorType.PROTOCOL,
                                 RestconfError.ErrorTag.DATA_EXISTS, "Data already exists", path));
                         } else if (errorTag.equals(DocumentedException.ErrorTag.DATA_MISSING)) {
                             LOG.trace("Operation via Restconf was not executed because data at {} does not exist",
                                 path);
-                            throw new RestconfDocumentedException(e, new RestconfError(RestconfError.ErrorType.PROTOCOL,
+                            throw new RestconfDocumentedException(e, new RestconfError(ErrorType.PROTOCOL,
                                 RestconfError.ErrorTag.DATA_MISSING, "Data does not exist", path));
                         }
                     }
                     if (error instanceof NetconfDocumentedException) {
                         throw new RestconfDocumentedException(error.getMessage(),
-                                RestconfError.ErrorType.valueOfCaseInsensitive(
-                                        ((NetconfDocumentedException) error).getErrorType().getTypeValue()),
+                                ((NetconfDocumentedException) error).getErrorType(),
                                 RestconfError.ErrorTag.valueOfCaseInsensitive(
                                         ((NetconfDocumentedException) error).getErrorTag().getTagValue()), e);
                     }
@@ -132,10 +130,6 @@ final class FutureCallbackTx {
             } else {
                 throw new RestconfDocumentedException("Transaction failed", e);
             }
-        } finally {
-            if (strategy != null) {
-                strategy.close();
-            }
         }
     }
 }