aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter/src
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-01-08 12:40:46 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-01-29 12:58:05 +0100
commit8d977df8ba8a63e8c76f58825854fd53f8e638ba (patch)
tree7a1e606d524ff5ea67715f4b1ef00b94545e9e61 /adapters/mso-network-adapter/src
parent1672a4db05c0e313ce258efe26a75f995c162bb5 (diff)
refactoring - add Optional
change possible null return value to Optional Change-Id: I70bf78a51b901a74932b00d1d8735bef5eeacef7 Issue-ID: SO-360 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-network-adapter/src')
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java32
1 files changed, 15 insertions, 17 deletions
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 687930673b..2c04ae9d6b 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
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import javax.jws.WebService;
import javax.xml.ws.Holder;
@@ -271,8 +272,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// So this is just catching that error in a bit more obvious way up front.
cloudConfig = cloudConfigFactory.getCloudConfig ();
- CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId);
- if (cloudSite == null)
+ Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
+ if (!cloudSiteOpt.isPresent())
{
String error = "Configuration Error. Stack " + networkName + " in "
+ cloudSiteId
@@ -299,7 +300,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
physicalNetworkName,
vlans,
routeTargets,
- cloudSite);
+ cloudSiteOpt.get());
String mode = networkResource.getOrchestrationMode ();
NetworkType neutronNetworkType = NetworkType.valueOf (networkResource.getNeutronNetworkType ());
@@ -787,8 +788,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
networkRollback.setMsoRequest (msoRequest);
cloudConfig = cloudConfigFactory.getCloudConfig ();
- CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId);
- if (cloudSite == null) {
+ Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite (cloudSiteId);
+ if (!cloudSiteOpt.isPresent()) {
String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in "
+ cloudSiteId
+ "/"
@@ -814,7 +815,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
physicalNetworkName,
vlans,
routeTargets,
- cloudSite);
+ cloudSiteOpt.get());
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
@@ -1233,7 +1234,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder <NetworkStatus> status,
Holder <List <Integer>> vlans,
Holder <Map <String, String>> subnetIdMap) throws NetworkException {
- queryNetwork (cloudSiteId,
+ queryNetworkInfo(cloudSiteId,
tenantId,
networkNameOrId,
msoRequest,
@@ -1242,7 +1243,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
neutronNetworkId,
status,
vlans,
- null,
subnetIdMap);
}
@@ -1257,7 +1257,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder <NetworkStatus> status,
Holder <List <String>> routeTargets,
Holder <Map <String, String>> subnetIdMap) throws NetworkException {
- queryNetwork (cloudSiteId,
+ queryNetworkInfo(cloudSiteId,
tenantId,
networkNameOrId,
msoRequest,
@@ -1266,18 +1266,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
neutronNetworkId,
status,
null,
- routeTargets,
subnetIdMap);
}
/**
- * This is the queryNetwork method. It returns the existence and status of
+ * This is the queryNetworkInfo method. It returns the existence and status of
* the specified network, along with its Neutron UUID and list of VLANs.
* This method attempts to find the network using both Heat and Neutron.
* Heat stacks are first searched based on the provided network name/id.
* If none is found, the Neutron is directly queried.
*/
- private void queryNetwork (String cloudSiteId,
+ private void queryNetworkInfo(String cloudSiteId,
String tenantId,
String networkNameOrId,
MsoRequest msoRequest,
@@ -1286,7 +1285,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder <String> neutronNetworkId,
Holder <NetworkStatus> status,
Holder <List <Integer>> vlans,
- Holder <List <String>> routeTargets,
Holder <Map <String, String>> subnetIdMap) throws NetworkException {
MsoLogger.setLogContext (msoRequest);
MsoLogger.setServiceName ("QueryNetwork");
@@ -1309,9 +1307,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException (error, MsoExceptionCategory.USERDATA);
}
- cloudConfig = cloudConfigFactory.getCloudConfig ();
- CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId);
- if (cloudSite == null)
+ cloudConfig = cloudConfigFactory.getCloudConfig();
+ Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
+ if (!cloudSiteOpt.isPresent())
{
String error = "Configuration Error. Stack " + networkNameOrId + " in "
+ cloudSiteId
@@ -1414,7 +1412,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
status.value = NetworkStatus.NOTFOUND;
neutronNetworkId.value = null;
if (vlans != null)
- vlans.value = new ArrayList <Integer> ();
+ vlans.value = new ArrayList<>();
LOGGER.debug ("Network " + networkNameOrId + " not found");
}