AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCoreBPMN / src / main / java / org / openecomp / mso / bpmn / core / json / DecomposeJsonUtil.java
index dcd9e3b..8ab93f2 100644 (file)
 \r
 package org.openecomp.mso.bpmn.core.json;\r
 \r
-import com.fasterxml.jackson.databind.DeserializationFeature;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
 import java.io.IOException;\r
+import java.io.Serializable;\r
+\r
 import org.openecomp.mso.bpmn.core.domain.AllottedResource;\r
+import org.openecomp.mso.bpmn.core.domain.ConfigResource;\r
 import org.openecomp.mso.bpmn.core.domain.NetworkResource;\r
 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;\r
 import org.openecomp.mso.bpmn.core.domain.ServiceInstance;\r
 import org.openecomp.mso.bpmn.core.domain.VnfResource;\r
 \r
-public class DecomposeJsonUtil {\r
+import com.fasterxml.jackson.databind.DeserializationFeature;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+public class DecomposeJsonUtil implements Serializable {\r
+\r
+       private static final long serialVersionUID = 1L;\r
 \r
     private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();\r
 \r
@@ -51,7 +57,10 @@ public class DecomposeJsonUtil {
      */\r
     public static ServiceDecomposition jsonToServiceDecomposition(String jsonString) throws JsonDecomposingException {\r
         try {\r
-            return OBJECT_MAPPER.readValue(jsonString, ServiceDecomposition.class);\r
+                       ObjectMapper om = new ObjectMapper();\r
+                       om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);\r
+                       om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\r
+            return om.readValue(jsonString, ServiceDecomposition.class);\r
         } catch (IOException e) {\r
             throw new JsonDecomposingException("Exception while converting json to service decomposition", e);\r
         }\r
@@ -118,4 +127,12 @@ public class DecomposeJsonUtil {
             throw new JsonDecomposingException("Exception while converting json to allotted resource", e);\r
         }\r
     }\r
+    \r
+    public static ConfigResource jsonToConfigResource(String jsonString) throws JsonDecomposingException {\r
+        try {\r
+            return OBJECT_MAPPER.readValue(jsonString, ConfigResource.class);\r
+        } catch (IOException e) {\r
+            throw new JsonDecomposingException("Exception while converting json to allotted resource", e);\r
+        }\r
+    }\r
 }
\ No newline at end of file