Containerization feature of SO
[so.git] / bpmn / mso-infrastructure-bpmn / src / main / java / org / onap / so / bpmn / common / workflow / service / VnfAdapterNotifyServiceImpl.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.bpmn.common.workflow.service;
22
23 import javax.jws.Oneway;
24 import javax.jws.WebMethod;
25 import javax.jws.WebParam;
26 import javax.jws.WebService;
27 import javax.ws.rs.core.Context;
28 import javax.xml.ws.Action;
29 import javax.xml.ws.RequestWrapper;
30 import javax.xml.ws.WebServiceContext;
31
32 import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification;
33 import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification;
34 import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory;
35 import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification;
36 import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification;
37 import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification;
38 import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify;
39 import org.onap.so.bpmn.common.adapter.vnf.VnfRollback;
40 import org.onap.so.bpmn.common.adapter.vnf.VnfStatus;
41 import org.onap.so.logger.MsoLogger;
42 import org.springframework.beans.factory.annotation.Autowired;
43 import org.springframework.stereotype.Service;
44
45 /**
46  * Implementation of the VnfAdapterNotify service.
47  */
48 @WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify")
49 @Service
50 public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService implements VnfAdapterNotify{
51
52         private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterNotifyServiceImpl.class);
53
54         private final String logMarker = "[VNF-NOTIFY]";
55         
56         @Autowired
57         CallbackHandlerService callback;
58
59         @Context WebServiceContext wsContext;
60
61     @WebMethod(operationName = "rollbackVnfNotification")
62     @Oneway
63     @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification")
64     @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackVnfNotificationRequest")
65     public void rollbackVnfNotification(
66         @WebParam(name = "messageId", targetNamespace = "")
67         String messageId,
68         @WebParam(name = "completed", targetNamespace = "")
69         boolean completed,
70         @WebParam(name = "exception", targetNamespace = "")
71         MsoExceptionCategory exception,
72         @WebParam(name = "errorMessage", targetNamespace = "")
73         String errorMessage) {
74
75                 RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification();
76
77                 rollbackVnfNotification.setMessageId(messageId);
78                 rollbackVnfNotification.setCompleted(completed);
79                 rollbackVnfNotification.setException(exception);
80                 rollbackVnfNotification.setErrorMessage(errorMessage);
81
82                 String method = "rollbackVnfNotification";
83                 Object message = rollbackVnfNotification;
84                 String messageEventName = "rollbackVnfNotificationCallback";
85                 String messageVariable = "rollbackVnfNotificationCallback";
86                 String correlationVariable = "VNFRB_messageId";
87                 String correlationValue = messageId;
88
89                 callback.handleCallback(method, message, messageEventName, messageVariable,
90                         correlationVariable, correlationValue, logMarker);
91     }
92
93     @WebMethod(operationName = "queryVnfNotification")
94     @Oneway
95     @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification")
96     @Action(input = "http://org.onap.so/notify/adapterNotify/queryVnfNotificationRequest")
97     public void queryVnfNotification(
98         @WebParam(name = "messageId", targetNamespace = "")
99         String messageId,
100         @WebParam(name = "completed", targetNamespace = "")
101         boolean completed,
102         @WebParam(name = "exception", targetNamespace = "")
103         MsoExceptionCategory exception,
104         @WebParam(name = "errorMessage", targetNamespace = "")
105         String errorMessage,
106         @WebParam(name = "vnfExists", targetNamespace = "")
107         Boolean vnfExists,
108         @WebParam(name = "vnfId", targetNamespace = "")
109         String vnfId,
110         @WebParam(name = "status", targetNamespace = "")
111         VnfStatus status,
112         @WebParam(name = "outputs", targetNamespace = "")
113         QueryVnfNotification.Outputs outputs){
114
115                 String method = "queryVnfNotification";
116                 String messageEventName = "queryVnfNotificationCallback";
117                 String messageVariable = "queryVnfNotificationCallback";
118                 String correlationVariable = "VNFQ_messageId";
119                 String correlationValue = messageId;
120
121                 MsoLogger.setServiceName("MSO." + method);
122                 MsoLogger.setLogContext(correlationValue, "N/A");
123
124         QueryVnfNotification message = new QueryVnfNotification();
125
126         message.setMessageId(messageId);
127         message.setCompleted(completed);
128         message.setException(exception);
129         message.setErrorMessage(errorMessage);
130         message.setVnfExists(vnfExists);
131         message.setVnfId(vnfId);
132         message.setStatus(status);
133         message.setOutputs(outputs);
134
135         callback.handleCallback(method, message, messageEventName, messageVariable,
136                         correlationVariable, correlationValue, logMarker);
137     }
138
139         @WebMethod(operationName = "createVnfNotification")
140     @Oneway
141     @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification")
142     @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest")
143         public void createVnfNotification(
144                         @WebParam(name = "messageId", targetNamespace = "")
145                 String messageId,
146                 @WebParam(name = "completed", targetNamespace = "")
147                 boolean completed,
148                 @WebParam(name = "exception", targetNamespace = "")
149                 MsoExceptionCategory exception,
150                 @WebParam(name = "errorMessage", targetNamespace = "")
151                 String errorMessage,
152                 @WebParam(name = "vnfId", targetNamespace = "")
153                 String vnfId,
154                 @WebParam(name = "outputs", targetNamespace = "")
155                 CreateVnfNotification.Outputs outputs,
156                 @WebParam(name = "rollback", targetNamespace = "")
157                 VnfRollback rollback){
158
159                 String method = "createVnfNotification";
160                 String messageEventName = "createVnfNotificationCallback";
161                 String messageVariable = "createVnfNotificationCallback";
162                 String correlationVariable = "VNFC_messageId";
163                 String correlationValue = messageId;
164
165                 MsoLogger.setServiceName("MSO." + method);
166                 MsoLogger.setLogContext(correlationValue, "N/A");
167
168                 CreateVnfNotification message = new CreateVnfNotification();
169
170                 message.setMessageId(messageId);
171                 message.setCompleted(completed);
172                 message.setException(exception);
173                 message.setErrorMessage(errorMessage);
174                 message.setVnfId(vnfId);
175                 message.setOutputs(outputs);
176                 message.setRollback(rollback);
177
178                 callback.handleCallback(method, message, messageEventName, messageVariable,
179                         correlationVariable, correlationValue, logMarker);
180          }
181
182         @WebMethod(operationName = "updateVnfNotification")
183     @Oneway
184     @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification")
185     @Action(input = "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest")
186     public void updateVnfNotification(
187         @WebParam(name = "messageId", targetNamespace = "")
188         String messageId,
189         @WebParam(name = "completed", targetNamespace = "")
190         boolean completed,
191         @WebParam(name = "exception", targetNamespace = "")
192         MsoExceptionCategory exception,
193         @WebParam(name = "errorMessage", targetNamespace = "")
194         String errorMessage,
195         @WebParam(name = "outputs", targetNamespace = "")
196         UpdateVnfNotification.Outputs outputs,
197         @WebParam(name = "rollback", targetNamespace = "")
198         VnfRollback rollback){
199
200                 String method = "updateVnfNotification";
201                 String messageEventName = "updateVnfNotificationCallback";
202                 String messageVariable = "updateVnfNotificationCallback";
203                 String correlationVariable = "VNFU_messageId";
204                 String correlationValue = messageId;
205
206                 MsoLogger.setServiceName("MSO." + method);
207                 MsoLogger.setLogContext(correlationValue, "N/A");
208
209         UpdateVnfNotification message = new UpdateVnfNotification();
210
211         message.setMessageId(messageId);
212         message.setCompleted(completed);
213         message.setException(exception);
214         message.setErrorMessage(errorMessage);
215         message.setOutputs(outputs);
216         message.setRollback(rollback);
217
218         callback.handleCallback(method, message, messageEventName, messageVariable,
219                         correlationVariable, correlationValue, logMarker);
220          }
221
222     @WebMethod(operationName = "deleteVnfNotification")
223     @Oneway
224     @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification")
225     @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest")
226     public void deleteVnfNotification(
227         @WebParam(name = "messageId", targetNamespace = "")
228         String messageId,
229         @WebParam(name = "completed", targetNamespace = "")
230         boolean completed,
231         @WebParam(name = "exception", targetNamespace = "")
232         MsoExceptionCategory exception,
233         @WebParam(name = "errorMessage", targetNamespace = "")
234         String errorMessage) {
235
236                 String method = "deleteVnfNotification";
237                 String messageEventName = "deleteVnfACallback";
238                 String messageVariable = "deleteVnfACallback";
239                 String correlationVariable = "VNFDEL_uuid";
240                 String correlationValue = messageId;
241
242                 MsoLogger.setServiceName("MSO." + method);
243                 MsoLogger.setLogContext(correlationValue, "N/A");
244
245         DeleteVnfNotification message = new DeleteVnfNotification();
246
247         message.setMessageId(messageId);
248         message.setCompleted(completed);
249         message.setException(exception);
250         message.setErrorMessage(errorMessage);
251
252         callback.handleCallback(method, message, messageEventName, messageVariable,
253                         correlationVariable, correlationValue, logMarker);
254         }
255 }