2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.adapters.vnf;
25 import java.net.MalformedURLException;
27 import java.security.GeneralSecurityException;
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.List;
33 import javax.jws.WebService;
34 import javax.xml.bind.DatatypeConverter;
35 import javax.xml.namespace.QName;
36 import javax.xml.ws.BindingProvider;
37 import javax.xml.ws.Holder;
38 import javax.xml.ws.handler.MessageContext;
40 import org.onap.so.adapters.vnf.async.client.CreateVnfNotification;
41 import org.onap.so.adapters.vnf.async.client.QueryVnfNotification;
42 import org.onap.so.adapters.vnf.async.client.UpdateVnfNotification;
43 import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify;
44 import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service;
45 import org.onap.so.adapters.vnf.exceptions.VnfException;
46 import org.onap.so.entity.MsoRequest;
47 import org.onap.so.logger.MessageEnum;
48 import org.onap.so.logger.MsoAlarmLogger;
49 import org.onap.so.logger.MsoLogger;
50 import org.onap.so.openstack.beans.VnfRollback;
51 import org.onap.so.openstack.beans.VnfStatus;
52 import org.onap.so.utils.CryptoUtils;
53 import org.springframework.beans.factory.annotation.Autowired;
54 import org.springframework.core.env.Environment;
55 import org.springframework.stereotype.Component;
57 @WebService(serviceName = "VnfAdapterAsync", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapterAsync", targetNamespace = "http://org.onap.so/vnfA")
59 public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync {
61 public static final String MSO_PROP_VNF_ADAPTER="MSO_PROP_VNF_ADAPTER";
62 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoVnfAdapterAsyncImpl.class);
63 private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
64 private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.vnf.bpelauth";
65 private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey";
68 private Environment environment;
71 private MsoVnfAdapterImpl vnfImpl;
74 * Health Check web method. Does nothing but return to show the adapter is deployed.
77 public void healthCheckA () {
78 LOGGER.debug ("Health check call in VNF Adapter");
82 * This is the asynchronous "Create VNF" web service implementation.
83 * It will create a new VNF of the requested type in the specified cloud
84 * and tenant. The tenant must exist before this service is called.
86 * If a VNF with the same name already exists, this can be considered a
87 * success or failure, depending on the value of the 'failIfExists' parameter.
89 * All VNF types will be defined in the MSO catalog. The caller must request
90 * one of these pre-defined types or an error will be returned. Within the
91 * catalog, each VNF type references (among other things) a Heat template
92 * which is used to deploy the required VNF artifacts (VMs, networks, etc.)
95 * Depending on the Heat template, a variable set of input parameters will
96 * be defined, some of which are required. The caller is responsible to
97 * pass the necessary input data for the VNF or an error will be thrown.
99 * The method sends an asynchronous response to the notification URL when
100 * processing completes. The createAsyncResponse contains the vnfId (the
101 * canonical name of the stack), a Map of VNF output attributes, and a
102 * VnfRollback object. This last object can be passed as-is to the
103 * rollbackVnf operation to undo everything that was created for the VNF.
104 * This is useful if a VNF is successfully created but the orchestrator
105 * fails on a subsequent operation.
107 * Note: this method is implemented by calling the synchronous web method
108 * and translating the response to an asynchronous notification.
110 * @param cloudSiteId CLLI code of the cloud site in which to create the VNF
111 * @param tenantId Openstack tenant identifier
112 * @param vnfType VNF type key, should match a VNF definition in catalog DB
113 * @param vnfName Name to be assigned to the new VNF
114 * @param inputs Map of key=value inputs for VNF stack creation
115 * @param failIfExists Flag whether already existing VNF should be considered
116 * a success or failure
117 * @param msoRequest Request tracking information for logs
118 * @param notificationURL the target URL for asynchronous response
121 public void createVnfA (String cloudSiteId,
127 String volumeGroupHeatStackId,
128 Map <String, String> inputs,
129 Boolean failIfExists,
131 Boolean enableBridge,
133 MsoRequest msoRequest,
134 String notificationUrl) {
136 String serviceName = "CreateVnfA";
137 MsoLogger.setLogContext (msoRequest);
138 MsoLogger.setServiceName (serviceName);
139 LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "createVnfA");
140 // Use the synchronous method to perform the actual Create
141 MsoVnfAdapter vnfAdapter = vnfImpl;
142 // Synchronous Web Service Outputs
143 Holder <String> vnfId = new Holder <> ();
144 Holder <Map <String, String>> outputs = new Holder <> ();
145 Holder <VnfRollback> vnfRollback = new Holder <> ();
148 vnfAdapter.createVnf (cloudSiteId,
154 volumeGroupHeatStackId,
163 MsoLogger.setServiceName (serviceName);
164 } catch (VnfException e) {
165 MsoLogger.setServiceName (serviceName);
166 LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException in createVnfA", e);
167 org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
170 eMsg = e.getFaultInfo ().getMessage ();
171 exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
174 } catch (Exception e1) {
175 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Fault info", e1);
177 // Build and send Asynchronous error response
179 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
180 notifyPort.createVnfNotification (messageId, false, exCat, eMsg, null, null, null);
181 } catch (Exception e1) {
182 error = "Error sending createVnf notification " + e1.getMessage ();
183 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e1);
184 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
186 LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "createVnfA", "");
189 LOGGER.debug ("Async Create VNF: " + vnfName + " VnfId:" + vnfId.value);
190 // Build and send Asynchronous response
192 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
193 notifyPort.createVnfNotification (messageId,
198 copyCreateOutputs (outputs),
199 copyVrb (vnfRollback));
200 } catch (Exception e) {
201 error = "Error sending createVnf notification " + e.getMessage ();
202 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "createVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending createVnf notification", e);
203 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
205 LOGGER.info (MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE, "", "","createVnfA");
210 public void updateVnfA (String cloudSiteId,
216 String volumeGroupHeatStackId,
217 Map <String, String> inputs,
219 MsoRequest msoRequest,
220 String notificationUrl) {
222 String serviceName = "UpdateVnfA";
223 MsoLogger.setServiceName (serviceName);
224 MsoLogger.setLogContext (msoRequest);
225 LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF, vnfName, vnfType, cloudSiteId, tenantId, "UpdateVnfA");
227 // Use the synchronous method to perform the actual Create
228 MsoVnfAdapter vnfAdapter = vnfImpl;
230 // Synchronous Web Service Outputs
231 Holder <String> vnfId = new Holder <> ();
232 Holder <Map <String, String>> outputs = new Holder <> ();
233 Holder <VnfRollback> vnfRollback = new Holder <> ();
236 vnfAdapter.updateVnf (cloudSiteId, tenantId, vnfType,vnfVersion, vnfName, requestType, volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback);
237 MsoLogger.setServiceName (serviceName);
238 } catch (VnfException e) {
239 MsoLogger.setServiceName (serviceName);
240 LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e);
241 org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
244 eMsg = e.getFaultInfo ().getMessage ();
245 exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
248 } catch (Exception e1) {
249 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
251 // Build and send Asynchronous error response
253 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
254 notifyPort.updateVnfNotification (messageId, false, exCat, eMsg, null, null);
255 } catch (Exception e1) {
256 error = "Error sending updateVnf notification " + e1.getMessage ();
257 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e1);
258 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
260 LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE,"","","UpdateVnfA");
263 LOGGER.debug ("Async Update VNF: " + vnfName + " VnfId:" + vnfId.value);
264 // Build and send Asynchronous response
266 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
267 notifyPort.updateVnfNotification (messageId,
271 copyUpdateOutputs (outputs),
272 copyVrb (vnfRollback));
273 } catch (Exception e) {
274 error = "Error sending updateVnf notification " + e.getMessage ();
275 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "UpdateVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending updateVnf notification", e);
276 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
278 LOGGER.info (MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE, "", "","UpdateVnfA");
283 * This is the "Query VNF" web service implementation.
284 * It will look up a VNF by name or ID in the specified cloud and tenant.
286 * The method returns an indicator that the VNF exists, its Openstack internal
287 * ID, its status, and the set of outputs (from when the stack was created).
289 * @param cloudSiteId CLLI code of the cloud site in which to query
290 * @param tenantId Openstack tenant identifier
291 * @param vnfName VNF Name or Openstack ID
292 * @param msoRequest Request tracking information for logs
293 * @param notificationURL the target URL for asynchronous response
296 public void queryVnfA (String cloudSiteId,
300 MsoRequest msoRequest,
301 String notificationUrl) {
303 String serviceName = "QueryVnfA";
304 MsoLogger.setServiceName (serviceName);
305 MsoLogger.setLogContext (msoRequest);
306 LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF, vnfName, cloudSiteId, tenantId);
308 // Use the synchronous method to perform the actual query
309 MsoVnfAdapter vnfAdapter = vnfImpl;
311 // Synchronous Web Service Outputs
312 Holder <Boolean> vnfExists = new Holder <> ();
313 Holder <String> vnfId = new Holder <> ();
314 Holder <VnfStatus> status = new Holder <> ();
315 Holder <Map <String, String>> outputs = new Holder <> ();
318 vnfAdapter.queryVnf (cloudSiteId, tenantId, vnfName, msoRequest, vnfExists, vnfId, status, outputs);
319 MsoLogger.setServiceName (serviceName);
320 } catch (VnfException e) {
321 MsoLogger.setServiceName (serviceName);
322 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnfA notification", e);
323 org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
326 eMsg = e.getFaultInfo ().getMessage ();
327 exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
330 } catch (Exception e1) {
331 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
333 // Build and send Asynchronous error response
335 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
336 notifyPort.queryVnfNotification (messageId, false, exCat, eMsg, null, null, null, null);
337 } catch (Exception e1) {
338 error = "Error sending queryVnf notification " + e1.getMessage ();
339 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e1);
340 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
342 LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "","", "queryVnfA");
346 if (!vnfExists.value) {
347 LOGGER.debug ("Async Query, VNF not found");
349 LOGGER.debug ("Async Query, VNF=" + vnfId.value + ", status=" + status.value);
351 // Build and send Asynchronous response
353 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
354 org.onap.so.adapters.vnf.async.client.VnfStatus vnfS = org.onap.so.adapters.vnf.async.client.VnfStatus.fromValue (status.value.name ());
355 notifyPort.queryVnfNotification (messageId,
362 copyQueryOutputs (outputs));
363 } catch (Exception e) {
364 error = "Error sending queryVnf notification " + e.getMessage ();
365 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "queryVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending queryVnf notification", e);
366 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
369 LOGGER.info (MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE, "","", "queryVnfA");
374 * This is the Asynchronous "Delete VNF" web service implementation.
375 * It will delete a VNF by name or ID in the specified cloud and tenant.
377 * The method has no outputs.
379 * @param cloudSiteId CLLI code of the cloud site in which to delete
380 * @param tenantId Openstack tenant identifier
381 * @param vnfName VNF Name or Openstack ID
382 * @param msoRequest Request tracking information for logs
383 * @param notificationURL the target URL for asynchronous response
386 public void deleteVnfA (String cloudSiteId,
390 MsoRequest msoRequest,
391 String notificationUrl) {
393 String serviceName = "DeleteVnfA";
394 MsoLogger.setServiceName (serviceName);
395 MsoLogger.setLogContext (msoRequest);
396 LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF, vnfName, cloudSiteId, tenantId);
398 // Use the synchronous method to perform the actual delete
399 MsoVnfAdapter vnfAdapter = vnfImpl;
402 vnfAdapter.deleteVnf (cloudSiteId, tenantId, vnfName, msoRequest);
403 MsoLogger.setServiceName (serviceName);
404 } catch (VnfException e) {
405 MsoLogger.setServiceName (serviceName);
406 LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, vnfName, cloudSiteId, tenantId, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e);
407 org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
410 eMsg = e.getFaultInfo ().getMessage ();
411 exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
414 } catch (Exception e1) {
415 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
417 // Build and send Asynchronous error response
419 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
420 notifyPort.deleteVnfNotification (messageId, false, exCat, eMsg);
421 } catch (Exception e1) {
422 error = "Error sending deleteVnf notification " + e1.getMessage ();
423 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e1);
424 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
426 LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "","", "deleteVnfA");
430 LOGGER.debug ("Async Delete VNF: " + vnfName);
431 // Build and send Asynchronous response
433 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
434 notifyPort.deleteVnfNotification (messageId, true, null, null);
436 } catch (Exception e) {
437 error = "Error sending deleteVnf notification " + e.getMessage ();
438 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "deleteVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending deleteVnfA notification", e);
439 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
442 LOGGER.info (MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE, "", "","deleteVnfA");
447 * This web service endpoint will rollback a previous Create VNF operation.
448 * A rollback object is returned to the client in a successful creation
449 * response. The client can pass that object as-is back to the rollbackVnf
450 * operation to undo the creation.
453 public void rollbackVnfA (VnfRollback rollback, String messageId, String notificationUrl) {
454 String serviceName = "RollbackVnfA";
455 MsoLogger.setServiceName (serviceName);
457 // rollback may be null (e.g. if stack already existed when Create was called)
458 if (rollback == null) {
459 error = "Empty Rollback: No action to perform";
460 LOGGER.info (MessageEnum.RA_ROLLBACK_NULL, "","", "rollbackVnfA");
461 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
465 MsoLogger.setLogContext (rollback.getMsoRequest ());
466 LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF, "", "","rollbackVnfA");
468 // Use the synchronous method to perform the actual rollback
469 MsoVnfAdapter vnfAdapter = vnfImpl;
472 vnfAdapter.rollbackVnf (rollback);
473 MsoLogger.setServiceName (serviceName);
474 } catch (VnfException e) {
475 MsoLogger.setServiceName (serviceName);
476 LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e);
477 org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null;
480 eMsg = e.getFaultInfo ().getMessage ();
481 exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory.fromValue (e.getFaultInfo ()
484 } catch (Exception e1) {
485 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - fault info", e1);
487 // Build and send Asynchronous error response
489 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
490 notifyPort.rollbackVnfNotification (messageId, false, exCat, eMsg);
491 } catch (Exception e1) {
492 error = "Error sending rollbackVnf notification " + e1.getMessage ();
493 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e1);
494 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
496 LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "","", "rollbackVnfA");
500 LOGGER.debug ("Async Rollback VNF:" + rollback.getVnfId ());
501 // Build and send Asynchronous response
503 VnfAdapterNotify notifyPort = getNotifyEP (notificationUrl);
504 notifyPort.rollbackVnfNotification (messageId, true, null, null);
505 } catch (Exception e) {
506 error = "Error sending rollbackVnf notification " + e.getMessage ();
507 LOGGER.error (MessageEnum.RA_SEND_VNF_NOTIF_ERR, "", "rollbackVnfA", MsoLogger.ErrorCode.BusinessProcesssError, "Exception sending rollbackVnfA notification", e);
508 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
511 LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE, "", "","rollbackVnfA");
515 private org.onap.so.adapters.vnf.async.client.VnfRollback copyVrb (Holder <VnfRollback> hVrb) {
516 org.onap.so.adapters.vnf.async.client.VnfRollback cvrb = new org.onap.so.adapters.vnf.async.client.VnfRollback ();
518 if (hVrb != null && hVrb.value != null) {
519 org.onap.so.adapters.vnf.async.client.MsoRequest cmr = new org.onap.so.adapters.vnf.async.client.MsoRequest ();
521 cvrb.setCloudSiteId (hVrb.value.getCloudSiteId ());
522 if (hVrb.value.getMsoRequest() != null) {
523 cmr.setRequestId (hVrb.value.getMsoRequest ().getRequestId ());
524 cmr.setServiceInstanceId (hVrb.value.getMsoRequest ().getServiceInstanceId ());
526 cmr.setRequestId (null);
527 cmr.setServiceInstanceId (null);
529 cvrb.setMsoRequest (cmr);
530 cvrb.setVnfId (hVrb.value.getVnfId ());
531 cvrb.setTenantId (hVrb.value.getTenantId ());
532 cvrb.setTenantCreated (hVrb.value.getTenantCreated ());
533 cvrb.setVnfCreated (hVrb.value.getVnfCreated ());
538 private CreateVnfNotification.Outputs copyCreateOutputs (Holder <Map <String, String>> hMap) {
540 CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs ();
542 if (hMap != null && hMap.value != null) {
543 Map <String, String> sMap = new HashMap <> ();
545 CreateVnfNotification.Outputs.Entry entry = new CreateVnfNotification.Outputs.Entry ();
547 for (String key : sMap.keySet ()) {
549 entry.setValue (sMap.get (key));
550 outputs.getEntry ().add (entry);
556 private UpdateVnfNotification.Outputs copyUpdateOutputs (Holder <Map <String, String>> hMap) {
558 UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs ();
560 if (hMap != null && hMap.value != null) {
561 Map <String, String> sMap = new HashMap <> ();
563 UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry ();
565 for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
566 String key = mapEntry.getKey();
567 String value = mapEntry.getValue();
569 entry.setValue (value);
570 outputs.getEntry ().add (entry);
576 private QueryVnfNotification.Outputs copyQueryOutputs (Holder <Map <String, String>> hMap) {
578 QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs ();
580 if (hMap != null && hMap.value != null) {
581 Map <String, String> sMap = new HashMap <> ();
584 QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry ();
586 for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
587 String key = mapEntry.getKey();
588 String value = mapEntry.getValue();
590 entry.setValue (value);
591 outputs.getEntry ().add (entry);
597 private VnfAdapterNotify getNotifyEP (String notificationUrl) {
599 URL warWsdlLoc = null;
601 warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("VnfAdapterNotify.wsdl");
602 } catch (Exception e) {
603 LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL not found", e);
605 if (warWsdlLoc == null) {
606 LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "WSDL not found");
609 LOGGER.debug ("VnfAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
610 } catch (Exception e) {
611 LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "VnfAdapterNotify.wsdl", "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - WSDL URL convention", e);
615 VnfAdapterNotify_Service notifySvc = new VnfAdapterNotify_Service (warWsdlLoc,
616 new QName ("http://org.onap.so/vnfNotify",
617 "vnfAdapterNotify"));
619 VnfAdapterNotify notifyPort = notifySvc.getMsoVnfAdapterAsyncImplPort ();
621 BindingProvider bp = (BindingProvider) notifyPort;
625 epUrl = new URL (notificationUrl);
626 } catch (MalformedURLException e1) {
627 LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "MalformedURLException", e1);
631 LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());
632 bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());
635 LOGGER.debug ("epUrl is NULL:");
640 Map <String, Object> reqCtx = bp.getRequestContext ();
641 Map <String, List <String>> headers = new HashMap <> ();
643 String userCredentials = this.getEncryptedProperty(BPEL_AUTH_PROP, "", ENCRYPTION_KEY_PROP);
645 String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ());
646 reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers);
647 headers.put ("Authorization", Collections.singletonList (basicAuth));
648 } catch (Exception e) {
649 LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "getNotifyEP", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e);
650 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, "Unable to set authorization in callback request");
656 public String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
658 return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey));
659 } catch (GeneralSecurityException e) {
660 LOGGER.debug("Exception while decrypting property: " + this.environment.getProperty(key), e);