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