2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.openecomp.mso.adapters.vfc.model;
22 import java.io.ByteArrayOutputStream;
24 import javax.xml.bind.JAXBContext;
25 import javax.xml.bind.Marshaller;
27 import com.fasterxml.jackson.databind.ObjectMapper;
28 import com.fasterxml.jackson.databind.SerializationFeature;
29 import org.openecomp.mso.logger.MsoLogger;
32 * NS Create Input Parameter For VFC Adapter<br>
36 * @version ONAP Amsterdam Release 2017/1/7
38 public class NSResourceInputParameter {
40 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
42 private NsOperationKey nsOperationKey;
44 private String nsServiceName;
46 private String nsServiceDescription;
48 private NsParameters nsParameters;
54 * @return Returns the nsServiceName.
56 public String getNsServiceName() {
62 * @param nsServiceName The nsServiceName to set.
64 public void setNsServiceName(String nsServiceName) {
65 this.nsServiceName = nsServiceName;
70 * @return Returns the nsServiceDescription.
72 public String getNsServiceDescription() {
73 return nsServiceDescription;
78 * @param nsServiceDescription The nsServiceDescription to set.
80 public void setNsServiceDescription(String nsServiceDescription) {
81 this.nsServiceDescription = nsServiceDescription;
85 * @return Returns the nsParameters.
87 public NsParameters getNsParameters() {
92 * @param nsParameters The nsParameters to set.
94 public void setNsParameters(NsParameters nsParameters) {
95 this.nsParameters = nsParameters;
98 public NsOperationKey getNsOperationKey() {
99 return nsOperationKey;
102 public void setNsOperationKey(NsOperationKey nsOperationKey) {
103 this.nsOperationKey = nsOperationKey;
105 public String toJsonString() {
106 String jsonString = null;
108 ObjectMapper mapper = new ObjectMapper();
109 mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
110 jsonString = mapper.writeValueAsString(this);
111 } catch (Exception e) {
112 LOGGER.debug("Exception:", e);
117 public String toXmlString() {
119 ByteArrayOutputStream bs = new ByteArrayOutputStream();
120 JAXBContext context = JAXBContext.newInstance(this.getClass());
121 Marshaller marshaller = context.createMarshaller();
122 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML
123 marshaller.marshal(this, bs);
124 return bs.toString();
125 } catch (Exception e) {
126 LOGGER.debug("Exception:", e);