65cc70d5f48ffb105c92329eb329771a4020c380
[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  * 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.bpmn.common.workflow.service;
24
25 import javax.jws.Oneway;
26 import javax.jws.WebMethod;
27 import javax.jws.WebParam;
28 import javax.jws.WebService;
29 import javax.ws.rs.core.Context;
30 import javax.xml.ws.Action;
31 import javax.xml.ws.RequestWrapper;
32 import javax.xml.ws.WebServiceContext;
33
34 import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification;
35 import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification;
36 import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory;
37 import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification;
38 import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification;
39 import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification;
40 import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify;
41 import org.onap.so.bpmn.common.adapter.vnf.VnfRollback;
42 import org.onap.so.bpmn.common.adapter.vnf.VnfStatus;
43 import org.onap.so.logger.MsoLogger;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.stereotype.Service;
46
47 /**
48  * Implementation of the VnfAdapterNotify service.
49  */
50 @WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.onap.so/vnfNotify")
51 @Service
52 public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService implements VnfAdapterNotify{
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.setLogContext(correlationValue, "N/A");
122
123         QueryVnfNotification message = new QueryVnfNotification();
124
125         message.setMessageId(messageId);
126         message.setCompleted(completed);
127         message.setException(exception);
128         message.setErrorMessage(errorMessage);
129         message.setVnfExists(vnfExists);
130         message.setVnfId(vnfId);
131         message.setStatus(status);
132         message.setOutputs(outputs);
133
134         callback.handleCallback(method, message, messageEventName, messageVariable,
135                         correlationVariable, correlationValue, logMarker);
136     }
137
138         @WebMethod(operationName = "createVnfNotification")
139     @Oneway
140     @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification")
141     @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest")
142         public void createVnfNotification(
143                         @WebParam(name = "messageId", targetNamespace = "")
144                 String messageId,
145                 @WebParam(name = "completed", targetNamespace = "")
146                 boolean completed,
147                 @WebParam(name = "exception", targetNamespace = "")
148                 MsoExceptionCategory exception,
149                 @WebParam(name = "errorMessage", targetNamespace = "")
150                 String errorMessage,
151                 @WebParam(name = "vnfId", targetNamespace = "")
152                 String vnfId,
153                 @WebParam(name = "outputs", targetNamespace = "")
154                 CreateVnfNotification.Outputs outputs,
155                 @WebParam(name = "rollback", targetNamespace = "")
156                 VnfRollback rollback){
157
158                 String method = "createVnfNotification";
159                 String messageEventName = "createVnfNotificationCallback";
160                 String messageVariable = "createVnfNotificationCallback";
161                 String correlationVariable = "VNFC_messageId";
162                 String correlationValue = messageId;
163
164                 MsoLogger.setLogContext(correlationValue, "N/A");
165
166                 CreateVnfNotification message = new CreateVnfNotification();
167
168                 message.setMessageId(messageId);
169                 message.setCompleted(completed);
170                 message.setException(exception);
171                 message.setErrorMessage(errorMessage);
172                 message.setVnfId(vnfId);
173                 message.setOutputs(outputs);
174                 message.setRollback(rollback);
175
176                 callback.handleCallback(method, message, messageEventName, messageVariable,
177                         correlationVariable, correlationValue, logMarker);
178          }
179
180         @WebMethod(operationName = "updateVnfNotification")
181     @Oneway
182     @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification")
183     @Action(input = "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest")
184     public void updateVnfNotification(
185         @WebParam(name = "messageId", targetNamespace = "")
186         String messageId,
187         @WebParam(name = "completed", targetNamespace = "")
188         boolean completed,
189         @WebParam(name = "exception", targetNamespace = "")
190         MsoExceptionCategory exception,
191         @WebParam(name = "errorMessage", targetNamespace = "")
192         String errorMessage,
193         @WebParam(name = "outputs", targetNamespace = "")
194         UpdateVnfNotification.Outputs outputs,
195         @WebParam(name = "rollback", targetNamespace = "")
196         VnfRollback rollback){
197
198                 String method = "updateVnfNotification";
199                 String messageEventName = "updateVnfNotificationCallback";
200                 String messageVariable = "updateVnfNotificationCallback";
201                 String correlationVariable = "VNFU_messageId";
202                 String correlationValue = messageId;
203
204                 MsoLogger.setLogContext(correlationValue, "N/A");
205
206         UpdateVnfNotification message = new UpdateVnfNotification();
207
208         message.setMessageId(messageId);
209         message.setCompleted(completed);
210         message.setException(exception);
211         message.setErrorMessage(errorMessage);
212         message.setOutputs(outputs);
213         message.setRollback(rollback);
214
215         callback.handleCallback(method, message, messageEventName, messageVariable,
216                         correlationVariable, correlationValue, logMarker);
217          }
218
219     @WebMethod(operationName = "deleteVnfNotification")
220     @Oneway
221     @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification")
222     @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest")
223     public void deleteVnfNotification(
224         @WebParam(name = "messageId", targetNamespace = "")
225         String messageId,
226         @WebParam(name = "completed", targetNamespace = "")
227         boolean completed,
228         @WebParam(name = "exception", targetNamespace = "")
229         MsoExceptionCategory exception,
230         @WebParam(name = "errorMessage", targetNamespace = "")
231         String errorMessage) {
232
233                 String method = "deleteVnfNotification";
234                 String messageEventName = "deleteVnfACallback";
235                 String messageVariable = "deleteVnfACallback";
236                 String correlationVariable = "VNFDEL_uuid";
237                 String correlationValue = messageId;
238
239                 MsoLogger.setLogContext(correlationValue, "N/A");
240
241         DeleteVnfNotification message = new DeleteVnfNotification();
242
243         message.setMessageId(messageId);
244         message.setCompleted(completed);
245         message.setException(exception);
246         message.setErrorMessage(errorMessage);
247
248         callback.handleCallback(method, message, messageEventName, messageVariable,
249                         correlationVariable, correlationValue, logMarker);
250         }
251 }