Remove RestconfDataServiceConstant.PatchData 82/93082/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 15 Oct 2020 15:21:13 +0000 (17:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 15 Oct 2020 15:35:39 +0000 (17:35 +0200)
This is a useless holder class for a constant which should be private.
Move the string constant and remove the class.

Change-Id: Ic8d9c6f9be5bea1dc828470601bd6fb14dd6dabd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtil.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfDataServiceConstant.java

index 09e3dbcc2f333b45d408abecb66f4ab4d0a49a58..f9d2f371b90ff60364a18c566bee833c7dc21291 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.restconf.common.patch.PatchEntity;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
 import org.opendaylight.restconf.common.patch.PatchStatusEntity;
 import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy;
-import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfDataServiceConstant.PatchData;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
@@ -37,6 +36,8 @@ import org.slf4j.LoggerFactory;
 
 public final class PatchDataTransactionUtil {
     private static final Logger LOG = LoggerFactory.getLogger(PatchDataTransactionUtil.class);
+    // FIXME: why is this used from other contexts?
+    static final String PATCH_TX_TYPE = "Patch";
 
     private PatchDataTransactionUtil() {
         throw new UnsupportedOperationException("Util class.");
@@ -134,7 +135,7 @@ public final class PatchDataTransactionUtil {
 
             try {
                 //This method will close transactionChain if any
-                FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response, strategy.getTransactionChain());
+                FutureCallbackTx.addCallback(future, PATCH_TX_TYPE, response, strategy.getTransactionChain());
             } catch (final RestconfDocumentedException e) {
                 // if errors occurred during transaction commit then patch failed and global errors are reported
                 return new PatchStatusContext(context.getPatchId(), ImmutableList.copyOf(editCollection), false,
@@ -182,7 +183,7 @@ public final class PatchDataTransactionUtil {
         final FluentFuture<Boolean> future = strategy.exists(dataStore, path);
         final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
 
-        FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
+        FutureCallbackTx.addCallback(future, PATCH_TX_TYPE, response);
 
         if (!response.result) {
             LOG.trace("Operation via Restconf was not executed because data at {} does not exist", path);
@@ -304,7 +305,7 @@ public final class PatchDataTransactionUtil {
         final FluentFuture<Boolean> future = strategy.exists(store, path);
         final FutureDataFactory<Boolean> response = new FutureDataFactory<>();
 
-        FutureCallbackTx.addCallback(future, PatchData.PATCH_TX_TYPE, response);
+        FutureCallbackTx.addCallback(future, PATCH_TX_TYPE, response);
 
         if (response.result) {
             LOG.trace("Operation via Restconf was not executed because data at {} already exists", path);
index a4ab1bcaeaa8ce97c548c3a6726c985f6ff523fc..88f463077c9975313a62c9f4463804660547c7d9 100644 (file)
@@ -62,7 +62,7 @@ public final class PlainPatchDataTransactionUtil {
         final FluentFuture<? extends CommitInfo> future = strategy.commit();
         final ResponseFactory response = new ResponseFactory(Status.OK);
 
-        FutureCallbackTx.addCallback(future, RestconfDataServiceConstant.PatchData.PATCH_TX_TYPE, response,
+        FutureCallbackTx.addCallback(future, PatchDataTransactionUtil.PATCH_TX_TYPE, response,
                 strategy.getTransactionChain()); // closes transactionChain if any, may throw
 
         return response.build();
index 21567abf59f80ec2711a7035910de6ba4f0d8b72..b336b8a7691d668efc60005f16d4e66992246587 100644 (file)
@@ -107,16 +107,4 @@ public final class RestconfDataServiceConstant {
             // Hidden on purpose
         }
     }
-
-    /**
-     * Constants for data to yang patch.
-     *
-     */
-    public static final class PatchData {
-        public static final String PATCH_TX_TYPE = "Patch";
-
-        private PatchData() {
-            throw new UnsupportedOperationException("Util class.");
-        }
-    }
 }