2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
6 * Copyright (C) 2018 CMCC All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.adapters.vfc.model;
23 import java.io.ByteArrayOutputStream;
25 import javax.xml.bind.JAXBContext;
26 import javax.xml.bind.Marshaller;
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import com.fasterxml.jackson.databind.SerializationFeature;
30 import org.openecomp.mso.logger.MsoLogger;
33 * NS Create Input Parameter For VFC Adapter<br>
37 * @version ONAP Amsterdam Release 2017/1/7
39 public class NSResourceInputParameter {
41 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
43 private NsOperationKey nsOperationKey;
45 private String nsServiceName;
47 private String nsServiceDescription;
49 private NsParameters nsParameters;
51 private NsScaleParameters nsScaleParameters;
55 * @return Returns the nsServiceName.
57 public String getNsServiceName() {
63 * @param nsServiceName The nsServiceName to set.
65 public void setNsServiceName(String nsServiceName) {
66 this.nsServiceName = nsServiceName;
71 * @return Returns the nsServiceDescription.
73 public String getNsServiceDescription() {
74 return nsServiceDescription;
79 * @param nsServiceDescription The nsServiceDescription to set.
81 public void setNsServiceDescription(String nsServiceDescription) {
82 this.nsServiceDescription = nsServiceDescription;
86 * @return Returns the nsParameters.
88 public NsParameters getNsParameters() {
93 * @param nsParameters The nsParameters to set.
95 public void setNsParameters(NsParameters nsParameters) {
96 this.nsParameters = nsParameters;
99 public NsOperationKey getNsOperationKey() {
100 return nsOperationKey;
103 public void setNsOperationKey(NsOperationKey nsOperationKey) {
104 this.nsOperationKey = nsOperationKey;
106 public String toJsonString() {
107 String jsonString = null;
109 ObjectMapper mapper = new ObjectMapper();
110 mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
111 jsonString = mapper.writeValueAsString(this);
112 } catch (Exception e) {
113 LOGGER.debug("Exception:", e);
118 public String toXmlString() {
120 ByteArrayOutputStream bs = new ByteArrayOutputStream();
121 JAXBContext context = JAXBContext.newInstance(this.getClass());
122 Marshaller marshaller = context.createMarshaller();
123 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML
124 marshaller.marshal(this, bs);
125 return bs.toString();
126 } catch (Exception e) {
127 LOGGER.debug("Exception:", e);
132 public NsScaleParameters getNsScaleParameters() {
133 return nsScaleParameters;
136 public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
137 this.nsScaleParameters = nsScaleParameters;