5f70ab5924184219b04ca132d3fd31af7eff0e1c
[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.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 import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification;
34 import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification;
35 import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory;
36 import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification;
37 import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification;
38 import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification;
39 import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify;
40 import org.onap.so.bpmn.common.adapter.vnf.VnfRollback;
41 import org.onap.so.bpmn.common.adapter.vnf.VnfStatus;
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
58     WebServiceContext wsContext;
59
60     @WebMethod(operationName = "rollbackVnfNotification")
61     @Oneway
62     @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify",
63             className = "org.onap.so.adapters.vnf.async.client.RollbackVnfNotification")
64     @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackVnfNotificationRequest")
65     public void rollbackVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
66             @WebParam(name = "completed", targetNamespace = "") boolean completed,
67             @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
68             @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage) {
69
70         RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification();
71
72         rollbackVnfNotification.setMessageId(messageId);
73         rollbackVnfNotification.setCompleted(completed);
74         rollbackVnfNotification.setException(exception);
75         rollbackVnfNotification.setErrorMessage(errorMessage);
76
77         String method = "rollbackVnfNotification";
78         Object message = rollbackVnfNotification;
79         String messageEventName = "rollbackVnfNotificationCallback";
80         String messageVariable = "rollbackVnfNotificationCallback";
81         String correlationVariable = "VNFRB_messageId";
82         String correlationValue = messageId;
83
84         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
85                 correlationValue, logMarker);
86     }
87
88     @WebMethod(operationName = "queryVnfNotification")
89     @Oneway
90     @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify",
91             className = "org.onap.so.adapters.vnf.async.client.QueryVnfNotification")
92     @Action(input = "http://org.onap.so/notify/adapterNotify/queryVnfNotificationRequest")
93     public void queryVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
94             @WebParam(name = "completed", targetNamespace = "") boolean completed,
95             @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
96             @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
97             @WebParam(name = "vnfExists", targetNamespace = "") Boolean vnfExists,
98             @WebParam(name = "vnfId", targetNamespace = "") String vnfId,
99             @WebParam(name = "status", targetNamespace = "") VnfStatus status,
100             @WebParam(name = "outputs", targetNamespace = "") QueryVnfNotification.Outputs outputs) {
101
102         String method = "queryVnfNotification";
103         String messageEventName = "queryVnfNotificationCallback";
104         String messageVariable = "queryVnfNotificationCallback";
105         String correlationVariable = "VNFQ_messageId";
106         String correlationValue = messageId;
107
108         QueryVnfNotification message = new QueryVnfNotification();
109
110         message.setMessageId(messageId);
111         message.setCompleted(completed);
112         message.setException(exception);
113         message.setErrorMessage(errorMessage);
114         message.setVnfExists(vnfExists);
115         message.setVnfId(vnfId);
116         message.setStatus(status);
117         message.setOutputs(outputs);
118
119         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
120                 correlationValue, logMarker);
121     }
122
123     @WebMethod(operationName = "createVnfNotification")
124     @Oneway
125     @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify",
126             className = "org.onap.so.adapters.vnf.async.client.CreateVnfNotification")
127     @Action(input = "http://org.onap.so/notify/adapterNotify/createVnfNotificationRequest")
128     public void createVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
129             @WebParam(name = "completed", targetNamespace = "") boolean completed,
130             @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
131             @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
132             @WebParam(name = "vnfId", targetNamespace = "") String vnfId,
133             @WebParam(name = "outputs", targetNamespace = "") CreateVnfNotification.Outputs outputs,
134             @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback) {
135
136         String method = "createVnfNotification";
137         String messageEventName = "createVnfNotificationCallback";
138         String messageVariable = "createVnfNotificationCallback";
139         String correlationVariable = "VNFC_messageId";
140         String correlationValue = messageId;
141
142         CreateVnfNotification message = new CreateVnfNotification();
143
144         message.setMessageId(messageId);
145         message.setCompleted(completed);
146         message.setException(exception);
147         message.setErrorMessage(errorMessage);
148         message.setVnfId(vnfId);
149         message.setOutputs(outputs);
150         message.setRollback(rollback);
151
152         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
153                 correlationValue, logMarker);
154     }
155
156     @WebMethod(operationName = "updateVnfNotification")
157     @Oneway
158     @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify",
159             className = "org.onap.so.adapters.vnf.async.client.UpdateVnfNotification")
160     @Action(input = "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest")
161     public void updateVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
162             @WebParam(name = "completed", targetNamespace = "") boolean completed,
163             @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
164             @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage,
165             @WebParam(name = "outputs", targetNamespace = "") UpdateVnfNotification.Outputs outputs,
166             @WebParam(name = "rollback", targetNamespace = "") VnfRollback rollback) {
167
168         String method = "updateVnfNotification";
169         String messageEventName = "updateVnfNotificationCallback";
170         String messageVariable = "updateVnfNotificationCallback";
171         String correlationVariable = "VNFU_messageId";
172         String correlationValue = messageId;
173
174         UpdateVnfNotification message = new UpdateVnfNotification();
175
176         message.setMessageId(messageId);
177         message.setCompleted(completed);
178         message.setException(exception);
179         message.setErrorMessage(errorMessage);
180         message.setOutputs(outputs);
181         message.setRollback(rollback);
182
183         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
184                 correlationValue, logMarker);
185     }
186
187     @WebMethod(operationName = "deleteVnfNotification")
188     @Oneway
189     @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.onap.so/vnfNotify",
190             className = "org.onap.so.adapters.vnf.async.client.DeleteVnfNotification")
191     @Action(input = "http://org.onap.so/notify/adapterNotify/deleteVnfNotificationRequest")
192     public void deleteVnfNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId,
193             @WebParam(name = "completed", targetNamespace = "") boolean completed,
194             @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception,
195             @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage) {
196
197         String method = "deleteVnfNotification";
198         String messageEventName = "deleteVnfACallback";
199         String messageVariable = "deleteVnfACallback";
200         String correlationVariable = "VNFDEL_uuid";
201         String correlationValue = messageId;
202
203         DeleteVnfNotification message = new DeleteVnfNotification();
204
205         message.setMessageId(messageId);
206         message.setCompleted(completed);
207         message.setException(exception);
208         message.setErrorMessage(errorMessage);
209
210         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
211                 correlationValue, logMarker);
212     }
213 }