0504627377545bda939c878b8a4cdd2ebd0ce2a2
[so.git] / adapters / mso-network-adapter / src / main / java / org / openecomp / mso / adapters / network / ContrailPolicyRef.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.adapters.network;
22
23
24 import org.codehaus.jackson.JsonNode;
25 import org.codehaus.jackson.annotate.JsonProperty;
26 import org.codehaus.jackson.map.ObjectMapper;
27
28 import org.openecomp.mso.logger.MessageEnum;
29 import org.openecomp.mso.logger.MsoLogger;
30
31 public class ContrailPolicyRef {
32         private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
33          
34         @JsonProperty("network_policy_refs_data_sequence")
35         private ContrailPolicyRefSeq seq;
36         
37         public JsonNode toJsonNode()
38         {
39                 JsonNode node = null;
40                 try
41                 {
42                         ObjectMapper mapper = new ObjectMapper(); 
43                         node = mapper.convertValue(this, JsonNode.class);
44                 }
45                 catch (Exception e)
46                 {
47                         logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e);
48                 }
49                 
50                 return node;
51         }
52         
53         public String toJsonString()
54         {
55                 String jsonString = null;
56                 try
57                 {
58                         ObjectMapper mapper = new ObjectMapper(); 
59                         jsonString = mapper.writeValueAsString(this);
60                 }
61                 catch (Exception e)
62                 {
63                         logger.error (MessageEnum.RA_MARSHING_ERROR, "Error creating JsonString for Contrail Policy Ref", "", "", MsoLogger.ErrorCode.SchemaError, "Exception creating JsonString for Contrail Policy Ref", e);
64                 }
65                 
66                 return jsonString;
67         }
68         
69         public void populate(String major, String minor)
70         {
71                 seq = new ContrailPolicyRefSeq(major, minor);
72                 return;
73         }
74         
75 }