Change the header to SO
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / openecomp / mso / bpmn / common / workflow / service / VnfAdapterNotifyServiceImpl.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package org.openecomp.mso.bpmn.common.workflow.service;\r
22 \r
23 import javax.jws.Oneway;\r
24 import javax.jws.WebMethod;\r
25 import javax.jws.WebParam;\r
26 import javax.jws.WebService;\r
27 import javax.ws.rs.core.Context;\r
28 import javax.xml.ws.Action;\r
29 import javax.xml.ws.RequestWrapper;\r
30 import javax.xml.ws.WebServiceContext;\r
31 \r
32 import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification;\r
33 import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification;\r
34 import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory;\r
35 import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification;\r
36 import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification;\r
37 import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification;\r
38 import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify;\r
39 import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback;\r
40 import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus;\r
41 import org.openecomp.mso.logger.MsoLogger;\r
42 \r
43 /**\r
44  * Implementation of the VnfAdapterNotify service.\r
45  */\r
46 @WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify")\r
47 public class VnfAdapterNotifyServiceImpl extends AbstractCallbackService implements VnfAdapterNotify{\r
48 \r
49         private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
50
51         private final String logMarker = "[VNF-NOTIFY]";\r
52 \r
53         @Context WebServiceContext wsContext;\r
54 \r
55     @WebMethod(operationName = "rollbackVnfNotification")\r
56     @Oneway\r
57     @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification")\r
58     @Action(input = "http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest")
59     public void rollbackVnfNotification(\r
60         @WebParam(name = "messageId", targetNamespace = "")\r
61         String messageId,\r
62         @WebParam(name = "completed", targetNamespace = "")\r
63         boolean completed,\r
64         @WebParam(name = "exception", targetNamespace = "")\r
65         MsoExceptionCategory exception,\r
66         @WebParam(name = "errorMessage", targetNamespace = "")\r
67         String errorMessage) {\r
68 \r
69                 RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification();\r
70 \r
71                 rollbackVnfNotification.setMessageId(messageId);\r
72                 rollbackVnfNotification.setCompleted(completed);\r
73                 rollbackVnfNotification.setException(exception);\r
74                 rollbackVnfNotification.setErrorMessage(errorMessage);\r
75 \r
76                 String method = "rollbackVnfNotification";\r
77                 Object message = rollbackVnfNotification;\r
78                 String messageEventName = "rollbackVnfNotificationCallback";\r
79                 String messageVariable = "rollbackVnfNotificationCallback";\r
80                 String correlationVariable = "VNFRB_messageId";\r
81                 String correlationValue = messageId;\r
82 \r
83                 handleCallback(method, message, messageEventName, messageVariable,\r
84                         correlationVariable, correlationValue, logMarker);\r
85     }\r
86 \r
87     @WebMethod(operationName = "queryVnfNotification")\r
88     @Oneway\r
89     @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification")
90     @Action(input = "http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest")
91     public void queryVnfNotification(\r
92         @WebParam(name = "messageId", targetNamespace = "")\r
93         String messageId,\r
94         @WebParam(name = "completed", targetNamespace = "")\r
95         boolean completed,\r
96         @WebParam(name = "exception", targetNamespace = "")\r
97         MsoExceptionCategory exception,\r
98         @WebParam(name = "errorMessage", targetNamespace = "")\r
99         String errorMessage,\r
100         @WebParam(name = "vnfExists", targetNamespace = "")\r
101         Boolean vnfExists,\r
102         @WebParam(name = "vnfId", targetNamespace = "")\r
103         String vnfId,\r
104         @WebParam(name = "status", targetNamespace = "")\r
105         VnfStatus status,\r
106         @WebParam(name = "outputs", targetNamespace = "")\r
107         QueryVnfNotification.Outputs outputs){\r
108 \r
109                 String method = "queryVnfNotification";\r
110                 String messageEventName = "queryVnfNotificationCallback";\r
111                 String messageVariable = "queryVnfNotificationCallback";\r
112                 String correlationVariable = "VNFQ_messageId";\r
113                 String correlationValue = messageId;\r
114 \r
115                 MsoLogger.setServiceName("MSO." + method);\r
116                 MsoLogger.setLogContext(correlationValue, "N/A");\r
117 \r
118         QueryVnfNotification message = new QueryVnfNotification();\r
119 \r
120         message.setMessageId(messageId);\r
121         message.setCompleted(completed);\r
122         message.setException(exception);\r
123         message.setErrorMessage(errorMessage);\r
124         message.setVnfExists(vnfExists);\r
125         message.setVnfId(vnfId);\r
126         message.setStatus(status);\r
127         message.setOutputs(outputs);\r
128 \r
129                 handleCallback(method, message, messageEventName, messageVariable,\r
130                         correlationVariable, correlationValue, logMarker);\r
131     }\r
132 \r
133         @WebMethod(operationName = "createVnfNotification")\r
134     @Oneway\r
135     @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification")
136     @Action(input = "http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest")
137         public void createVnfNotification(\r
138                         @WebParam(name = "messageId", targetNamespace = "")\r
139                 String messageId,\r
140                 @WebParam(name = "completed", targetNamespace = "")\r
141                 boolean completed,\r
142                 @WebParam(name = "exception", targetNamespace = "")\r
143                 MsoExceptionCategory exception,\r
144                 @WebParam(name = "errorMessage", targetNamespace = "")\r
145                 String errorMessage,\r
146                 @WebParam(name = "vnfId", targetNamespace = "")\r
147                 String vnfId,\r
148                 @WebParam(name = "outputs", targetNamespace = "")\r
149                 CreateVnfNotification.Outputs outputs,\r
150                 @WebParam(name = "rollback", targetNamespace = "")\r
151                 VnfRollback rollback){\r
152 \r
153                 String method = "createVnfNotification";\r
154                 String messageEventName = "createVnfNotificationCallback";\r
155                 String messageVariable = "createVnfNotificationCallback";\r
156                 String correlationVariable = "VNFC_messageId";\r
157                 String correlationValue = messageId;\r
158 \r
159                 MsoLogger.setServiceName("MSO." + method);\r
160                 MsoLogger.setLogContext(correlationValue, "N/A");\r
161 \r
162                 CreateVnfNotification message = new CreateVnfNotification();\r
163 \r
164                 message.setMessageId(messageId);\r
165                 message.setCompleted(completed);\r
166                 message.setException(exception);\r
167                 message.setErrorMessage(errorMessage);\r
168                 message.setVnfId(vnfId);\r
169                 message.setOutputs(outputs);\r
170                 message.setRollback(rollback);\r
171 \r
172                 handleCallback(method, message, messageEventName, messageVariable,\r
173                         correlationVariable, correlationValue, logMarker);\r
174          }\r
175 \r
176         @WebMethod(operationName = "updateVnfNotification")\r
177     @Oneway\r
178     @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification")
179     @Action(input = "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest")
180     public void updateVnfNotification(\r
181         @WebParam(name = "messageId", targetNamespace = "")\r
182         String messageId,\r
183         @WebParam(name = "completed", targetNamespace = "")\r
184         boolean completed,\r
185         @WebParam(name = "exception", targetNamespace = "")\r
186         MsoExceptionCategory exception,\r
187         @WebParam(name = "errorMessage", targetNamespace = "")\r
188         String errorMessage,\r
189         @WebParam(name = "outputs", targetNamespace = "")\r
190         UpdateVnfNotification.Outputs outputs,\r
191         @WebParam(name = "rollback", targetNamespace = "")\r
192         VnfRollback rollback){\r
193 \r
194                 String method = "updateVnfNotification";\r
195                 String messageEventName = "updateVnfNotificationCallback";\r
196                 String messageVariable = "updateVnfNotificationCallback";\r
197                 String correlationVariable = "VNFU_messageId";\r
198                 String correlationValue = messageId;\r
199 \r
200                 MsoLogger.setServiceName("MSO." + method);\r
201                 MsoLogger.setLogContext(correlationValue, "N/A");\r
202 \r
203         UpdateVnfNotification message = new UpdateVnfNotification();\r
204 \r
205         message.setMessageId(messageId);\r
206         message.setCompleted(completed);\r
207         message.setException(exception);\r
208         message.setErrorMessage(errorMessage);\r
209         message.setOutputs(outputs);\r
210         message.setRollback(rollback);\r
211 \r
212                 handleCallback(method, message, messageEventName, messageVariable,\r
213                         correlationVariable, correlationValue, logMarker);\r
214          }\r
215 \r
216     @WebMethod(operationName = "deleteVnfNotification")\r
217     @Oneway\r
218     @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification")
219     @Action(input = "http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest")
220     public void deleteVnfNotification(\r
221         @WebParam(name = "messageId", targetNamespace = "")\r
222         String messageId,\r
223         @WebParam(name = "completed", targetNamespace = "")\r
224         boolean completed,\r
225         @WebParam(name = "exception", targetNamespace = "")\r
226         MsoExceptionCategory exception,\r
227         @WebParam(name = "errorMessage", targetNamespace = "")\r
228         String errorMessage) {\r
229 \r
230                 String method = "deleteVnfNotification";\r
231                 String messageEventName = "deleteVnfACallback";\r
232                 String messageVariable = "deleteVnfACallback";\r
233                 String correlationVariable = "VNFDEL_uuid";\r
234                 String correlationValue = messageId;\r
235 \r
236                 MsoLogger.setServiceName("MSO." + method);\r
237                 MsoLogger.setLogContext(correlationValue, "N/A");\r
238 \r
239         DeleteVnfNotification message = new DeleteVnfNotification();\r
240 \r
241         message.setMessageId(messageId);\r
242         message.setCompleted(completed);\r
243         message.setException(exception);\r
244         message.setErrorMessage(errorMessage);\r
245 \r
246                 handleCallback(method, message, messageEventName, messageVariable,\r
247                         correlationVariable, correlationValue, logMarker);\r
248         }\r
249 }