Replaced all tabs with spaces in java and pom.xml
[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         JsonNode node = null;
43         try {
44             ObjectMapper mapper = new ObjectMapper();
45             node = mapper.convertValue(this, JsonNode.class);
46         } catch (Exception e) {
47             logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR,
48                     ErrorCode.SchemaError.getValue(), e);
49         }
50
51         return node;
52     }
53
54     public String toJsonString() {
55         String jsonString = null;
56         try {
57             ObjectMapper mapper = new ObjectMapper();
58             jsonString = mapper.writeValueAsString(this);
59         } catch (Exception e) {
60             logger.error("{} {} Error creating JsonString for Contrail Policy Ref: ", MessageEnum.RA_MARSHING_ERROR,
61                     ErrorCode.SchemaError.getValue(), e);
62         }
63
64         return jsonString;
65     }
66
67     public void populate(String major, String minor) {
68         seq = new ContrailPolicyRefSeq(major, minor);
69         return;
70     }
71
72 }