diff options
author | 2018-04-03 17:28:44 +0100 | |
---|---|---|
committer | 2018-04-03 17:28:44 +0100 | |
commit | 7b1f813441f94261f43ec4f5bb0944ad2570fbdf (patch) | |
tree | 7c5a2d1f378b2a0b358905e82d21cce73f3e1d6d /src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java | |
parent | 4dd316529148d07059d844197cdb676806bdc0c6 (diff) |
Revisions made to the Model Loader to use Babel
Change the Model Loader to use the Babel micro service.
Responsibility for transformation of ASDC TOSCA models,
the yaml files, has been moved from ASDC and placed into
the Bable microservice. Model Loader will forward any
CSAR received from ASDC and delegate transformation to
Babel. Babel will return the transformed TOSCA models
to Model Loader which will then ingest them into the
A&AI Inventory.
Issue-ID: AAI-987
Change-Id: I99594770b51b00cb7dcc0f30706060ae27cd94c5
Signed-off-by: Blackwell, Ian (ib733q) <IanB@amdocs.com>
Diffstat (limited to 'src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java')
-rw-r--r-- | src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java | 85 |
1 files changed, 40 insertions, 45 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java b/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java index 29a4409..a5a7bc5 100644 --- a/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java +++ b/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java @@ -27,53 +27,48 @@ import org.json.XML; public class JsonXmlConverter {
- /**
- * Determines whether or not the supplied text string represents a valid
- * JSON structure or not.
- *
- * @param text - The text to be evaluated.
- *
- * @return - true if the string represents a valid JSON object,
- * false, otherwise.
- */
- public static boolean isValidJson(String text) {
- try {
- new JSONObject(text);
- } catch (JSONException ex) {
- try {
- new JSONArray(text);
- } catch (JSONException ex1) {
- return false;
- }
+ private JsonXmlConverter() {
+ throw new AssertionError("Instantiating utility class.");
}
- return true;
- }
+ /**
+ * Determines whether or not the supplied text string represents a valid JSON structure or not.
+ *
+ * @param text The text to be evaluated.
+ * @return - true if the string represents a valid JSON object, false, otherwise.
+ */
+ public static boolean isValidJson(String text) {
+ try {
+ new JSONObject(text);
+ } catch (JSONException ex) {
+ try {
+ new JSONArray(text);
+ } catch (JSONException ex1) {
+ return false;
+ }
+ }
- /**
- * Takes a text string representing a valid JSON structure and converts it to
- * an equivalent XML string.
- *
- * @param jsonText - The JSON string to convert to XML.
- *
- * @return - An XML string representation of the supplied JSON string.
- */
- public static String convertJsonToXml(String jsonText) {
- JSONObject jsonObj = new JSONObject(jsonText);
- String xmlText = XML.toString(jsonObj);
- return xmlText;
- }
+ return true;
+ }
+
+ /**
+ * Takes a text string representing a valid JSON structure and converts it to an equivalent XML string.
+ *
+ * @param jsonText The JSON string to convert to XML.
+ * @return an XML string representation of the supplied JSON string.
+ */
+ public static String convertJsonToXml(String jsonText) {
+ return XML.toString(new JSONObject(jsonText));
+ }
- /**
- * Takes a text string representing a valid XML structure and converts it to
- * an equivalent JSON string.
- *
- * @param xmlText - The XML string to convert to JSON.
- *
- * @return - A JSON string representation of the supplied XML string.
- */
- public static String convertXmlToJson(String xmlText) {
- JSONObject jsonObj = XML.toJSONObject(xmlText);
- return jsonObj.toString();
- }
+ /**
+ * Takes a text string representing a valid XML structure and converts it to an equivalent JSON string.
+ *
+ * @param xmlText The XML string to convert to JSON.
+ * @return a JSON string representation of the supplied XML string.
+ */
+ public static String convertXmlToJson(String xmlText) {
+ JSONObject jsonObj = XML.toJSONObject(xmlText);
+ return jsonObj.toString();
+ }
}
|