Removed MsoLogger class
[so.git] / adapters / mso-openstack-adapters / src / main / java / org / onap / so / 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  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.adapters.network;
24
25
26 import com.fasterxml.jackson.annotation.JsonProperty;
27 import com.fasterxml.jackson.databind.JsonNode;
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import org.onap.so.logger.ErrorCode;
30 import org.onap.so.logger.MessageEnum;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 public class ContrailPolicyRef {
35
36     private static final Logger logger = LoggerFactory.getLogger(ContrailPolicyRef.class);
37          
38         @JsonProperty("network_policy_refs_data_sequence")
39         private ContrailPolicyRefSeq seq;
40         
41         public JsonNode toJsonNode()
42         {
43                 JsonNode node = null;
44                 try
45                 {
46                         ObjectMapper mapper = new ObjectMapper(); 
47                         node = mapper.convertValue(this, JsonNode.class);
48                 }
49                 catch (Exception e)
50                 {
51         logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR,
52             ErrorCode.SchemaError.getValue(), e);
53                 }
54                 
55                 return node;
56         }
57         
58         public String toJsonString()
59         {
60                 String jsonString = null;
61                 try
62                 {
63                         ObjectMapper mapper = new ObjectMapper(); 
64                         jsonString = mapper.writeValueAsString(this);
65                 }
66                 catch (Exception e)
67                 {
68         logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR,
69             ErrorCode.SchemaError.getValue(), e);
70                 }
71                 
72                 return jsonString;
73         }
74         
75         public void populate(String major, String minor)
76         {
77                 seq = new ContrailPolicyRefSeq(major, minor);
78                 return;
79         }
80         
81 }