2  * ============LICENSE_START=======================================================
 
   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
 
  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.sdncrest;
 
  22 import org.openecomp.mso.adapters.json.MapDeserializer;
 
  23 import org.openecomp.mso.adapters.json.MapSerializer;
 
  24 import org.codehaus.jackson.annotate.JsonProperty;
 
  25 import org.codehaus.jackson.map.annotate.JsonDeserialize;
 
  26 import org.codehaus.jackson.map.annotate.JsonRootName;
 
  27 import org.codehaus.jackson.map.annotate.JsonSerialize;
 
  28 import org.jboss.resteasy.annotations.providers.NoJackson;
 
  30 import javax.xml.bind.annotation.XmlElement;
 
  31 import javax.xml.bind.annotation.XmlRootElement;
 
  32 import java.io.Serializable;
 
  33 import java.util.LinkedHashMap;
 
  36 // NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy,
 
  37 //       even though we are using JSON exclusively.  The @NoJackson annotation
 
  38 //       is also required in this environment.
 
  41  * SDNC adapter success response for "agnostic" API services. Note that the
 
  42  * map of response parameters is represented this way in JSON:
 
  46  *     {"key": "P1", "value": "V1"},
 
  47  *     {"key": "P2", "value": "V2"},
 
  49  *     {"key": "PN", "value": "VN"}
 
  54 @JsonRootName("SDNCServiceResponse")
 
  55 @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
 
  56 @XmlRootElement(name = "SDNCServiceResponse")
 
  58 public class SDNCServiceResponse extends SDNCResponseCommon implements Serializable {
 
  59         private static final long serialVersionUID = 1L;
 
  61         // Map of response parameters (possibly none).
 
  62         private Map<String, String> params = null;
 
  64         public SDNCServiceResponse(String sdncRequestId, String responseCode,
 
  65                         String responseMessage, String ackFinalIndicator) {
 
  66                 super(sdncRequestId, responseCode, responseMessage, ackFinalIndicator);
 
  69         public SDNCServiceResponse() {
 
  72         @JsonProperty("params")
 
  73         @JsonDeserialize(using = MapDeserializer.class)
 
  74         @XmlElement(name = "params")
 
  75         public Map<String, String> getParams() {
 
  79         @JsonProperty("params")
 
  80         @JsonSerialize(using = MapSerializer.class, include=JsonSerialize.Inclusion.NON_NULL)
 
  81         public void setParams(Map<String, String> params) {
 
  85         public void addParam(String name, String value) {
 
  87                         params = new LinkedHashMap<String, String>();
 
  89                 params.put(name, value);