18c9d49939f4f1685d627c09a53cf3b588db293c
[so.git] / adapters / mso-adapters-rest-interface / src / main / java / org / onap / so / adapters / sdncrest / SDNCServiceResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. 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
21 package org.onap.so.adapters.sdncrest;
22
23 import java.io.Serializable;
24 import java.util.LinkedHashMap;
25 import java.util.Map;
26
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlRootElement;
29
30 import com.fasterxml.jackson.annotation.JsonInclude;
31 import com.fasterxml.jackson.annotation.JsonInclude.Include;
32 import com.fasterxml.jackson.annotation.JsonProperty;
33 import com.fasterxml.jackson.annotation.JsonRootName;
34
35 // NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy,
36 //       even though we are using JSON exclusively.  The @NoJackson annotation
37 //       is also required in this environment.
38
39 /**
40  Map<String, String> elements when marshalled to XML produce a list of <entry><key>${MsoUtils.xmlEscape(key)}</key><value>${MsoUtils.xmlEscape(value)}</value></entry> elements.
41  When marshalling to JSON they create a list of "${key}" : "${value}" pairs with no extra wrappers.
42  * </pre>
43  */
44 @JsonRootName("SDNCServiceResponse")
45 @JsonInclude(Include.NON_NULL)
46 @XmlRootElement(name = "SDNCServiceResponse")
47 public class SDNCServiceResponse extends SDNCResponseCommon implements Serializable {
48         private static final long serialVersionUID = 1L;
49
50         // Map of response parameters (possibly none).
51         private Map<String, String> params = null;
52
53         public SDNCServiceResponse(String sdncRequestId, String responseCode,
54                         String responseMessage, String ackFinalIndicator) {
55                 super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator);
56         }
57
58         public SDNCServiceResponse() {
59         }
60
61         @JsonProperty("params")
62         @XmlElement(name = "params")
63         public Map<String, String> getParams() {
64                 return params;
65         }
66
67         @JsonProperty("params")
68         public void setParams(Map<String, String> params) {
69                 this.params = params;
70         }
71
72         public void addParam(String name, String value) {
73                 if (params == null) {
74                         params = new LinkedHashMap<>();
75                 }
76                 params.put(name, value);
77         }
78 }