diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2018-01-08 12:40:46 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2018-01-29 12:58:05 +0100 |
commit | 8d977df8ba8a63e8c76f58825854fd53f8e638ba (patch) | |
tree | 7a1e606d524ff5ea67715f4b1ef00b94545e9e61 /adapters/mso-tenant-adapter | |
parent | 1672a4db05c0e313ce258efe26a75f995c162bb5 (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-tenant-adapter')
-rw-r--r-- | adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java | 12 |
1 files changed, 7 insertions, 5 deletions
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 <String> tenantId, - Holder <TenantRollback> rollback) throws TenantException, TenantAlreadyExists { + Holder <TenantRollback> 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) { |