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 * Modifications Copyright (C) 2018 IBM.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.so.adapters.network;
27 import java.net.MalformedURLException;
29 import java.security.GeneralSecurityException;
30 import java.util.Collections;
31 import java.util.HashMap;
32 import java.util.List;
35 import javax.jws.WebService;
36 import javax.xml.bind.DatatypeConverter;
37 import javax.xml.namespace.QName;
38 import javax.xml.ws.BindingProvider;
39 import javax.xml.ws.Holder;
40 import javax.xml.ws.handler.MessageContext;
42 import org.onap.so.adapters.network.async.client.CreateNetworkNotification;
43 import org.onap.so.adapters.network.async.client.MsoExceptionCategory;
44 import org.onap.so.adapters.network.async.client.NetworkAdapterNotify;
45 import org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service;
46 import org.onap.so.adapters.network.async.client.QueryNetworkNotification;
47 import org.onap.so.adapters.network.async.client.UpdateNetworkNotification;
48 import org.onap.so.adapters.network.exceptions.NetworkException;
49 import org.onap.so.entity.MsoRequest;
50 import org.onap.so.logger.MessageEnum;
51 import org.onap.so.logger.MsoAlarmLogger;
52 import org.onap.so.logger.MsoLogger;
53 import org.onap.so.openstack.beans.NetworkRollback;
54 import org.onap.so.openstack.beans.NetworkStatus;
55 import org.onap.so.openstack.beans.Subnet;
56 import org.onap.so.utils.CryptoUtils;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.core.env.Environment;
59 import org.springframework.stereotype.Component;
62 @WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.onap.so/networkA")
63 public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
65 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,MsoNetworkAdapterAsyncImpl.class);
66 private static final MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
67 private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth";
68 private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
69 private static final String NETWORK_EXCEPTION_MSG="Got a NetworkException on createNetwork: ";
70 private static final String CREATE_NETWORK_ERROR_MSG="Error sending createNetwork notification ";
71 private static final String CREATE_NETWORK_EXCEPTON_MSG="Exception sending createNetwork notification";
72 private static final String MSO_INTERNAL_ERROR_MSG="MsoInternalError";
74 private Environment environment;
77 private MsoNetworkAdapter networkAdapter;
79 * Health Check web method. Does nothing but return to show the adapter is deployed.
82 public void healthCheckA () {
83 LOGGER.debug ("Health check call in Network Adapter");
87 * This is the "Create Network" web service implementation.
88 * It will create a new Network of the requested type in the specified cloud
89 * and tenant. The tenant must exist at the time this service is called.
91 * If a network with the same name already exists, this can be considered a
92 * success or failure, depending on the value of the 'failIfExists' parameter.
94 * There will be a pre-defined set of network types defined in the MSO Catalog.
95 * All such networks will have a similar configuration, based on the allowable
96 * Openstack networking definitions. This includes basic networks, provider
97 * networks (with a single VLAN), and multi-provider networks (one or more VLANs)
99 * Initially, all provider networks must be "vlan" type, and multiple segments in
100 * a multi-provider network must be multiple VLANs on the same physical network.
102 * This service supports two modes of Network creation/update:
103 * - via Heat Templates
105 * The network orchestration mode for each network type is declared in its
106 * catalog definition. All Heat-based templates must support some subset of
107 * the same input parameters: network_name, physical_network, vlan(s).
109 * The method returns the network ID and a NetworkRollback object. This latter
110 * object can be passed as-is to the rollbackNetwork operation to undo everything
111 * that was created. This is useful if a network is successfully created but
112 * the orchestration fails on a subsequent operation.
115 public void createNetworkA (String cloudSiteId,
118 String modelCustomizationUuid,
120 String physicalNetworkName,
121 List <Integer> vlans,
122 Boolean failIfExists,
124 List <Subnet> subnets,
126 MsoRequest msoRequest,
127 String notificationUrl) {
130 MsoLogger.setLogContext (msoRequest);
131 MsoLogger.setServiceName ("CreateNetworkA");
132 LOGGER.debug ("Async Create Network: " + networkName
140 // Use the synchronous method to perform the actual Create
143 // Synchronous Web Service Outputs
144 Holder <String> networkId = new Holder <> ();
145 Holder <String> neutronNetworkId = new Holder <> ();
146 Holder <NetworkRollback> networkRollback = new Holder <> ();
147 Holder <Map <String, String>> subnetIdMap = new Holder <> ();
150 networkAdapter.createNetwork (cloudSiteId,
153 modelCustomizationUuid,
165 } catch (NetworkException e) {
166 LOGGER.debug (NETWORK_EXCEPTION_MSG, e);
167 MsoExceptionCategory exCat = null;
170 eMsg = e.getFaultInfo ().getMessage ();
171 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
172 } catch (Exception e1) {
173 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
175 // Build and send Asynchronous error response
177 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
178 notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null);
179 } catch (Exception e1) {
180 error = CREATE_NETWORK_ERROR_MSG + e1.getMessage ();
181 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError,CREATE_NETWORK_EXCEPTON_MSG, e1);
182 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
186 LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName);
187 // Build and send Asynchronous response
189 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
190 notifyPort.createNetworkNotification (messageId,
195 neutronNetworkId.value,
196 copyCreateSubnetIdMap (subnetIdMap),
197 copyNrb (networkRollback));
198 } catch (Exception e) {
199 error = CREATE_NETWORK_ERROR_MSG + e.getMessage ();
200 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e);
201 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
207 * This is the "Update Network" web service implementation.
208 * It will update an existing Network of the requested type in the specified cloud
209 * and tenant. The typical use will be to replace the VLANs with the supplied
210 * list (to add or remove a VLAN), but other properties may be updated as well.
212 * There will be a pre-defined set of network types defined in the MSO Catalog.
213 * All such networks will have a similar configuration, based on the allowable
214 * Openstack networking definitions. This includes basic networks, provider
215 * networks (with a single VLAN), and multi-provider networks (one or more VLANs).
217 * Initially, all provider networks must currently be "vlan" type, and multi-provider
218 * networks must be multiple VLANs on the same physical network.
220 * This service supports two modes of Network update:
221 * - via Heat Templates
223 * The network orchestration mode for each network type is declared in its
224 * catalog definition. All Heat-based templates must support some subset of
225 * the same input parameters: network_name, physical_network, vlan, segments.
227 * The method returns a NetworkRollback object. This object can be passed
228 * as-is to the rollbackNetwork operation to undo everything that was updated.
229 * This is useful if a network is successfully updated but orchestration
230 * fails on a subsequent operation.
233 public void updateNetworkA (String cloudSiteId,
236 String modelCustomizationUuid,
239 String physicalNetworkName,
240 List <Integer> vlans,
241 List <Subnet> subnets,
243 MsoRequest msoRequest,
244 String notificationUrl) {
247 String serviceName = "UpdateNetworkA";
248 MsoLogger.setServiceName (serviceName);
249 MsoLogger.setLogContext (msoRequest);
250 LOGGER.debug ("Async Update Network: " + networkId
258 // Use the synchronous method to perform the actual Create
261 // Synchronous Web Service Outputs
262 Holder <NetworkRollback> networkRollback = new Holder <> ();
263 Holder <Map <String, String>> subnetIdMap = new Holder <> ();
266 networkAdapter.updateNetwork (cloudSiteId,
269 modelCustomizationUuid,
278 MsoLogger.setServiceName (serviceName);
279 } catch (NetworkException e) {
280 MsoLogger.setServiceName (serviceName);
281 LOGGER.debug ("Got a NetworkException on updateNetwork: ", e);
282 MsoExceptionCategory exCat = null;
285 eMsg = e.getFaultInfo ().getMessage ();
286 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
287 } catch (Exception e1) {
288 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
290 // Build and send Asynchronous error response
292 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
293 notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback));
294 } catch (Exception e1) {
295 error = "Error sending updateNetwork notification " + e1.getMessage ();
296 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1);
297 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
301 LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId);
302 // Build and send Asynchronous response
304 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
305 notifyPort.updateNetworkNotification (messageId,
309 copyUpdateSubnetIdMap (subnetIdMap),
310 copyNrb (networkRollback));
311 } catch (Exception e) {
312 error = "Error sending updateNotification request" + e.getMessage ();
313 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e);
314 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
320 * This is the queryNetwork method. It returns the existence and status of
321 * the specified network, along with its Neutron UUID and list of VLANs.
322 * This method attempts to find the network using both Heat and Neutron.
323 * Heat stacks are first searched based on the provided network name/id.
324 * If none is found, the Neutron is directly queried.
327 public void queryNetworkA (String cloudSiteId,
329 String networkNameOrId,
331 MsoRequest msoRequest,
332 String notificationUrl) {
335 MsoLogger.setLogContext (msoRequest);
336 String serviceName = "QueryNetworkA";
337 MsoLogger.setServiceName (serviceName);
338 LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId);
340 // Use the synchronous method to perform the actual Create
343 // Synchronous Web Service Outputs
344 Holder <Boolean> networkExists = new Holder <> ();
345 Holder <String> networkId = new Holder <> ();
346 Holder <String> neutronNetworkId = new Holder <> ();
347 Holder <NetworkStatus> status = new Holder <> ();
348 Holder <List <Integer>> vlans = new Holder <> ();
349 Holder <Map <String, String>> subnetIdMap = new Holder <> ();
352 networkAdapter.queryNetwork (cloudSiteId,
362 MsoLogger.setServiceName (serviceName);
363 } catch (NetworkException e) {
364 MsoLogger.setServiceName (serviceName);
365 LOGGER.debug (NETWORK_EXCEPTION_MSG, e);
366 MsoExceptionCategory exCat = null;
369 eMsg = e.getFaultInfo ().getMessage ();
370 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
371 } catch (Exception e1) {
372 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
374 // Build and send Asynchronous error response
376 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
377 notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null);
378 } catch (Exception e1) {
379 error = CREATE_NETWORK_ERROR_MSG + e1.getMessage ();
380 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e1);
381 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
385 LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId);
386 // Build and send Asynchronous response
388 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
389 org.onap.so.adapters.network.async.client.NetworkStatus networkS = org.onap.so.adapters.network.async.client.NetworkStatus.fromValue (status.value.name ());
390 notifyPort.queryNetworkNotification (messageId,
396 neutronNetworkId.value,
399 copyQuerySubnetIdMap (subnetIdMap));
400 } catch (Exception e) {
401 error = CREATE_NETWORK_ERROR_MSG + e.getMessage ();
402 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e);
403 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
409 * This is the "Delete Network" web service implementation.
410 * It will delete a Network in the specified cloud and tenant.
412 * If the network is not found, it is treated as a success.
414 * This service supports two modes of Network creation/update/delete:
415 * - via Heat Templates
417 * The network orchestration mode for each network type is declared in its
418 * catalog definition.
420 * For Heat-based orchestration, the networkId should be the stack ID.
421 * For Neutron-based orchestration, the networkId should be the Neutron network UUID.
423 * The method returns nothing on success. Rollback is not possible for delete
424 * commands, so any failure on delete will require manual fallout in the client.
427 public void deleteNetworkA (String cloudSiteId,
430 String modelCustomizationUuid,
433 MsoRequest msoRequest,
434 String notificationUrl) {
436 MsoLogger.setLogContext (msoRequest);
437 String serviceName = "DeleteNetworkA";
438 MsoLogger.setServiceName (serviceName);
439 LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId);
441 // Use the synchronous method to perform the actual Create
444 // Synchronous Web Service Outputs
445 Holder <Boolean> networkDeleted = new Holder <> ();
448 networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted);
449 MsoLogger.setServiceName (serviceName);
450 } catch (NetworkException e) {
451 MsoLogger.setServiceName (serviceName);
452 LOGGER.debug (NETWORK_EXCEPTION_MSG, e);
453 MsoExceptionCategory exCat = null;
456 eMsg = e.getFaultInfo ().getMessage ();
457 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
458 } catch (Exception e1) {
459 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
461 // Build and send Asynchronous error response
463 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
464 notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null);
465 } catch (Exception e1) {
466 error = CREATE_NETWORK_ERROR_MSG + e1.getMessage ();
467 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e1);
468 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
472 LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId);
473 // Build and send Asynchronous response
475 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
476 notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value);
477 } catch (Exception e) {
478 error = "Error sending deleteNetwork notification " + e.getMessage ();
479 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e);
480 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
486 * This web service endpoint will rollback a previous Create VNF operation.
487 * A rollback object is returned to the client in a successful creation
488 * response. The client can pass that object as-is back to the rollbackNetwork
489 * operation to undo the creation.
491 * The rollback includes removing the VNF and deleting the tenant if the
492 * tenant did not exist prior to the VNF creation.
495 public void rollbackNetworkA (NetworkRollback rollback, String messageId, String notificationUrl) {
497 String serviceName = "RollbackNetworkA";
498 MsoLogger.setServiceName (serviceName);
499 // rollback may be null (e.g. if network already existed when Create was called)
500 if (rollback == null) {
501 LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null");
505 MsoLogger.setLogContext (rollback.getMsoRequest ());
506 LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", "");
507 // Use the synchronous method to perform the actual Create
511 networkAdapter.rollbackNetwork (rollback);
512 MsoLogger.setServiceName (serviceName);
513 } catch (NetworkException e) {
514 MsoLogger.setServiceName (serviceName);
515 LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e);
516 // Build and send Asynchronous error response
517 MsoExceptionCategory exCat = null;
520 eMsg = e.getFaultInfo ().getMessage ();
521 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
522 } catch (Exception e1) {
523 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1);
525 // Build and send Asynchronous error response
527 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
528 notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg);
529 } catch (Exception e1) {
530 error = CREATE_NETWORK_ERROR_MSG + e1.getMessage ();
531 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1);
532 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
536 LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ());
537 // Build and send Asynchronous response
539 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
540 notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null);
541 } catch (Exception e) {
542 error = "Error sending rollbackNetwork notification " + e.getMessage ();
543 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e);
544 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error);
549 private org.onap.so.adapters.network.async.client.NetworkRollback copyNrb (Holder <NetworkRollback> hNrb) {
550 org.onap.so.adapters.network.async.client.NetworkRollback cnrb = new org.onap.so.adapters.network.async.client.NetworkRollback ();
552 if (hNrb != null && hNrb.value != null) {
553 org.onap.so.adapters.network.async.client.MsoRequest cmr = new org.onap.so.adapters.network.async.client.MsoRequest ();
555 cnrb.setCloudId (hNrb.value.getCloudId ());
556 cmr.setRequestId (hNrb.value.getMsoRequest ().getRequestId ());
557 cmr.setServiceInstanceId (hNrb.value.getMsoRequest ().getServiceInstanceId ());
558 cnrb.setMsoRequest (cmr);
559 cnrb.setNetworkId (hNrb.value.getNetworkId ());
560 cnrb.setNetworkStackId (hNrb.value.getNetworkStackId ());
561 cnrb.setNeutronNetworkId (hNrb.value.getNeutronNetworkId ());
562 cnrb.setTenantId (hNrb.value.getTenantId ());
563 cnrb.setNetworkType (hNrb.value.getNetworkType ());
564 cnrb.setNetworkCreated (hNrb.value.getNetworkCreated ());
565 cnrb.setNetworkName (hNrb.value.getNetworkName ());
566 cnrb.setPhysicalNetwork (hNrb.value.getPhysicalNetwork ());
567 List <Integer> vlansc = cnrb.getVlans ();
568 List <Integer> vlansh = hNrb.value.getVlans ();
569 if (vlansh != null) {
570 vlansc.addAll (vlansh);
576 private NetworkAdapterNotify getNotifyEP (String notificationUrl) {
578 URL warWsdlLoc = null;
580 warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl");
581 } catch (Exception e) {
582 LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e);
584 if (warWsdlLoc == null) {
585 LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found");
588 LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
589 } catch (Exception e) {
590 LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e);
594 NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc,
595 new QName ("http://org.onap.so/networkNotify",
596 "networkAdapterNotify"));
598 NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort ();
600 BindingProvider bp = (BindingProvider) notifyPort;
604 epUrl = new URL (notificationUrl);
605 } catch (MalformedURLException e1) {
606 LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1);
610 LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());
611 bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());
614 LOGGER.debug ("Notification Endpoint URL is NULL: ");
619 Map <String, Object> reqCtx = bp.getRequestContext ();
620 Map <String, List <String>> headers = new HashMap <> ();
622 String userCredentials = this.getEncryptedProperty (BPEL_AUTH_PROP, "", ENCRYPTION_KEY);
624 String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ());
625 reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers);
626 headers.put ("Authorization", Collections.singletonList (basicAuth));
627 } catch (Exception e) {
628 String error1 = "Unable to set authorization in callback request" + e.getMessage ();
629 LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e);
630 alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error1);
636 public String getEncryptedProperty(String key, String defaultValue, String encryptionKey) {
638 return CryptoUtils.decrypt(this.environment.getProperty(key), encryptionKey);
639 } catch (GeneralSecurityException e) {
640 LOGGER.debug("Exception while decrypting property: " + this.environment.getProperty(key), e);
646 private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap (Holder <Map <String, String>> hMap) {
648 CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap ();
650 if (hMap != null && hMap.value != null) {
651 Map <String, String> sMap = hMap.value;
652 CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry ();
654 for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
655 String key = mapEntry.getKey();
656 String value = mapEntry.getValue();
658 entry.setValue (value);
659 subnetIdMap.getEntry ().add (entry);
665 private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap (Holder <Map <String, String>> hMap) {
667 UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap ();
669 if (hMap != null && hMap.value != null) {
670 Map <String, String> sMap = hMap.value;
671 UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry ();
673 for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
674 String key = mapEntry.getKey();
675 String value = mapEntry.getValue();
677 entry.setValue (value);
678 subnetIdMap.getEntry ().add (entry);
684 private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap (Holder <Map <String, String>> hMap) {
686 QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap ();
688 if (hMap != null && hMap.value != null) {
689 Map <String, String> sMap = hMap.value;
690 QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry ();
692 for (Map.Entry<String,String> mapEntry : sMap.entrySet ()) {
693 String key = mapEntry.getKey();
694 String value = mapEntry.getValue();
696 entry.setValue (value);
697 subnetIdMap.getEntry ().add (entry);