Bug 5509 - HTTP Patch in Restconf doesn't support general absolute or relative target... 57/42457/9
authorIvan Hrasko <ihrasko@cisco.com>
Mon, 25 Jul 2016 10:12:07 +0000 (12:12 +0200)
committerIvan Hrasko <ihrasko@cisco.com>
Fri, 29 Jul 2016 08:17:21 +0000 (08:17 +0000)
- dependencies shared between XML and JSON PATCH implementations

Change-Id: Ia649763379fab03019ddfd16eac564da576cb35b
Signed-off-by: Ivan Hrasko <ihrasko@cisco.com>
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/PATCHEditOperation.java

index d7b4ebd1dd0af7abb4b06286050e297e33114b3e..da98193f230090aec00010cb013adae2a9944804 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.netconf.sal.restconf.impl;
 
+import javax.annotation.Nonnull;
+
 /**
  *
  * Each YANG patch edit specifies one edit operation on the target data
@@ -22,5 +24,25 @@ public enum PATCHEditOperation {
     MERGE,
     MOVE,    //delete+post
     REPLACE, //put
-    REMOVE   //delete
-}
+    REMOVE;  //delete
+
+    /**
+     * Not all patch operations support value node. Check if operation requires value or not.
+     * @param operation Name of the operation to be checked
+     * @return true if operation requires value, false otherwise
+     */
+    public static final boolean isPatchOperationWithValue(@Nonnull final String operation) {
+        switch (PATCHEditOperation.valueOf(operation.toUpperCase())) {
+            case CREATE:
+                // fall through
+            case MERGE:
+                // fall through
+            case REPLACE:
+                // fall through
+            case INSERT:
+                return true;
+            default:
+                return false;
+        }
+    }
+}
\ No newline at end of file