Update response message for data validation failure

- Make the response message more informative and cleaner in case of data
  validation failure.
- Updated message body will not contain the entire jsonData as part of
  response sent back to the user

Issue-ID: CPS-2306
Change-Id: I28aab1450779af98ccdd11701e78bdfcdbc18cf0
Signed-off-by: Arpit Singh <as00745003@techmahindra.com>
diff --git a/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java b/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java
index 5cadd29..5971645 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/YangParserHelper.java
@@ -120,13 +120,9 @@
 
         try (jsonParserStream) {
             jsonParserStream.parse(jsonReader);
-        } catch (final IOException | JsonSyntaxException exception) {
+        } catch (final IOException | JsonSyntaxException | IllegalStateException | IllegalArgumentException exception) {
             throw new DataValidationException(
-                    "Failed to parse json data: " + jsonData, exception.getMessage(), exception);
-        } catch (final IllegalStateException | IllegalArgumentException exception) {
-            throw new DataValidationException(
-                    "Failed to parse json data. Unsupported xpath or json data:" + jsonData, exception
-                    .getMessage(), exception);
+                    "Data Validation Failed", "Failed to parse json data. " + exception.getMessage(), exception);
         }
         return dataContainerNodeBuilder.build();
     }
@@ -168,7 +164,7 @@
         } catch (final XMLStreamException | URISyntaxException | IOException | SAXException | NullPointerException
                        | ParserConfigurationException | TransformerException exception) {
             throw new DataValidationException(
-                "Failed to parse xml data: " + xmlData, exception.getMessage(), exception);
+                "Data Validation Failed", "Failed to parse xml data: " + exception.getMessage(), exception);
         }
         final DataContainerChild dataContainerChild =
             (DataContainerChild) getFirstChildXmlRoot(normalizedNodeResult.getResult());
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
index 2e38d79..0d3c5aa 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
@@ -132,8 +132,8 @@
         where: 'given parameters'
             scenario        | invalidData     | contentType      || expectedMessage
             'no data nodes' | '{}'            | ContentType.JSON || 'No data nodes'
-            'invalid json'  | '{invalid json' | ContentType.JSON || 'Failed to parse json data'
-            'invalid xml'   | '<invalid xml'  | ContentType.XML  || 'Failed to parse xml data'
+            'invalid json'  | '{invalid json' | ContentType.JSON || 'Data Validation Failed'
+            'invalid xml'   | '<invalid xml'  | ContentType.XML  || 'Data Validation Failed'
     }
 
     def 'Saving list element data fragment under Root node.'() {