Fixed POST data error response
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / RestconfDataServiceImpl.java
index 075fd1a09dcbeab16814071f8a1bc8466d10c7cd..87b20ee86bf8734a32f131d066cbb11dd93fbb35 100644 (file)
@@ -240,11 +240,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
 
     private static void checkQueryParams(final boolean insertUsed, final boolean pointUsed, final String insert) {
         if (pointUsed && !insertUsed) {
-            throw new RestconfDocumentedException("Point parameter can't be used without Insert parameter.");
+            throw new RestconfDocumentedException("Point parameter can't be used without Insert parameter.",
+                    RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
         }
         if (pointUsed && (insert.equals("first") || insert.equals("last"))) {
             throw new RestconfDocumentedException(
-                    "Point parameter can be used only with 'after' or 'before' values of Insert parameter.");
+                    "Point parameter can be used only with 'after' or 'before' values of Insert parameter.",
+                    RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
         }
     }
 
@@ -269,7 +271,8 @@ public class RestconfDataServiceImpl implements RestconfDataService {
                         insertUsed = true;
                         insert = entry.getValue().iterator().next();
                     } else {
-                        throw new RestconfDocumentedException("Insert parameter can be used only once.");
+                        throw new RestconfDocumentedException("Insert parameter can be used only once.",
+                                RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
                     }
                     break;
                 case "point":
@@ -277,11 +280,13 @@ public class RestconfDataServiceImpl implements RestconfDataService {
                         pointUsed = true;
                         point = entry.getValue().iterator().next();
                     } else {
-                        throw new RestconfDocumentedException("Point parameter can be used only once.");
+                        throw new RestconfDocumentedException("Point parameter can be used only once.",
+                                RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
                     }
                     break;
                 default:
-                    throw new RestconfDocumentedException("Bad parameter for post: " + entry.getKey());
+                    throw new RestconfDocumentedException("Bad parameter for post: " + entry.getKey(),
+                            RestconfError.ErrorType.PROTOCOL, RestconfError.ErrorTag.BAD_ELEMENT);
             }
         }