96a11d21a731f990a1178f023cc04d094993d178
[so.git] /
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 final String logMarker = "[VNF-NOTIFY]";
53         
54         @Autowired
55         CallbackHandlerService callback;
56
57         @Context WebServiceContext wsContext;
58
59     @WebMethod(operationName = "rollbackVnfNotification")
60     @Oneway
61     @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification")
62     @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackVnfNotificationRequest")
63     public void rollbackVnfNotification(
64         @WebParam(name = "messageId", targetNamespace = "")
65         String messageId,
66         @WebParam(name = "completed", targetNamespace = "")
67         boolean completed,
68         @WebParam(name = "exception", targetNamespace = "")
69         MsoExceptionCategory exception,
70         @WebParam(name = "errorMessage", targetNamespace = "")
71         String errorMessage) {
72
73                 RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification();
74
75                 rollbackVnfNotification.setMessageId(messageId);
76                 rollbackVnfNotification.setCompleted(completed);
77                 rollbackVnfNotification.setException(exception);
78                 rollbackVnfNotification.setErrorMessage(errorMessage);
79
80                 String method = "rollbackVnfNotification";
81                 Object message = rollbackVnfNotification;
82                 String messageEventName = "rollbackVnfNotificationCallback";
83                 String messageVariable = "rollbackVnfNotificationCallback";
84                 String correlationVariable = "VNFRB_messageId";
85                 String correlationValue = messageId;
86
87                 callback.handleCallback(method, message, messageEventName, messageVariable,
88                         correlationVariable, correlationValue, logMarker);
89     }
90
91     @WebMethod(operationName = "queryVnfNotification")
92     @Oneway
93     @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification")
94     @Action(input = "http://org.onap.so/notify/adapterNotify/queryVnfNotificationRequest")
95     public void queryVnfNotification(
96         @WebParam(name = "messageId", targetNamespace = "")
97         String messageId,
98         @WebParam(name = "completed", targetNamespace = "")
99         boolean completed,
100         @WebParam(name = "exception", targetNamespace = "")
101         MsoExceptionCategory exception,
102         @WebParam(name = "errorMessage", targetNamespace = "")
103         String errorMessage,
104         @WebParam(name = "vnfExists", targetNamespace = "")
105         Boolean vnfExists,
106         @WebParam(name = "vnfId", targetNamespace = "")
107         String vnfId,
108         @WebParam(name = "status", targetNamespace = "")
109         VnfStatus status,
110         @WebParam(name = "outputs", targetNamespace = "")
111         QueryVnfNotification.Outputs outputs){
112
113                 String method = "queryVnfNotification";
114                 String messageEventName = "queryVnfNotificationCallback";
115                 String messageVariable = "queryVnfNotificationCallback";
116                 String correlationVariable = "VNFQ_messageId";
117                 String correlationValue = messageId;
118
119                 MsoLogger.setServiceName("MSO." + method);
120                 MsoLogger.setLogContext(correlationValue, "N/A");
121
122         QueryVnfNotification message = new QueryVnfNotification();
123
124         message.setMessageId(messageId);
125         message.setCompleted(completed);
126         message.setException(exception);
127         message.setErrorMessage(errorMessage);
128         message.setVnfExists(vnfExists);
129         message.setVnfId(vnfId);
130         message.setStatus(status);
131         message.setOutputs(outputs);
132
133         callback.handleCallback(method, message, messageEventName, messageVariable,
134                         correlationVariable, correlationValue, logMarker);
135     }
136
137         @WebMethod(operationName = "createVnfNotification")
138     @Oneway
139     @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification")
140     @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest")
141         public void createVnfNotification(
142                         @WebParam(name = "messageId", targetNamespace = "")
143                 String messageId,
144                 @WebParam(name = "completed", targetNamespace = "")
145                 boolean completed,
146                 @WebParam(name = "exception", targetNamespace = "")
147                 MsoExceptionCategory exception,
148                 @WebParam(name = "errorMessage", targetNamespace = "")
149                 String errorMessage,
150                 @WebParam(name = "vnfId", targetNamespace = "")
151                 String vnfId,
152                 @WebParam(name = "outputs", targetNamespace = "")
153                 CreateVnfNotification.Outputs outputs,
154                 @WebParam(name = "rollback", targetNamespace = "")
155                 VnfRollback rollback){
156
157                 String method = "createVnfNotification";
158                 String messageEventName = "createVnfNotificationCallback";
159                 String messageVariable = "createVnfNotificationCallback";
160                 String correlationVariable = "VNFC_messageId";
161                 String correlationValue = messageId;
162
163                 MsoLogger.setServiceName("MSO." + method);
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.setServiceName("MSO." + method);
205                 MsoLogger.setLogContext(correlationValue, "N/A");
206
207         UpdateVnfNotification message = new UpdateVnfNotification();
208
209         message.setMessageId(messageId);
210         message.setCompleted(completed);
211         message.setException(exception);
212         message.setErrorMessage(errorMessage);
213         message.setOutputs(outputs);
214         message.setRollback(rollback);
215
216         callback.handleCallback(method, message, messageEventName, messageVariable,
217                         correlationVariable, correlationValue, logMarker);
218          }
219
220     @WebMethod(operationName = "deleteVnfNotification")
221     @Oneway
222     @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify", className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification")
223     @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest")
224     public void deleteVnfNotification(
225         @WebParam(name = "messageId", targetNamespace = "")
226         String messageId,
227         @WebParam(name = "completed", targetNamespace = "")
228         boolean completed,
229         @WebParam(name = "exception", targetNamespace = "")
230         MsoExceptionCategory exception,
231         @WebParam(name = "errorMessage", targetNamespace = "")
232         String errorMessage) {
233
234                 String method = "deleteVnfNotification";
235                 String messageEventName = "deleteVnfACallback";
236                 String messageVariable = "deleteVnfACallback";
237                 String correlationVariable = "VNFDEL_uuid";
238                 String correlationValue = messageId;
239
240                 MsoLogger.setServiceName("MSO." + method);
241                 MsoLogger.setLogContext(correlationValue, "N/A");
242
243         DeleteVnfNotification message = new DeleteVnfNotification();
244
245         message.setMessageId(messageId);
246         message.setCompleted(completed);
247         message.setException(exception);
248         message.setErrorMessage(errorMessage);
249
250         callback.handleCallback(method, message, messageEventName, messageVariable,
251                         correlationVariable, correlationValue, logMarker);
252         }
253 }