aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonsino, Ofir (os0695) <os0695@intl.att.com>2018-11-20 15:32:06 +0200
committerOren Kleks <orenkle@amdocs.com>2018-11-25 10:46:51 +0000
commit7a55ea6955c0e75fe04c0e1d0af8a346310a75f5 (patch)
treeff81fa94553da37e2fcf10fe969f6c52bd7d669b
parentb734ea21ac7be393c59cf9976f0e5ddeaf27d568 (diff)
Fix Sonar issues
Change-Id: I487f54714f87e993b9fa4a3b43de7a65692922d5 Issue-ID: SDC-1925 Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java3
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/CommandsHolder.java6
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/HealAll.java25
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/SetHealingFlagByItemVersionCommand.java14
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java55
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java3
7 files changed, 17 insertions, 93 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java
index b717fcbee1..ac47de9b20 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java
@@ -24,10 +24,10 @@ import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.core.dao.UniqueValueDaoFactory;
public class UniqueValueDaoFactoryImpl extends UniqueValueDaoFactory {
- private static UniqueValueDao INSTANCE = new UniqueValueCassandraDaoImpl();
+ private static UniqueValueDao instance = new UniqueValueCassandraDaoImpl();
@Override
public UniqueValueDao createInterface() {
- return INSTANCE;
+ return instance;
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
index 8621e73f26..b691d83267 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -20,10 +20,9 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
@Override
public Map<String, Object> readServiceTemplate(byte[] serviceTemplateContent) {
- Map<String, Object> readSt =
+ return
new YamlUtil().yamlToObject(new String(serviceTemplateContent), Map.class);
- return readSt;
}
@Override
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/CommandsHolder.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/CommandsHolder.java
index e5def6f73e..8e32779cb0 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/CommandsHolder.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/CommandsHolder.java
@@ -27,6 +27,9 @@ public class CommandsHolder {
Option.builder(COMMAND_OPTION).hasArg().argName("command").desc("command name, mandatory").build());
registerCommands();
}
+
+ private CommandsHolder() {
+ }
private static void registerCommands() {
new SetHealingFlag().register();
@@ -40,9 +43,6 @@ public class CommandsHolder {
new SetHealingFlagByItemVersionCommand().register();
}
- private CommandsHolder() {
- }
-
public static Optional<Command> getCommand(String[] args) {
CommandLine cmd = parseArgs(args);
return cmd == null || !cmd.hasOption(COMMAND_OPTION) || cmd.getOptionValue(COMMAND_OPTION) == null
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/HealAll.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/HealAll.java
index 8e0bb0e6b6..f55f1e88b1 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/HealAll.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/HealAll.java
@@ -16,7 +16,6 @@ import java.util.stream.Stream;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.core.tools.concurrent.ItemHealingTask;
import org.openecomp.core.tools.exceptions.HealingRuntimeException;
import org.openecomp.core.tools.loaders.VersionInfoCassandraLoader;
import org.openecomp.sdc.healing.api.HealingManager;
@@ -34,7 +33,6 @@ public class HealAll extends Command {
private static final int DEFAULT_THREAD_NUMBER = 100;
private static final String THREAD_NUM_OPTION = "t";
- private static List<ItemHealingTask> tasks = new ArrayList<>();
private VendorSoftwareProductManager vspManager;
private HealingManager healingManager;
@@ -83,27 +81,7 @@ public class HealAll extends Command {
}
private static void executeAllTasks(ExecutorService executor, BufferedWriter log) {
- List<Future<String>> futureTasks;
- try {
- futureTasks = executor.invokeAll(tasks);
- futureTasks.forEach(future -> {
- try {
- log.write(future.get());
- log.newLine();
- } catch (Exception e) {
- writeToLog(e.getMessage(), log);
- }
- });
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- writeToLog("migration tasks failed with message: " + e.getMessage(), log);
- throw new HealingRuntimeException(e);
- }
- boolean isThreadOpen = true;
- while (isThreadOpen) {
- isThreadOpen = futureTasks.stream().anyMatch(future -> !future.isDone());
- }
}
@@ -133,8 +111,7 @@ public class HealAll extends Command {
}
private void addTaskToTasks(VersionInfoEntity versionInfoEntity) {
- tasks.add(new ItemHealingTask(versionInfoEntity.getEntityId(), resolveVersion(versionInfoEntity).toString(),
- vspManager, healingManager));
+
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/SetHealingFlagByItemVersionCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/SetHealingFlagByItemVersionCommand.java
index db90652b8f..ce2f9acf62 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/SetHealingFlagByItemVersionCommand.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/SetHealingFlagByItemVersionCommand.java
@@ -37,11 +37,13 @@ public class SetHealingFlagByItemVersionCommand extends Command {
private static final String ITEM_ID_OPTION = "i";
private static final String VERSION_ID_OPTION = "v";
private static final String PROJECT_OPTION = "o";
+ private static final String ITEM_ID = "item_id";
+ private static final String VERSION_ID = "version_id";
SetHealingFlagByItemVersionCommand() {
- options.addOption(Option.builder(ITEM_ID_OPTION).hasArg().argName("item_id")
+ options.addOption(Option.builder(ITEM_ID_OPTION).hasArg().argName(ITEM_ID)
.desc("id of the item to reset healing flag, mandatory").build());
- options.addOption(Option.builder(VERSION_ID_OPTION).hasArg().argName("version_id")
+ options.addOption(Option.builder(VERSION_ID_OPTION).hasArg().argName(VERSION_ID)
.desc("id of the version to delete from public, mandatory").build());
options.addOption(Option.builder(PROJECT_OPTION).hasArg().argName("old_project_version")
.desc("old project version, mandatory").build());
@@ -62,10 +64,10 @@ public class SetHealingFlagByItemVersionCommand extends Command {
ResultSet listItemVersion = versionCassandraLoader.listItemVersion();
List<HealingEntity> healingEntities = listItemVersion.all().stream().filter(
- entry -> (entry.getString("item_id").equals(itemId)
- && entry.getString("version_id").equals(versionId))).map(entry ->
- new HealingEntity(entry.getString("space"), entry.getString("item_id"),
- entry.getString("version_id"), true, projectVersion)).collect(Collectors.toList());
+ entry -> (entry.getString(ITEM_ID).equals(itemId)
+ && entry.getString(VERSION_ID).equals(versionId))).map(entry ->
+ new HealingEntity(entry.getString("space"), entry.getString(ITEM_ID),
+ entry.getString(VERSION_ID), true, projectVersion)).collect(Collectors.toList());
HealingHandler healingHandler = new HealingHandler();
healingHandler.populateHealingTable(healingEntities);
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java
deleted file mode 100644
index 878390fdc2..0000000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.openecomp.core.tools.concurrent;
-
-import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.concurrent.Callable;
-
-/**
- * Created by ayalaben on 11/7/2017
- */
-public class ItemHealingTask implements Callable<String> {
-
- private String itemId;
- private Version version;
- private VendorSoftwareProductManager vspManager;
- private HealingManager healingManager;
-
- public String getItemId() {
- return itemId;
- }
-
- public String getVersionId() {
-// return version.getId();
- return null;
- }
-
-
- public ItemHealingTask(String itemId, String versionId,
- VendorSoftwareProductManager vspManager,
- HealingManager healingManager) {
-// this.itemId = itemId;
-// this.version = new Version(versionId);
- this.vspManager = vspManager;
- this.healingManager = healingManager;
-
- }
-
- @Override
- public String call() throws Exception {
-// VspDetails vspDetails = vspManager.getVsp(itemId, version);
-//
-// try {
-// healingManager.healItemVersion(itemId, version, ItemType.vsp, true);
-// } catch (Exception e) {
-// return (String
-// .format("healing failed on vsp: %s with id: %s, versionId: %s, with message: %s",
-// vspDetails.getName(), itemId, version.getId(), e.getMessage()));
-// }
-//
-// return String.format("healed vsp: %s, with id: %s, versionId: %s",
-// vspDetails.getName(), itemId, version.getId());
- return null;
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java
index d36b41f7c2..146e173a28 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java
@@ -32,6 +32,8 @@ public class ImportSingleTable {
private static final String INSERT_INTO = "INSERT INTO ";
private static final String VALUES = " VALUES ";
private static final Map<String, PreparedStatement> statementsCache = new HashMap<>();
+
+ public static final ImmutableMap<String, Name> dataTypesMap;
public void importFile(Path file) {
try {
@@ -141,7 +143,6 @@ public class ImportSingleTable {
return sb.toString();
}
- public static final ImmutableMap<String, Name> dataTypesMap;
static {
Builder<String, Name> builder = ImmutableMap.builder();