577b550be6a6a11bc9cd31d3468fc9a8f7238e3d
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.adapters.sdnc.client;
24
25
26 import java.io.StringWriter;
27 import javax.xml.bind.JAXBContext;
28 import javax.xml.bind.Marshaller;
29 import javax.xml.bind.annotation.XmlAccessType;
30 import javax.xml.bind.annotation.XmlAccessorType;
31 import javax.xml.bind.annotation.XmlElement;
32 import javax.xml.bind.annotation.XmlRootElement;
33 import javax.xml.bind.annotation.XmlType;
34 import org.onap.so.logger.LoggingAnchor;
35 import org.onap.so.logger.ErrorCode;
36 import org.onap.so.logger.MessageEnum;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
39
40 /**
41  * <p>
42  * Java class for anonymous complex type.
43  *
44  * <p>
45  * The following schema fragment specifies the expected content contained within this class.
46  *
47  * <pre>
48  * &lt;complexType>
49  *   &lt;complexContent>
50  *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
51  *       &lt;sequence>
52  *         &lt;element ref="{http://org.onap/workflow/sdnc/adapter/schema/v1}CallbackHeader"/>
53  *         &lt;element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
54  *       &lt;/sequence>
55  *     &lt;/restriction>
56  *   &lt;/complexContent>
57  * &lt;/complexType>
58  * </pre>
59  *
60  *
61  */
62 // SDNCAdapter to BPEL Async response
63 @XmlAccessorType(XmlAccessType.FIELD)
64 @XmlType(name = "", propOrder = {"callbackHeader", "requestData"})
65 @XmlRootElement(name = "SDNCAdapterCallbackRequest")
66 public class SDNCAdapterCallbackRequest {
67
68     @XmlElement(name = "CallbackHeader", required = true)
69     protected CallbackHeader callbackHeader;
70     @XmlElement(name = "RequestData")
71     protected Object requestData;
72
73     private static Logger logger = LoggerFactory.getLogger(SDNCAdapterCallbackRequest.class);
74
75     /**
76      * Gets the value of the callbackHeader property.
77      *
78      * @return possible object is {@link CallbackHeader }
79      *
80      */
81     public CallbackHeader getCallbackHeader() {
82         return callbackHeader;
83     }
84
85     /**
86      * Sets the value of the callbackHeader property.
87      *
88      * @param value allowed object is {@link CallbackHeader }
89      *
90      */
91     public void setCallbackHeader(CallbackHeader value) {
92         this.callbackHeader = value;
93     }
94
95     /**
96      * Gets the value of the requestData property.
97      *
98      * @return possible object is {@link Object }
99      *
100      */
101     public Object getRequestData() {
102         return requestData;
103     }
104
105     /**
106      * Sets the value of the requestData property.
107      *
108      * @param value allowed object is {@link Object }
109      *
110      */
111     public void setRequestData(Object value) {
112         this.requestData = value;
113     }
114
115     @Override
116     public String toString() {
117         try {
118             JAXBContext ctx = JAXBContext.newInstance("org.onap.so.adapters.sdnc.client");
119             Marshaller m = ctx.createMarshaller();
120             m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
121             m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
122             StringWriter w = new StringWriter();
123             m.marshal(this, w);
124             return w.toString();
125         } catch (Exception e) {
126             logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR.toString(), ErrorCode.DataError.getValue(),
127                     "Exception - MARSHING_ERROR", e);
128         }
129         return "";
130     }
131 }