From 4f2d003bfa91190f44bf70ee3b3deb1a6d720cd0 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Thu, 23 Aug 2018 17:13:42 +0530 Subject: fix sonar critcal issues in R_CloudConfigMigration added specific excpetions instead of generic ones Issue-ID: SO-886 Change-Id: Ib0f2e655a6e58b8dc142233679a53c15b373f117 Signed-off-by: Sandeep J --- .../src/main/java/db/migration/R__CloudConfigMigration.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java/db/migration') diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java index ed64abd982..d638e47e8c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java @@ -2,6 +2,8 @@ package db.migration; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.flywaydb.core.api.MigrationVersion; @@ -14,10 +16,12 @@ import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.logger.MsoLogger; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.Collection; @@ -74,7 +78,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro this.cloudConfig = cloudConfig; } - private CloudConfig loadCloudConfig(InputStream stream) throws Exception { + private CloudConfig loadCloudConfig(InputStream stream) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); R__CloudConfigMigration cloudConfigMigration = mapper.readValue(stream, R__CloudConfigMigration.class); @@ -92,7 +96,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro return "/application" + profile + ".yaml"; } - private void migrateCloudIdentity(Collection entities, Connection connection) throws Exception { + private void migrateCloudIdentity(Collection entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->IdentityService"); String insert = "INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?,?);"; @@ -122,7 +126,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudSite(Collection entities, Connection connection) throws Exception { + private void migrateCloudSite(Collection entities, Connection connection) throws SQLException { LOGGER.debug("Starting migration for CloudConfig-->CloudSite"); String insert = "INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`) " + "VALUES (?,?,?,?,?,?,?,?,?);"; @@ -151,7 +155,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro } } - private void migrateCloudifyManagers(Collection entities, Connection connection) throws Exception { + private void migrateCloudifyManagers(Collection entities, Connection connection) throws SQLException { String insert = "INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`)" + " VALUES (?,?,?,?,?,?);"; -- cgit 1.2.3-korg