2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.so.adapters.network;
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;
34 public class ContrailPolicyRef {
36 private static final Logger logger = LoggerFactory.getLogger(ContrailPolicyRef.class);
38 @JsonProperty("network_policy_refs_data_sequence")
39 private ContrailPolicyRefSeq seq;
41 public JsonNode toJsonNode() {
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);
54 public String toJsonString() {
55 String jsonString = null;
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);
67 public void populate(String major, String minor) {
68 seq = new ContrailPolicyRefSeq(major, minor);