1f166062d17414d3ba7b520d22b6c4f8503372c5
[so.git] / adapters / mso-vfc-adapter / src / main / java / org / openecomp / mso / adapters / vfc / model / NSResourceInputParameter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.openecomp.mso.adapters.vfc.model;
21
22 import java.io.ByteArrayOutputStream;
23
24 import javax.xml.bind.JAXBContext;
25 import javax.xml.bind.Marshaller;
26
27 import org.codehaus.jackson.map.ObjectMapper;
28 import org.codehaus.jackson.map.SerializationConfig;
29 import org.openecomp.mso.logger.MsoLogger;
30
31 /**
32  * NS Create Input Parameter For VFC Adapter<br>
33  * <p>
34  * </p>
35  * 
36  * @version ONAP Amsterdam Release 2017/1/7
37  */
38 public class NSResourceInputParameter {
39
40     private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
41     
42     private NsOperationKey nsOperationKey;
43
44     private String nsServiceName;
45
46     private String nsServiceDescription;
47
48     private NsParameters nsParameters;
49
50
51
52     
53     /**
54      * @return Returns the nsServiceName.
55      */
56     public String getNsServiceName() {
57         return nsServiceName;
58     }
59
60     
61     /**
62      * @param nsServiceName The nsServiceName to set.
63      */
64     public void setNsServiceName(String nsServiceName) {
65         this.nsServiceName = nsServiceName;
66     }
67
68     
69     /**
70      * @return Returns the nsServiceDescription.
71      */
72     public String getNsServiceDescription() {
73         return nsServiceDescription;
74     }
75
76     
77     /**
78      * @param nsServiceDescription The nsServiceDescription to set.
79      */
80     public void setNsServiceDescription(String nsServiceDescription) {
81         this.nsServiceDescription = nsServiceDescription;
82     }
83
84     /**
85      * @return Returns the nsParameters.
86      */
87     public NsParameters getNsParameters() {
88         return nsParameters;
89     }
90
91     /**
92      * @param nsParameters The nsParameters to set.
93      */
94     public void setNsParameters(NsParameters nsParameters) {
95         this.nsParameters = nsParameters;
96     }
97
98     public NsOperationKey getNsOperationKey() {
99         return nsOperationKey;
100     }
101
102     public void setNsOperationKey(NsOperationKey nsOperationKey) {
103         this.nsOperationKey = nsOperationKey;
104     }
105     public String toJsonString() {
106         String jsonString = null;
107         try {
108             ObjectMapper mapper = new ObjectMapper();
109             mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
110             jsonString = mapper.writeValueAsString(this);
111         } catch (Exception e) {
112             LOGGER.debug("Exception:", e);
113         }
114         return jsonString;
115     }
116
117     public String toXmlString() {
118         try {
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);
127             return "";
128         }
129     }
130 }