c643443791ae5d59a3dcb1e0d0fabb504c56d5ba
[so.git] / adapters / mso-network-adapter / src / main / java / org / openecomp / mso / adapters / network / MsoNetworkAdapterAsyncImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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.openecomp.mso.adapters.network;
22
23
24 import java.net.MalformedURLException;
25 import java.net.URL;
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31 import javax.jws.WebService;
32 import javax.xml.bind.DatatypeConverter;
33 import javax.xml.namespace.QName;
34 import javax.xml.ws.BindingProvider;
35 import javax.xml.ws.Holder;
36 import javax.xml.ws.handler.MessageContext;
37
38 import org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification;
39 import org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory;
40 import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify;
41 import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify_Service;
42 import org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification;
43 import org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification;
44 import org.openecomp.mso.adapters.network.exceptions.NetworkException;
45 import org.openecomp.mso.cloud.CloudConfigFactory;
46 import org.openecomp.mso.entity.MsoRequest;
47 import org.openecomp.mso.logger.MessageEnum;
48 import org.openecomp.mso.logger.MsoAlarmLogger;
49 import org.openecomp.mso.logger.MsoLogger;
50 import org.openecomp.mso.openstack.beans.NetworkRollback;
51 import org.openecomp.mso.openstack.beans.NetworkStatus;
52 import org.openecomp.mso.openstack.beans.Subnet;
53 import org.openecomp.mso.properties.MsoPropertiesFactory;
54
55
56 @WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.openecomp.mso/networkA")
57 public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {
58
59         MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
60
61         CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();
62
63         public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER";
64     private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
65     private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
66     private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.network.bpelauth";
67     private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
68     /**
69      * Health Check web method. Does nothing but return to show the adapter is deployed.
70      */
71     @Override
72     public void healthCheckA () {
73         LOGGER.debug ("Health check call in Network Adapter");
74     }
75
76     /**
77      * This is the "Create Network" web service implementation.
78      * It will create a new Network of the requested type in the specified cloud
79      * and tenant. The tenant must exist at the time this service is called.
80      *
81      * If a network with the same name already exists, this can be considered a
82      * success or failure, depending on the value of the 'failIfExists' parameter.
83      *
84      * There will be a pre-defined set of network types defined in the MSO Catalog.
85      * All such networks will have a similar configuration, based on the allowable
86      * Openstack networking definitions. This includes basic networks, provider
87      * networks (with a single VLAN), and multi-provider networks (one or more VLANs)
88      *
89      * Initially, all provider networks must be "vlan" type, and multiple segments in
90      * a multi-provider network must be multiple VLANs on the same physical network.
91      *
92      * This service supports two modes of Network creation/update:
93      * - via Heat Templates
94      * - via Neutron API
95      * The network orchestration mode for each network type is declared in its
96      * catalog definition. All Heat-based templates must support some subset of
97      * the same input parameters: network_name, physical_network, vlan(s).
98      *
99      * The method returns the network ID and a NetworkRollback object. This latter
100      * object can be passed as-is to the rollbackNetwork operation to undo everything
101      * that was created. This is useful if a network is successfully created but
102      * the orchestration fails on a subsequent operation.
103      */
104     @Override
105     public void createNetworkA (String cloudSiteId,
106                                 String tenantId,
107                                 String networkType,
108                                 String modelCustomizationUuid,
109                                 String networkName,
110                                 String physicalNetworkName,
111                                 List <Integer> vlans,
112                                 Boolean failIfExists,
113                                 Boolean backout,
114                                 List <Subnet> subnets,
115                                 String messageId,
116                                 MsoRequest msoRequest,
117                                 String notificationUrl) {
118         String error;
119         // Will capture execution time for metrics
120         long startTime = System.currentTimeMillis ();
121         MsoLogger.setLogContext (msoRequest);
122         MsoLogger.setServiceName ("CreateNetworkA");
123         LOGGER.debug ("Async Create Network: " + networkName
124                                       + " of type "
125                                       + networkType
126                                       + " in "
127                                       + cloudSiteId
128                                       + "/"
129                                       + tenantId);
130
131         // Use the synchronous method to perform the actual Create
132         MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
133
134         // Synchronous Web Service Outputs
135         Holder <String> networkId = new Holder <String> ();
136         Holder <String> neutronNetworkId = new Holder <String> ();
137         Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> ();
138         Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();
139
140         try {
141             networkAdapter.createNetwork (cloudSiteId,
142                                           tenantId,
143                                           networkType,
144                                           modelCustomizationUuid,
145                                           networkName,
146                                           physicalNetworkName,
147                                           vlans,
148                                           failIfExists,
149                                           backout,
150                                           subnets,
151                                           msoRequest,
152                                           networkId,
153                                           neutronNetworkId,
154                                           subnetIdMap,
155                                           networkRollback);
156         } catch (NetworkException e) {
157             LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
158             MsoExceptionCategory exCat = null;
159             String eMsg = null;
160             try {
161                 eMsg = e.getFaultInfo ().getMessage ();
162                 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
163             } catch (Exception e1) {
164                 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
165             }
166             // Build and send Asynchronous error response
167             try {
168                 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
169                 notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null);
170             } catch (Exception e1) {
171                 error = "Error sending createNetwork notification " + e1.getMessage ();
172                 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
173                 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
174             }
175             return;
176         }
177         LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName);
178         // Build and send Asynchronous response
179         try {
180             NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
181             notifyPort.createNetworkNotification (messageId,
182                                                   true,
183                                                   null,
184                                                   null,
185                                                   networkId.value,
186                                                   neutronNetworkId.value,
187                                                   copyCreateSubnetIdMap (subnetIdMap),
188                                                   copyNrb (networkRollback));
189         } catch (Exception e) {
190             error = "Error sending createNetwork notification " + e.getMessage ();
191             LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
192             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
193         }
194         return;
195     }
196
197     /**
198      * This is the "Update Network" web service implementation.
199      * It will update an existing Network of the requested type in the specified cloud
200      * and tenant. The typical use will be to replace the VLANs with the supplied
201      * list (to add or remove a VLAN), but other properties may be updated as well.
202      *
203      * There will be a pre-defined set of network types defined in the MSO Catalog.
204      * All such networks will have a similar configuration, based on the allowable
205      * Openstack networking definitions. This includes basic networks, provider
206      * networks (with a single VLAN), and multi-provider networks (one or more VLANs).
207      *
208      * Initially, all provider networks must currently be "vlan" type, and multi-provider
209      * networks must be multiple VLANs on the same physical network.
210      *
211      * This service supports two modes of Network update:
212      * - via Heat Templates
213      * - via Neutron API
214      * The network orchestration mode for each network type is declared in its
215      * catalog definition. All Heat-based templates must support some subset of
216      * the same input parameters: network_name, physical_network, vlan, segments.
217      *
218      * The method returns a NetworkRollback object. This object can be passed
219      * as-is to the rollbackNetwork operation to undo everything that was updated.
220      * This is useful if a network is successfully updated but orchestration
221      * fails on a subsequent operation.
222      */
223     @Override
224     public void updateNetworkA (String cloudSiteId,
225                                 String tenantId,
226                                 String networkType,
227                                 String modelCustomizationUuid,
228                                 String networkId,
229                                 String networkName,
230                                 String physicalNetworkName,
231                                 List <Integer> vlans,
232                                 List <Subnet> subnets,
233                                 String messageId,
234                                 MsoRequest msoRequest,
235                                 String notificationUrl) {
236         String error;
237         // Will capture execution time for metrics
238         long startTime = System.currentTimeMillis ();
239         String serviceName = "UpdateNetworkA";
240         MsoLogger.setServiceName (serviceName);
241         MsoLogger.setLogContext (msoRequest);
242         LOGGER.debug ("Async Update Network: " + networkId
243                       + " of type "
244                       + networkType
245                       + "in "
246                       + cloudSiteId
247                       + "/"
248                       + tenantId);
249
250         // Use the synchronous method to perform the actual Create
251         MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
252
253         // Synchronous Web Service Outputs
254         Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> ();
255         Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();
256
257         try {
258             networkAdapter.updateNetwork (cloudSiteId,
259                                           tenantId,
260                                           networkType,
261                                           modelCustomizationUuid,
262                                           networkId,
263                                           networkName,
264                                           physicalNetworkName,
265                                           vlans,
266                                           subnets,
267                                           msoRequest,
268                                           subnetIdMap,
269                                           networkRollback);
270             MsoLogger.setServiceName (serviceName);
271         } catch (NetworkException e) {
272                 MsoLogger.setServiceName (serviceName);
273             LOGGER.debug ("Got a NetworkException on updateNetwork: ", e);
274             MsoExceptionCategory exCat = null;
275             String eMsg = null;
276             try {
277                 eMsg = e.getFaultInfo ().getMessage ();
278                 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
279             } catch (Exception e1) {
280                 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
281             }
282             // Build and send Asynchronous error response
283             try {
284                 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
285                 notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback));
286             } catch (Exception e1) {
287                 error = "Error sending updateNetwork notification " + e1.getMessage ();
288                 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1);
289                 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
290             }
291             return;
292         }
293         LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId);
294         // Build and send Asynchronous response
295         try {
296             NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
297             notifyPort.updateNetworkNotification (messageId,
298                                                   true,
299                                                   null,
300                                                   null,
301                                                   copyUpdateSubnetIdMap (subnetIdMap),
302                                                   copyNrb (networkRollback));
303         } catch (Exception e) {
304             error = "Error sending updateNotification request" + e.getMessage ();
305             LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e);
306             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
307         }
308         return;
309     }
310
311     /**
312      * This is the queryNetwork method. It returns the existence and status of
313      * the specified network, along with its Neutron UUID and list of VLANs.
314      * This method attempts to find the network using both Heat and Neutron.
315      * Heat stacks are first searched based on the provided network name/id.
316      * If none is found, the Neutron is directly queried.
317      */
318     @Override
319     public void queryNetworkA (String cloudSiteId,
320                                String tenantId,
321                                String networkNameOrId,
322                                String messageId,
323                                MsoRequest msoRequest,
324                                String notificationUrl) {
325         String error;
326         // Will capture execution time for metrics
327         long startTime = System.currentTimeMillis ();
328         MsoLogger.setLogContext (msoRequest);
329         String serviceName = "QueryNetworkA";
330         MsoLogger.setServiceName (serviceName);
331         LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId);
332
333         // Use the synchronous method to perform the actual Create
334         MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
335
336         // Synchronous Web Service Outputs
337         Holder <Boolean> networkExists = new Holder <Boolean> ();
338         Holder <String> networkId = new Holder <String> ();
339         Holder <String> neutronNetworkId = new Holder <String> ();
340         Holder <NetworkStatus> status = new Holder <NetworkStatus> ();
341         Holder <List <Integer>> vlans = new Holder <List <Integer>> ();
342         Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();
343
344         try {
345             networkAdapter.queryNetwork (cloudSiteId,
346                                          tenantId,
347                                          networkNameOrId,
348                                          msoRequest,
349                                          networkExists,
350                                          networkId,
351                                          neutronNetworkId,
352                                          status,
353                                          vlans,
354                                          subnetIdMap);
355             MsoLogger.setServiceName (serviceName);
356         } catch (NetworkException e) {
357                 MsoLogger.setServiceName (serviceName);
358             LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
359             MsoExceptionCategory exCat = null;
360             String eMsg = null;
361             try {
362                 eMsg = e.getFaultInfo ().getMessage ();
363                 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
364             } catch (Exception e1) {
365                 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
366             }
367             // Build and send Asynchronous error response
368             try {
369                 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
370                 notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null);
371             } catch (Exception e1) {
372                 error = "Error sending createNetwork notification " + e1.getMessage ();
373                 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
374                 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
375             }
376             return;
377         }
378         LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId);
379         // Build and send Asynchronous response
380         try {
381             NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
382             org.openecomp.mso.adapters.network.async.client.NetworkStatus networkS = org.openecomp.mso.adapters.network.async.client.NetworkStatus.fromValue (status.value.name ());
383             notifyPort.queryNetworkNotification (messageId,
384                                                  true,
385                                                  null,
386                                                  null,
387                                                  networkExists.value,
388                                                  networkId.value,
389                                                  neutronNetworkId.value,
390                                                  networkS,
391                                                  vlans.value,
392                                                  copyQuerySubnetIdMap (subnetIdMap));
393         } catch (Exception e) {
394             error = "Error sending createNetwork notification " + e.getMessage ();
395             LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
396             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
397         }
398         return;
399     }
400
401     /**
402      * This is the "Delete Network" web service implementation.
403      * It will delete a Network in the specified cloud and tenant.
404      *
405      * If the network is not found, it is treated as a success.
406      *
407      * This service supports two modes of Network creation/update/delete:
408      * - via Heat Templates
409      * - via Neutron API
410      * The network orchestration mode for each network type is declared in its
411      * catalog definition.
412      *
413      * For Heat-based orchestration, the networkId should be the stack ID.
414      * For Neutron-based orchestration, the networkId should be the Neutron network UUID.
415      *
416      * The method returns nothing on success. Rollback is not possible for delete
417      * commands, so any failure on delete will require manual fallout in the client.
418      */
419     @Override
420     public void deleteNetworkA (String cloudSiteId,
421                                 String tenantId,
422                                 String networkType,
423                                 String modelCustomizationUuid,
424                                 String networkId,
425                                 String messageId,
426                                 MsoRequest msoRequest,
427                                 String notificationUrl) {
428         String error;
429         // Will capture execution time for metrics
430         long startTime = System.currentTimeMillis ();
431         MsoLogger.setLogContext (msoRequest);
432         String serviceName = "DeleteNetworkA";
433         MsoLogger.setServiceName (serviceName);
434         LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId);
435
436         // Use the synchronous method to perform the actual Create
437         MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
438
439         // Synchronous Web Service Outputs
440         Holder <Boolean> networkDeleted = new Holder <Boolean> ();
441
442         try {
443             networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted);
444             MsoLogger.setServiceName (serviceName);
445         } catch (NetworkException e) {
446                 MsoLogger.setServiceName (serviceName);
447             LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
448             MsoExceptionCategory exCat = null;
449             String eMsg = null;
450             try {
451                 eMsg = e.getFaultInfo ().getMessage ();
452                 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
453             } catch (Exception e1) {
454                 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
455             }
456             // Build and send Asynchronous error response
457             try {
458                 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
459                 notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null);
460             } catch (Exception e1) {
461                 error = "Error sending createNetwork notification " + e1.getMessage ();
462                 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
463                 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
464             }
465             return;
466         }
467         LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId);
468         // Build and send Asynchronous response
469         try {
470             NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
471             notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value);
472         } catch (Exception e) {
473             error = "Error sending deleteNetwork notification " + e.getMessage ();
474             LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e);
475             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
476         }
477         return;
478     }
479
480     /**
481      * This web service endpoint will rollback a previous Create VNF operation.
482      * A rollback object is returned to the client in a successful creation
483      * response. The client can pass that object as-is back to the rollbackNetwork
484      * operation to undo the creation.
485      *
486      * The rollback includes removing the VNF and deleting the tenant if the
487      * tenant did not exist prior to the VNF creation.
488      */
489     @Override
490     public void rollbackNetworkA (NetworkRollback rollback, String messageId, String notificationUrl) {
491         String error;
492         String serviceName = "RollbackNetworkA";
493         MsoLogger.setServiceName (serviceName);
494         // Will capture execution time for metrics
495         long startTime = System.currentTimeMillis ();
496         // rollback may be null (e.g. if network already existed when Create was called)
497         if (rollback == null) {
498             LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null");
499             return;
500         }
501
502         MsoLogger.setLogContext (rollback.getMsoRequest ());
503         LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", "");
504         // Use the synchronous method to perform the actual Create
505         MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);
506
507         try {
508             networkAdapter.rollbackNetwork (rollback);
509             MsoLogger.setServiceName (serviceName);
510         } catch (NetworkException e) {
511                 MsoLogger.setServiceName (serviceName);
512             LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e);
513             // Build and send Asynchronous error response
514             MsoExceptionCategory exCat = null;
515             String eMsg = null;
516             try {
517                 eMsg = e.getFaultInfo ().getMessage ();
518                 exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
519             } catch (Exception e1) {
520                 LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1);
521             }
522             // Build and send Asynchronous error response
523             try {
524                 NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
525                 notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg);
526             } catch (Exception e1) {
527                 error = "Error sending createNetwork notification " + e1.getMessage ();
528                 LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1);
529                 alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
530             }
531             return;
532         }
533         LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ());
534         // Build and send Asynchronous response
535         try {
536             NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
537             notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null);
538         } catch (Exception e) {
539             error = "Error sending rollbackNetwork notification " + e.getMessage ();
540             LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e);
541             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
542         }
543         return;
544     }
545
546     private org.openecomp.mso.adapters.network.async.client.NetworkRollback copyNrb (Holder <NetworkRollback> hNrb) {
547         org.openecomp.mso.adapters.network.async.client.NetworkRollback cnrb = new org.openecomp.mso.adapters.network.async.client.NetworkRollback ();
548
549         if (hNrb != null && hNrb.value != null) {
550             org.openecomp.mso.adapters.network.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.network.async.client.MsoRequest ();
551
552             cnrb.setCloudId (hNrb.value.getCloudId ());
553             cmr.setRequestId (hNrb.value.getMsoRequest ().getRequestId ());
554             cmr.setServiceInstanceId (hNrb.value.getMsoRequest ().getServiceInstanceId ());
555             cnrb.setMsoRequest (cmr);
556             cnrb.setNetworkId (hNrb.value.getNetworkId ());
557             cnrb.setNetworkStackId (hNrb.value.getNetworkStackId ());
558             cnrb.setNeutronNetworkId (hNrb.value.getNeutronNetworkId ());
559             cnrb.setTenantId (hNrb.value.getTenantId ());
560             cnrb.setNetworkType (hNrb.value.getNetworkType ());
561             cnrb.setNetworkCreated (hNrb.value.getNetworkCreated ());
562             cnrb.setNetworkName (hNrb.value.getNetworkName ());
563             cnrb.setPhysicalNetwork (hNrb.value.getPhysicalNetwork ());
564             List <Integer> vlansc = cnrb.getVlans ();
565             List <Integer> vlansh = hNrb.value.getVlans ();
566             if (vlansh != null) {
567                 vlansc.addAll (vlansh);
568             }
569         }
570         return cnrb;
571     }
572
573     private NetworkAdapterNotify getNotifyEP (String notificationUrl) {
574
575         URL warWsdlLoc = null;
576         try {
577             warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl");
578         } catch (Exception e) {
579             LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e);
580         }
581         if (warWsdlLoc == null) {
582             LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found");
583         } else {
584             try {
585                 LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
586             } catch (Exception e) {
587                 LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e);
588             }
589         }
590
591         NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc,
592                                                                                    new QName ("http://org.openecomp.mso/networkNotify",
593                                                                                               "networkAdapterNotify"));
594
595         NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort ();
596
597         BindingProvider bp = (BindingProvider) notifyPort;
598
599         URL epUrl = null;
600         try {
601             epUrl = new URL (notificationUrl);
602         } catch (MalformedURLException e1) {
603             LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1);
604         }
605
606         LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());
607
608         bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());
609
610         // authentication
611         try {
612             Map <String, Object> reqCtx = bp.getRequestContext ();
613             Map <String, List <String>> headers = new HashMap <String, List <String>> ();
614
615             String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP,
616                                                                                              "",
617                                                                                           ENCRYPTION_KEY);
618
619             String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ());
620             reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers);
621             headers.put ("Authorization", Collections.singletonList (basicAuth));
622         } catch (Exception e) {
623             String error1 = "Unable to set authorization in callback request" + e.getMessage ();
624             LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e);
625             alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error1);
626         }
627
628         return notifyPort;
629     }
630
631     private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap (Holder <Map <String, String>> hMap) {
632
633         CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap ();
634
635         if (hMap != null && hMap.value != null) {
636             Map <String, String> sMap = new HashMap <String, String> ();
637             sMap = hMap.value;
638             CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry ();
639
640             for (String key : sMap.keySet ()) {
641                 entry.setKey (key);
642                 entry.setValue (sMap.get (key));
643                 subnetIdMap.getEntry ().add (entry);
644             }
645         }
646         return subnetIdMap;
647     }
648
649     private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap (Holder <Map <String, String>> hMap) {
650
651         UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap ();
652
653         if (hMap != null && hMap.value != null) {
654             Map <String, String> sMap = new HashMap <String, String> ();
655             sMap = hMap.value;
656             UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry ();
657
658             for (String key : sMap.keySet ()) {
659                 entry.setKey (key);
660                 entry.setValue (sMap.get (key));
661                 subnetIdMap.getEntry ().add (entry);
662             }
663         }
664         return subnetIdMap;
665     }
666
667     private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap (Holder <Map <String, String>> hMap) {
668
669         QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap ();
670
671         if (hMap != null && hMap.value != null) {
672             Map <String, String> sMap = new HashMap <String, String> ();
673             sMap = hMap.value;
674             QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry ();
675
676             for (String key : sMap.keySet ()) {
677                 entry.setKey (key);
678                 entry.setValue (sMap.get (key));
679                 subnetIdMap.getEntry ().add (entry);
680             }
681         }
682         return subnetIdMap;
683     }
684 }