Solve BE issues from sonar
Change-Id: Ide67cbc4418e94907437053e2db16b94c51da4ee
Issue-ID: SDC-1948
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
index 3f3f2ae..e6a6491 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
@@ -37,7 +37,6 @@
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
index 0ea9662..89ed22f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
@@ -39,7 +39,6 @@
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleChangeInfoBase.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleChangeInfoBase.java
index dcce9b0..a63fe20 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleChangeInfoBase.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleChangeInfoBase.java
@@ -22,6 +22,8 @@
public class LifecycleChangeInfoBase {
+ private String userRemarks;
+
public LifecycleChangeInfoBase() {
}
@@ -30,8 +32,6 @@
this.userRemarks = userRemarks;
}
- private String userRemarks;
-
public String getUserRemarks() {
return userRemarks;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogic.java
index 6565e96..eca7086 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsValuesMergingBusinessLogic.java
@@ -7,7 +7,6 @@
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.model.InputDefinition;
-import java.util.List;
@org.springframework.stereotype.Component
public class InputsValuesMergingBusinessLogic {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsRedeclareHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsRedeclareHandler.java
index f331239..a60b0f0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsRedeclareHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsRedeclareHandler.java
@@ -3,7 +3,6 @@
import org.openecomp.sdc.be.components.merge.input.DeclaredInputsResolver;
import org.openecomp.sdc.be.components.merge.input.InputsValuesMergingBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ESGenericIdDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ESGenericIdDAO.java
index e10930d..9c534d0 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ESGenericIdDAO.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ESGenericIdDAO.java
@@ -85,7 +85,7 @@
T ret = null;
try {
- ret = (T) jsonMapper.readValue(response.getSourceAsString(), clazz);
+ ret = jsonMapper.readValue(response.getSourceAsString(), clazz);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
index 0efbb9f..284b91a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
@@ -52,7 +52,7 @@
Statement select = QueryBuilder.select().countAll().from(tableName).limit(10);
try {
ResultSet res = session.execute(select);
- return Either.left((res.one().getLong("count") != 0 ? false : true));
+ return Either.left(res.one().getLong("count") == 0);
} catch (Exception e) {
logger.debug("Failed check if table is empty", e);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
index 9ff82f4..783eb95 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
@@ -18,6 +18,7 @@
@Component("operational-environment-dao")
public class OperationalEnvironmentDao extends CassandraDao {
+ private static final String OPERATIONAL_ENVIRONMENT_DAO = "OperationalEnvironmentDao";
private static Logger logger = Logger.getLogger(OperationalEnvironmentDao.class.getName());
private OperationalEnvironmentsAccessor operationalEnvironmentsAccessor;
@@ -36,13 +37,13 @@
operationalEnvironmentsAccessor = manager.createAccessor(OperationalEnvironmentsAccessor.class);
logger.debug("** OperationalEnvironmentDao created");
} else {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** OperationalEnvironmentDao failed");
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, OPERATIONAL_ENVIRONMENT_DAO, OPERATIONAL_ENVIRONMENT_DAO, "** OperationalEnvironmentDao failed");
throw new RuntimeException("OperationalEnvironment keyspace [" + keyspace + "] failed to connect with error : "
+ result.right().value());
}
} else {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** Cassandra client isn't connected");
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** OperationalEnvironmentDao created, but not connected");
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, OPERATIONAL_ENVIRONMENT_DAO, OPERATIONAL_ENVIRONMENT_DAO, "** Cassandra client isn't connected");
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, OPERATIONAL_ENVIRONMENT_DAO, OPERATIONAL_ENVIRONMENT_DAO, "** OperationalEnvironmentDao created, but not connected");
}
}
public CassandraOperationStatus save(OperationalEnvironmentEntry operationalEnvironmentEntry) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
index 6c74543..5af12a8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
@@ -40,6 +40,17 @@
public class SdcSchemaBuilder {
+ /**
+ * creat key space statment for SimpleStrategy
+ */
+ private static final String CREATE_KEYSPACE_SIMPLE_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'SimpleStrategy', %s};";
+ /**
+ * creat key space statment for NetworkTopologyStrategy
+ */
+ private static final String CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'NetworkTopologyStrategy', %s};";
+
+ private static Logger log = Logger.getLogger(SdcSchemaBuilder.class.getName());
+
private SdcSchemaUtils sdcSchemaUtils;
private Supplier<Configuration.CassandrConfig> cassandraConfigSupplier;
@@ -47,16 +58,6 @@
this.sdcSchemaUtils = sdcSchemaUtils;
this.cassandraConfigSupplier = cassandraConfigSupplier;
}
- /**
- * creat key space statment for SimpleStrategy
- */
- private static final String CREATE_KEYSPACE_SIMPLE_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'SimpleStrategy', %s};";
- /**
- * creat key space statment for NetworkTopologyStrategy
- */
- private static final String CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'NetworkTopologyStrategy', %s};";
-
- private static Logger log = Logger.getLogger(SdcSchemaBuilder.class.getName());
//TODO remove after 1707_OS migration
private static void handle1707OSMigration(Map<String, Map<String, List<String>>> cassndraMetadata, Map<String, List<ITableDescription>> schemeData){
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
index 360d2e6..f68cd52 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java
@@ -34,6 +34,7 @@
ConfigurationSource configurationSource = null;
private static ConfigurationManager instance;
+ Map<String, Object> configurations = new HashMap<>();
public ConfigurationManager(ConfigurationSource configurationSource) {
super();
@@ -42,8 +43,6 @@
instance = this;
}
- Map<String, Object> configurations = new HashMap<>();
-
private void loadConfigurationFiles() {
loadConfigurationClass(Configuration.class);