From a8a96339680fa1c4df5577285442e902b5637631 Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 19 Aug 2020 18:01:52 +0100 Subject: Fix Vulnerabilities reported by SONAR Change-Id: I8f4e173a4ea5111db55eebaf15be86f1583082ad Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3248 --- .../org/openecomp/core/tools/exportinfo/ExportSerializer.java | 10 +++++----- .../org/openecomp/core/tools/importinfo/ImportSingleTable.java | 8 ++++---- .../main/java/org/openecomp/core/tools/model/TableData.java | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'openecomp-be/tools/zusammen-tools') diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java index b41f74fc69..3454b99dc2 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java @@ -53,8 +53,8 @@ public class ExportSerializer { public void serializeResult(final ResultSet resultSet, final Set filteredItems, final String filteredColumn, Set vlms) { try { TableData tableData = new TableData(); - tableData.definitions = resultSet.getColumnDefinitions().asList().stream().map(ColumnDefinition::new).collect(Collectors.toList()); - String table = tableData.definitions.iterator().next().getTable(); + tableData.getDefinitions().addAll(resultSet.getColumnDefinitions().asList().stream().map(ColumnDefinition::new).collect(Collectors.toList())); + String table = tableData.getDefinitions().iterator().next().getTable(); boolean isElementTable = table.equals(ELEMENT_TABLE_NAME); Iterator iterator = resultSet.iterator(); iterator.forEachRemaining(row -> { @@ -62,14 +62,14 @@ public class ExportSerializer { return; } List rowData = new ArrayList<>(); - for (int i = 0; i < tableData.definitions.size(); i++) { - ColumnDefinition columnDefinition = tableData.definitions.get(i); + for (int i = 0; i < tableData.getDefinitions().size(); i++) { + ColumnDefinition columnDefinition = tableData.getDefinitions().get(i); Name name = dataTypesMap.get(columnDefinition.getType()); boolean checkForVLM = isElementTable && columnDefinition.getName().equals(ELEMENT_INFO_COLUMN_NAME); Object data = convertByType(vlms, row, i, name, checkForVLM); rowData.add(data.toString()); } - tableData.rows.add(rowData); + tableData.getRows().add(rowData); }); ObjectMapper objectMapper = new ObjectMapper(); String fileName = ImportProperties.ROOT_DIRECTORY + File.separator + table + "_" + System.currentTimeMillis() + ".json"; 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 40486c8269..64c595caa5 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 @@ -61,7 +61,7 @@ public class ImportSingleTable { TableData tableData = objectMapper.readValue(file.toFile(), TableData.class); Session session = CassandraSessionFactory.getSession(); PreparedStatement ps = getPrepareStatement(tableData, session); - tableData.rows.forEach(row -> executeQuery(session, ps, tableData.definitions, row)); + tableData.getRows().forEach(row -> executeQuery(session, ps, tableData.getDefinitions(), row)); } catch (IOException e) { Utils.logError(logger, e); } @@ -153,12 +153,12 @@ public class ImportSingleTable { } private String createQuery(TableData tableData) { - ColumnDefinition def = tableData.definitions.iterator().next(); + ColumnDefinition def = tableData.getDefinitions().iterator().next(); StringBuilder sb = new StringBuilder(1024); sb.append(INSERT_INTO).append(def.getKeyspace()).append(".").append(def.getTable()); - sb.append(tableData.definitions.stream().map(ColumnDefinition::getName) + sb.append(tableData.getDefinitions().stream().map(ColumnDefinition::getName) .collect(Collectors.joining(" , ", " ( ", " ) "))); - sb.append(VALUES).append(tableData.definitions.stream().map(definition -> "?") + sb.append(VALUES).append(tableData.getDefinitions().stream().map(definition -> "?") .collect(Collectors.joining(" , ", " ( ", " ) "))).append(";"); return sb.toString(); } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java index a6fdbd801e..77b6ca1b76 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java @@ -21,8 +21,10 @@ package org.openecomp.core.tools.model; import java.util.ArrayList; import java.util.List; +import lombok.Getter; +@Getter public class TableData { - public List definitions = new ArrayList<>(); - public List> rows = new ArrayList<>(); + private final List definitions = new ArrayList<>(); + private final List> rows = new ArrayList<>(); } -- cgit 1.2.3-korg