1 package org.openecomp.mso.bpmn.core.json;
\r
3 import java.io.Serializable;
\r
4 import java.io.IOException;
\r
7 import org.openecomp.mso.bpmn.core.domain.AllottedResource;
\r
8 import org.openecomp.mso.bpmn.core.domain.NetworkResource;
\r
9 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
\r
10 import org.openecomp.mso.bpmn.core.domain.VnfResource;
\r
12 import com.fasterxml.jackson.core.JsonParseException;
\r
13 import com.fasterxml.jackson.databind.DeserializationFeature;
\r
14 import com.fasterxml.jackson.databind.JsonMappingException;
\r
15 import com.fasterxml.jackson.databind.ObjectMapper;
\r
17 public class DecomposeJsonUtil implements Serializable {
\r
22 private static final long serialVersionUID = 1L;
\r
25 * Method to construct Service Decomposition object converting
\r
28 * @param jsonString - input in JSON format confirming ServiceDecomposition
\r
29 * @return - ServiceDecomposition object
\r
30 * @throws IOException
\r
31 * @throws JsonMappingException
\r
32 * @throws JsonParseException
\r
34 public static ServiceDecomposition JsonToServiceDecomposition(String jsonString) {
\r
36 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
\r
37 ObjectMapper om = new ObjectMapper();
\r
38 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
41 serviceDecomposition = om.readValue(jsonString, ServiceDecomposition.class);
\r
42 } catch (JsonParseException e) {
\r
43 // TODO Auto-generated catch block
\r
44 e.printStackTrace();
\r
45 } catch (JsonMappingException e) {
\r
46 // TODO Auto-generated catch block
\r
47 e.printStackTrace();
\r
48 } catch (IOException e) {
\r
49 // TODO Auto-generated catch block
\r
50 e.printStackTrace();
\r
53 return serviceDecomposition;
\r
57 * Method to construct Resource Decomposition object converting
\r
60 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
61 * @return - ServiceDecomposition object
\r
62 * @throws IOException
\r
63 * @throws JsonMappingException
\r
64 * @throws JsonParseException
\r
66 public static VnfResource JsonToVnfResource(String jsonString) {
\r
68 VnfResource vnfResource = new VnfResource();
\r
69 ObjectMapper om = new ObjectMapper();
\r
70 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
73 vnfResource = om.readValue(jsonString, VnfResource.class);
\r
74 } catch (JsonParseException e) {
\r
75 // TODO Auto-generated catch block
\r
76 e.printStackTrace();
\r
77 } catch (JsonMappingException e) {
\r
78 // TODO Auto-generated catch block
\r
79 e.printStackTrace();
\r
80 } catch (IOException e) {
\r
81 // TODO Auto-generated catch block
\r
82 e.printStackTrace();
\r
88 * Method to construct Resource Decomposition object converting
\r
91 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
92 * @return - ServiceDecomposition object
\r
93 * @throws IOException
\r
94 * @throws JsonMappingException
\r
95 * @throws JsonParseException
\r
97 public static NetworkResource JsonToNetworkResource(String jsonString) {
\r
99 NetworkResource networkResource = new NetworkResource();
\r
100 ObjectMapper om = new ObjectMapper();
\r
101 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
104 networkResource = om.readValue(jsonString, NetworkResource.class);
\r
105 } catch (JsonParseException e) {
\r
106 // TODO Auto-generated catch block
\r
107 e.printStackTrace();
\r
108 } catch (JsonMappingException e) {
\r
109 // TODO Auto-generated catch block
\r
110 e.printStackTrace();
\r
111 } catch (IOException e) {
\r
112 // TODO Auto-generated catch block
\r
113 e.printStackTrace();
\r
115 return networkResource;
\r
119 * Method to construct Resource Decomposition object converting
\r
122 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
123 * @return - ServiceDecomposition object
\r
124 * @throws IOException
\r
125 * @throws JsonMappingException
\r
126 * @throws JsonParseException
\r
128 public static AllottedResource JsonToAllottedResource(String jsonString) {
\r
130 AllottedResource allottedResource = new AllottedResource();
\r
131 ObjectMapper om = new ObjectMapper();
\r
132 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
135 allottedResource = om.readValue(jsonString, AllottedResource.class);
\r
136 } catch (JsonParseException e) {
\r
137 // TODO Auto-generated catch block
\r
138 e.printStackTrace();
\r
139 } catch (JsonMappingException e) {
\r
140 // TODO Auto-generated catch block
\r
141 e.printStackTrace();
\r
142 } catch (IOException e) {
\r
143 // TODO Auto-generated catch block
\r
144 e.printStackTrace();
\r
146 return allottedResource;
\r