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 import org.openecomp.mso.logger.MsoLogger;
\r
19 public class DecomposeJsonUtil implements Serializable {
\r
20 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
\r
24 private static final long serialVersionUID = 1L;
\r
27 * Method to construct Service Decomposition object converting
\r
30 * @param jsonString - input in JSON format confirming ServiceDecomposition
\r
31 * @return - ServiceDecomposition object
\r
32 * @throws IOException
\r
33 * @throws JsonMappingException
\r
34 * @throws JsonParseException
\r
36 public static ServiceDecomposition JsonToServiceDecomposition(String jsonString) {
\r
38 ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
\r
39 ObjectMapper om = new ObjectMapper();
\r
40 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
43 serviceDecomposition = om.readValue(jsonString, ServiceDecomposition.class);
\r
44 } catch (JsonParseException e) {
\r
45 LOGGER.debug("JsonParseException :",e);
\r
46 } catch (JsonMappingException e) {
\r
47 LOGGER.debug("JsonMappingException :",e);
\r
48 } catch (IOException e) {
\r
49 LOGGER.debug("IOException :",e);
\r
52 return serviceDecomposition;
\r
56 * Method to construct Resource Decomposition object converting
\r
59 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
60 * @return - ServiceDecomposition object
\r
61 * @throws IOException
\r
62 * @throws JsonMappingException
\r
63 * @throws JsonParseException
\r
65 public static VnfResource JsonToVnfResource(String jsonString) {
\r
67 VnfResource vnfResource = new VnfResource();
\r
68 ObjectMapper om = new ObjectMapper();
\r
69 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
72 vnfResource = om.readValue(jsonString, VnfResource.class);
\r
73 } catch (JsonParseException e) {
\r
74 LOGGER.debug("JsonParseException :",e);
\r
75 } catch (JsonMappingException e) {
\r
76 LOGGER.debug("JsonMappingException :",e);
\r
77 } catch (IOException e) {
\r
78 LOGGER.debug("IOException :",e);
\r
84 * Method to construct Resource Decomposition object converting
\r
87 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
88 * @return - ServiceDecomposition object
\r
89 * @throws IOException
\r
90 * @throws JsonMappingException
\r
91 * @throws JsonParseException
\r
93 public static NetworkResource JsonToNetworkResource(String jsonString) {
\r
95 NetworkResource networkResource = new NetworkResource();
\r
96 ObjectMapper om = new ObjectMapper();
\r
97 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
100 networkResource = om.readValue(jsonString, NetworkResource.class);
\r
101 } catch (JsonParseException e) {
\r
102 LOGGER.debug("Exception :",e);
\r
103 } catch (JsonMappingException e) {
\r
104 LOGGER.debug("Exception :",e);
\r
105 } catch (IOException e) {
\r
106 LOGGER.debug("Exception :",e);
\r
108 return networkResource;
\r
112 * Method to construct Resource Decomposition object converting
\r
115 * @param jsonString - input in JSON format confirming ResourceDecomposition
\r
116 * @return - ServiceDecomposition object
\r
117 * @throws IOException
\r
118 * @throws JsonMappingException
\r
119 * @throws JsonParseException
\r
121 public static AllottedResource JsonToAllottedResource(String jsonString) {
\r
123 AllottedResource allottedResource = new AllottedResource();
\r
124 ObjectMapper om = new ObjectMapper();
\r
125 om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
\r
128 allottedResource = om.readValue(jsonString, AllottedResource.class);
\r
129 } catch (JsonParseException e) {
\r
130 LOGGER.debug("Exception :",e);
\r
131 } catch (JsonMappingException e) {
\r
132 LOGGER.debug("Exception :",e);
\r
133 } catch (IOException e) {
\r
134 LOGGER.debug("Exception :",e);
\r
136 return allottedResource;
\r