diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2017-09-18 12:58:10 +0530 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2017-09-18 12:58:10 +0530 |
commit | 043f000141590ef5c5944b6d717c7a592df69c47 (patch) | |
tree | 32a29bf25d81be8e5c08ce793d395ff2a9f43a3e /adapters/mso-network-adapter/src/main/java | |
parent | 5e2aa1fec3c51e8eb0e6b43285c8414105a51b2f (diff) |
Fixed issues in adapter package
Issue-Id: SO-141
Change-Id: I1a6905aa7e1328e47b3d0f7580a1dca33c6a069c
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'adapters/mso-network-adapter/src/main/java')
4 files changed, 64 insertions, 61 deletions
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java index 83cadb8878..b7ab5043f3 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/BpelRestClient.java @@ -143,9 +143,10 @@ public class BpelRestClient { } public void setRetryCount(int retryCount) { + int retCnt = 0; if (retryCount < 0) - retryCount = DEFAULT_RETRY_COUNT; - this.retryCount = retryCount; + retCnt = DEFAULT_RETRY_COUNT; + this.retryCount = retCnt; } public int getRetryInterval() { @@ -172,7 +173,7 @@ public class BpelRestClient { } public void setRetryList(String retryList) { - Set<Integer> s = new TreeSet<Integer>(); + Set<Integer> s = new TreeSet<>(); for (String t : retryList.split("[, ]")) { try { s.add(Integer.parseInt(t)); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java index 0878bc54c9..74c39af68a 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,10 +132,10 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <String> networkId = new Holder <String> (); - Holder <String> neutronNetworkId = new Holder <String> (); - Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> (); - Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <NetworkRollback> networkRollback = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); try { networkAdapter.createNetwork (cloudSiteId, @@ -423,8 +424,6 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoRequest msoRequest, String notificationUrl) { String error; - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); MsoLogger.setLogContext (msoRequest); String serviceName = "DeleteNetworkA"; MsoLogger.setServiceName (serviceName); @@ -434,7 +433,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory); // Synchronous Web Service Outputs - Holder <Boolean> networkDeleted = new Holder <Boolean> (); + Holder <Boolean> networkDeleted = new Holder <> (); try { networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, msoRequest, networkDeleted); @@ -488,8 +487,6 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { String error; String serviceName = "RollbackNetworkA"; MsoLogger.setServiceName (serviceName); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis (); // rollback may be null (e.g. if network already existed when Create was called) if (rollback == null) { LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null"); @@ -602,13 +599,16 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { if(null != epUrl) { LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ()); + bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); + } + else { + LOGGER.debug ("Notification Endpoint URL is NULL: "); } - bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ()); // authentication try { Map <String, Object> reqCtx = bp.getRequestContext (); - Map <String, List <String>> headers = new HashMap <String, List <String>> (); + Map <String, List <String>> headers = new HashMap <> (); String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP, "", @@ -631,7 +631,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry (); @@ -649,7 +649,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry (); @@ -667,7 +667,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap (); if (hMap != null && hMap.value != null) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); sMap = hMap.value; QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry (); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java index cf61d9af73..ccac38a58c 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,7 +128,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder <String> neutronNetworkId, Holder <Map <String, String>> subnetIdMap, Holder <NetworkRollback> rollback) throws NetworkException { - Holder <String> networkFqdn = new Holder <String> (); + Holder <String> networkFqdn = new Holder <> (); createNetwork (cloudSiteId, tenantId, networkType, @@ -315,13 +316,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Response successfully received from OpenStack", "OpenStack", "QueryNetwork", null); } catch (MsoException me) { LOGGER.recordMetricEvent (queryNetworkStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack", "OpenStack", "QueryNetwork", null); - String error = "Create Network (neutron): query network " + networkName - + " in " - + cloudSiteId - + "/" - + tenantId - + ": " - + me; LOGGER.error (MessageEnum.RA_QUERY_NETWORK_EXC, networkName, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while querying network from OpenStack", me); me.addContext (CREATE_NETWORK_CONTEXT); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while querying network from OpenStack"); @@ -472,7 +466,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet")) { @@ -490,7 +484,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } subnetIdMap.value = sMap; - String msg = "Found Existing network stack, status=" + heatStack.getStatus () + " for Heat mode"; LOGGER.warn (MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "", "", MsoLogger.ErrorCode.DataError, "Found Existing network stack, status=" + heatStack.getStatus ()); LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Suc, "Found Existing network stack"); } @@ -588,7 +581,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Deploy the network stack // Ignore MsoStackAlreadyExists exception because we already checked. - long createStackStartTime = System.currentTimeMillis (); try { if (backout == null) backout = true; @@ -628,7 +620,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } Map <String, Object> outputs = heatStack.getOutputs (); - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet")) { @@ -943,7 +935,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String previousNetworkName = (String) heatParams.get("network_name"); String previousPhysicalNetwork = (String) heatParams.get(PHYSICAL_NETWORK); - List<Integer> previousVlans = new ArrayList<Integer>(); + List<Integer> previousVlans = new ArrayList<>(); String vlansParam = (String) heatParams.get(VLANS); if (vlansParam != null) { for (String vlan : vlansParam.split(",")) { @@ -1087,7 +1079,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } Map<String, Object> outputs = heatStack.getOutputs(); - Map<String, String> sMap = new HashMap<String, String>(); + Map<String, String> sMap = new HashMap<>(); if (outputs != null) { for (String key : outputs.keySet()) { if (key != null && key.startsWith("subnet")) { @@ -1108,7 +1100,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Reach this point if createStack is successful. // Populate remaining rollback info and response parameters. networkRollback.setNetworkStackId(heatStack.getCanonicalName()); - networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); + if(null != outputs) { + networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); + } + else { + LOGGER.debug("outputs is NULL"); + } networkRollback.setNetworkType(networkType); // Save previous parameters networkRollback.setNetworkName(previousNetworkName); @@ -1332,8 +1329,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER,msoPropertiesFactory,cloudConfigFactory); MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory); - String mode = null; - String neutronId = null; + String mode; + String neutronId; // Try Heat first, since networks may be named the same as the Heat stack StackInfo heatStack = null; long queryStackStarttime = System.currentTimeMillis (); @@ -1362,7 +1359,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { neutronId = (String) outputs.get (NETWORK_ID); mode = "HEAT"; - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); if (outputs != null) { for (String key : outputs.keySet ()) { if (key != null && key.startsWith ("subnet_id_")) //multiples subnet_%aaid% outputs @@ -1726,7 +1723,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String external, boolean aic3template) { // Build the common set of HEAT template parameters - Map <String, Object> stackParams = new HashMap <String, Object> (); + Map <String, Object> stackParams = new HashMap <> (); stackParams.put ("network_name", networkName); if (neutronNetworkType == NetworkType.PROVIDER) { @@ -1758,9 +1755,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (!isNullOrEmpty(rt)) { if (aic3template) - buf.append (sep).append ("target:" + rt.toString ()); + buf.append (sep).append ("target:" + rt); else - buf.append (sep).append (rt.toString ()); + buf.append (sep).append (rt); sep = ","; } @@ -1802,7 +1799,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { **/ private void mergePolicyRefs(List <String> pFqdns, Map <String, Object> stackParams) throws MsoException { //Resource Property - List<ContrailPolicyRef> prlist = new ArrayList <ContrailPolicyRef> (); + List<ContrailPolicyRef> prlist = new ArrayList <> (); int index = 1; for (String pf : pFqdns) { if (!isNullOrEmpty(pf)) @@ -1837,7 +1834,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (String pf : pFqdns) { if (!isNullOrEmpty(pf)) { - buf.append (sep).append (pf.toString ()); + buf.append (sep).append (pf); sep = ","; } } @@ -1860,7 +1857,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (String rtf : rtFqdns) { if (!isNullOrEmpty(rtf)) { - buf.append (sep).append (rtf.toString ()); + buf.append (sep).append (rtf); sep = ","; } } @@ -1929,7 +1926,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private String mergeSubnetsAIC3 (String heatTemplate, List <Subnet> subnets, Map <String, Object> stackParams) throws MsoException { //Resource Property - List<ContrailSubnet> cslist = new ArrayList <ContrailSubnet> (); + List<ContrailSubnet> cslist = new ArrayList <> (); for (Subnet subnet : subnets) { ContrailSubnet cs = new ContrailSubnet(); LOGGER.debug("Input Subnet:" + subnet.toString()); @@ -1990,8 +1987,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n" + " value: {get_resource: subnet_%subnetId%}\n"; - String curR = ""; - String curO = ""; + String curR; + String curO; StringBuilder resourcesBuf = new StringBuilder (); StringBuilder outputsBuf = new StringBuilder (); for (Subnet subnet : subnets) { @@ -2063,7 +2060,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private Map <String, String> getSubnetUUId(String key, Map <String, Object> outputs, List <Subnet> subnets) { - Map <String, String> sMap = new HashMap <String, String> (); + Map <String, String> sMap = new HashMap <> (); try{ Object obj = outputs.get(key); @@ -2107,7 +2104,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static String insertStr (String template, String snippet, int index) { - String updatedTemplate = ""; + String updatedTemplate; LOGGER.debug ("Index:" + index + " Snippet:" + snippet); diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java index b90bfdf9d6..7c775eeb88 100644 --- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -135,11 +136,11 @@ public class NetworkAdapterRest { LOGGER.debug ("CreateNetworkTask start"); try { // Synchronous Web Service Outputs - Holder<String> networkId = new Holder<String>(); - Holder<String> neutronNetworkId = new Holder<String>(); - Holder<String> networkFqdn = new Holder<String>(); - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); - Holder<NetworkRollback> rollback = new Holder<NetworkRollback>(); + Holder<String> networkId = new Holder<>(); + Holder<String> neutronNetworkId = new Holder<>(); + Holder<String> networkFqdn = new Holder<>(); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); + Holder<NetworkRollback> rollback = new Holder<>(); String cloudsite = req.getCloudSiteId(); if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { @@ -211,6 +212,7 @@ public class NetworkAdapterRest { rollback.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new CreateNetworkError( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -292,7 +294,7 @@ public class NetworkAdapterRest { public void run() { LOGGER.debug("DeleteNetworkTask start"); try { - Holder<Boolean> networkDeleted = new Holder<Boolean>(); + Holder<Boolean> networkDeleted = new Holder<>(); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { networkDeleted.value = true; } else { @@ -307,6 +309,7 @@ public class NetworkAdapterRest { } response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -337,12 +340,12 @@ public class NetworkAdapterRest { try { int respStatus = HttpStatus.SC_OK; QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null); - Holder<Boolean> networkExists = new Holder<Boolean>(); - Holder<String> networkId = new Holder<String>(); - Holder<String> neutronNetworkId = new Holder<String>(); - Holder<NetworkStatus> status = new Holder<NetworkStatus>(); - Holder<List<String>> routeTargets = new Holder<List<String>>(); - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); + Holder<Boolean> networkExists = new Holder<>(); + Holder<String> networkId = new Holder<>(); + Holder<String> neutronNetworkId = new Holder<>(); + Holder<NetworkStatus> status = new Holder<>(); + Holder<List<String>> routeTargets = new Holder<>(); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest, networkExists, networkId, neutronNetworkId, status, routeTargets, subnetIdMap); @@ -441,6 +444,7 @@ public class NetworkAdapterRest { adapter.rollbackNetwork(nwr); response = new RollbackNetworkResponse(true, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -521,8 +525,8 @@ public class NetworkAdapterRest { public void run() { LOGGER.debug("UpdateNetworkTask start"); try { - Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>(); - Holder<NetworkRollback> rollback = new Holder<NetworkRollback> (); + Holder<Map<String, String>> subnetIdMap = new Holder<>(); + Holder<NetworkRollback> rollback = new Holder<> (); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { subnetIdMap.value = testMap(); @@ -579,6 +583,7 @@ public class NetworkAdapterRest { subnetIdMap.value, req.getMessageId()); } catch (NetworkException e) { + LOGGER.debug ("Exception:", e); eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -591,7 +596,7 @@ public class NetworkAdapterRest { } public static Map<String, String> testMap() { - Map<String, String> m = new HashMap<String, String>(); + Map<String, String> m = new HashMap<>(); m.put("mickey", "7"); m.put("clyde", "10"); m.put("wayne", "99"); |