From 8d977df8ba8a63e8c76f58825854fd53f8e638ba Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Mon, 8 Jan 2018 12:40:46 +0100 Subject: refactoring - add Optional change possible null return value to Optional Change-Id: I70bf78a51b901a74932b00d1d8735bef5eeacef7 Issue-ID: SO-360 Signed-off-by: Lukasz Muszkieta --- .../openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'adapters/mso-tenant-adapter/src/main/java/org/openecomp') diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java index 29f5630586..58169f6f92 100644 --- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java +++ b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java @@ -28,6 +28,7 @@ import javax.jws.WebService; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceContext; +import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; import org.openecomp.mso.properties.MsoPropertiesFactory; import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists; import org.openecomp.mso.adapters.tenant.exceptions.TenantException; @@ -84,7 +85,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { Boolean backout, MsoRequest msoRequest, Holder tenantId, - Holder rollback) throws TenantException, TenantAlreadyExists { + Holder rollback) throws TenantException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (CREATE_TENANT); @@ -99,15 +100,16 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { TenantRollback tenantRollback = new TenantRollback (); tenantRollback.setCloudId (cloudSiteId); tenantRollback.setMsoRequest (msoRequest); - - MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); + MsoTenantUtils tUtils; MsoTenant newTenant = null; String newTenantId; long queryTenantStartTime = System.currentTimeMillis (); try { + tUtils = tFactory.getTenantUtils (cloudSiteId); newTenant = tUtils.queryTenantByName (tenantName, cloudSiteId); logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null); + } catch (MsoException me) { logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", OPENSTACK, QUERY_TENANT, null); String error = "Create Tenant " + tenantName + ": " + me; @@ -166,11 +168,11 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { // Will capture execution time for metrics long startTime = System.currentTimeMillis (); - MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId); - + MsoTenantUtils tUtils = null; MsoTenant qTenant = null; long subStartTime = System.currentTimeMillis (); try { + tUtils = tFactory.getTenantUtils (cloudSiteId); qTenant = tUtils.queryTenant (tenantNameOrId, cloudSiteId); logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null); if (qTenant == null) { -- cgit 1.2.3-korg