diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2020-12-16 17:53:52 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2020-12-16 17:57:52 +0100 |
commit | c6ea01c94d56f0e8a78716db6575aac58bd59841 (patch) | |
tree | 9d9323fd585e1e04e50b21f47215e3df683984dc /adapters/mso-adapter-utils/src/main/java/org | |
parent | fcf14bc2eddad4f3ef7f138a5b5c98b1e965fde9 (diff) |
blocker sonar fix
- autowired fields are redundant, they cover the fields from superclass
- logger should be final
Issue-ID: SO-3428
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Change-Id: Idb29369118befb0eda9719e88d53c3885814dfc0
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java/org')
-rw-r--r-- | adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index b875c2c8bb..c8fae84479 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,7 +28,6 @@ package org.onap.so.openstack.utils; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.onap.so.cloud.authentication.AuthenticationMethodFactory; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.logging.filter.base.ErrorCode; @@ -39,7 +40,6 @@ import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.onap.so.openstack.exceptions.MsoTenantAlreadyExists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.woorea.openstack.base.client.OpenStackBaseException; import com.woorea.openstack.base.client.OpenStackConnectException; @@ -59,19 +59,7 @@ import com.woorea.openstack.keystone.utils.KeystoneUtils; public class MsoKeystoneUtils extends MsoTenantUtils { public static final String DELETE_TENANT = "Delete Tenant"; - private static Logger logger = LoggerFactory.getLogger(MsoKeystoneUtils.class); - - @Autowired - private AuthenticationMethodFactory authenticationMethodFactory; - - @Autowired - private MsoHeatUtils msoHeatUtils; - - @Autowired - private MsoNeutronUtils msoNeutronUtils; - - @Autowired - private MsoTenantUtilsFactory tenantUtilsFactory; + private static final Logger LOGGER = LoggerFactory.getLogger(MsoKeystoneUtils.class); /** * Create a tenant with the specified name in the given cloud. If the tenant already exists, an Exception will be @@ -94,7 +82,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Obtain the cloud site information where we will create the tenant Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId); if (!cloudSiteOpt.isPresent()) { - logger.error("{} MSOCloudSite {} not found {} ", MessageEnum.RA_CREATE_TENANT_ERR, cloudSiteId, + LOGGER.error("{} MSOCloudSite {} not found {} ", MessageEnum.RA_CREATE_TENANT_ERR, cloudSiteId, ErrorCode.DataError.getValue()); throw new MsoCloudSiteNotFound(cloudSiteId); } @@ -106,7 +94,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (tenant != null) { // Tenant already exists. Throw an exception - logger.error("{} Tenant name {} already exists on Cloud site id {}, {}", + LOGGER.error("{} Tenant name {} already exists on Cloud site id {}, {}", MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, ErrorCode.DataError.getValue()); throw new MsoTenantAlreadyExists(tenantName, cloudSiteId); } @@ -153,7 +141,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Failed to attach MSO User to the new tenant. Can't operate without access, // so roll back the tenant. if (!backout) { - logger.warn("{} Create Tenant errored, Tenant deletion suppressed {} ", + LOGGER.warn("{} Create Tenant errored, Tenant deletion suppressed {} ", MessageEnum.RA_CREATE_TENANT_ERR, ErrorCode.DataError.getValue()); } else { try { @@ -161,7 +149,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { executeAndRecordOpenstackRequest(request); } catch (Exception e2) { // Just log this one. We will report the original exception. - logger.error("{} Nested exception rolling back tenant {} ", MessageEnum.RA_CREATE_TENANT_ERR, + LOGGER.error("{} Nested exception rolling back tenant {} ", MessageEnum.RA_CREATE_TENANT_ERR, ErrorCode.DataError.getValue(), e2); } } @@ -295,14 +283,14 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Check that the tenant exists. Also, need the ID to delete Tenant tenant = findTenantById(keystoneAdminClient, tenantId); if (tenant == null) { - logger.error("{} Tenant id {} not found on cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, + LOGGER.error("{} Tenant id {} not found on cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, tenantId, cloudSiteId, ErrorCode.DataError.getValue()); return false; } OpenStackRequest<Void> request = keystoneAdminClient.tenants().delete(tenant.getId()); executeAndRecordOpenstackRequest(request); - logger.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName()); + LOGGER.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName()); } catch (OpenStackBaseException e) { // Convert Keystone OpenStackResponseException to MsoOpenstackException throw keystoneErrorToMsoException(e, DELETE_TENANT); @@ -341,7 +329,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { Tenant tenant = findTenantByName(keystoneAdminClient, tenantName); if (tenant == null) { // OK if tenant already doesn't exist. - logger.error("{} Tenant {} not found on Cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, + LOGGER.error("{} Tenant {} not found on Cloud site id {}, {}", MessageEnum.RA_TENANT_NOT_FOUND, tenantName, cloudSiteId, ErrorCode.DataError.getValue()); return false; } @@ -350,7 +338,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { OpenStackRequest<Void> request = keystoneAdminClient.tenants().delete(tenant.getId()); executeAndRecordOpenstackRequest(request); - logger.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName()); + LOGGER.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName()); } catch (OpenStackBaseException e) { // Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown. @@ -419,7 +407,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } catch (RuntimeException e) { String error = "Identity service not found: region=" + region + ",cloud=" + cloudIdentity.getId(); - logger.error("{} Region: {} Cloud identity {} {} Exception in findEndpointURL ", + LOGGER.error("{} Region: {} Cloud identity {} {} Exception in findEndpointURL ", MessageEnum.IDENTITY_SERVICE_NOT_FOUND, region, cloudIdentity.getId(), ErrorCode.DataError.getValue(), e); throw new MsoAdapterException(error, e); @@ -476,7 +464,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (e.getStatus() == 404) { return null; } else { - logger.error("{} {} Openstack Error, GET Tenant by Id ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, + LOGGER.error("{} {} Openstack Error, GET Tenant by Id ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), tenantId, e); throw e; } @@ -505,7 +493,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (e.getStatus() == 404) { return null; } else { - logger.error("{} {} Openstack Error, GET Tenant By Name ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, + LOGGER.error("{} {} Openstack Error, GET Tenant By Name ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), tenantName, e); throw e; } @@ -534,7 +522,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { // Not found by ID. Search for name return findUserByName(adminClient, userNameOrId); } else { - logger.error("{} {} Openstack Error, GET User ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, + LOGGER.error("{} {} Openstack Error, GET User ({}) ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), userNameOrId, e); throw e; } @@ -562,7 +550,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { if (e.getStatus() == 404) { return null; } else { - logger.error("{} {} Openstack Error, GET User By Name ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, + LOGGER.error("{} {} Openstack Error, GET User By Name ({}): ", MessageEnum.RA_CONNECTION_EXCEPTION, ErrorCode.DataError.getValue(), userName, e); throw e; } |