Inline checkItemExists()
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / utils / DeleteDataTransactionUtil.java
index 29b2b3cc4b8b32bb14678c9c463178a88d870edb..89dfb3acb81f5c53e401edcbb8a0ad8c253f318e 100644 (file)
@@ -14,19 +14,12 @@ import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfTransaction;
-import org.opendaylight.yangtools.yang.common.ErrorTag;
-import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Util class for delete specific data in config DS.
  */
 public final class DeleteDataTransactionUtil {
-    private static final Logger LOG = LoggerFactory.getLogger(DeleteDataTransactionUtil.class);
-    public static final String DELETE_TX_TYPE = "DELETE";
-
     private DeleteDataTransactionUtil() {
         // Hidden on purpose
     }
@@ -49,28 +42,7 @@ public final class DeleteDataTransactionUtil {
         final FluentFuture<? extends CommitInfo> future = transaction.commit();
         final ResponseFactory response = new ResponseFactory(Status.NO_CONTENT);
         //This method will close transactionChain if any
-        FutureCallbackTx.addCallback(future, DELETE_TX_TYPE, response, path);
+        FutureCallbackTx.addCallback(future, "DELETE", response, path);
         return response.build();
     }
-
-    /**
-     * Check if items already exists at specified {@code path}. Throws {@link RestconfDocumentedException} if
-     * data does NOT already exists.
-     *
-     * @param isExistsFuture if checked data exists
-     * @param path           Path to be checked
-     * @param operationType  Type of operation (READ, POST, PUT, DELETE...)
-     */
-    public static void checkItemExists(final FluentFuture<Boolean> isExistsFuture,
-                                       final YangInstanceIdentifier path,
-                                       final String operationType) {
-        final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
-        FutureCallbackTx.addCallback(isExistsFuture, operationType, response);
-
-        if (!response.result) {
-            LOG.trace("Operation via Restconf was not executed because data at {} does not exist", path);
-            throw new RestconfDocumentedException(
-                "Data does not exist", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, path);
-        }
-    }
 }