From 396cb378ab8940b1adb8ba1adc656d0b4ad66f99 Mon Sep 17 00:00:00 2001 From: Divesh Mirchandani Date: Thu, 14 Sep 2017 19:14:21 +0530 Subject: Fixed SONAR issues Fixed blocker, critical, major & minor SONAR issues. Issue-ID: SDC-343 Change-Id: I72e5a3a7fa7d7407a92f98f77e4334827f70f926 Signed-off-by: dd4616 --- .../java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java | 5 +++++ .../org/openecomp/sdc/heat/datatypes/manifest/FileData.java | 2 +- .../openecomp/sdc/heat/services/tree/HeatTreeManager.java | 12 +++++++++--- .../sdc/heat/services/tree/HeatTreeManagerUtil.java | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'openecomp-be/lib/openecomp-heat-lib/src/main/java') diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java index 249dcaf4a5..f0bb253a4b 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/HeatBoolean.java @@ -24,6 +24,8 @@ import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.heat.services.ErrorCodes; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import java.util.HashSet; import java.util.Set; @@ -33,6 +35,8 @@ public class HeatBoolean { private static Set heatFalse; private static Set heatTrue; + private final static Logger log = (Logger) LoggerFactory.getLogger(HeatBoolean.class.getName()); + static { @@ -90,6 +94,7 @@ public class HeatBoolean { Boolean answer = eval(value); return true; } catch (CoreException ce) { + log.debug("",ce); return false; } } diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java index dd487603e1..81bf2fa5a9 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/manifest/FileData.java @@ -31,7 +31,7 @@ import java.util.function.Predicate; public class FileData { - public static Set heatFileTypes = + protected static final Set heatFileTypes = new HashSet<>(Arrays.asList(Type.HEAT, Type.HEAT_NET, Type.HEAT_VOL)); private Boolean isBase; private String file; diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java index def773d712..372c09cffe 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManager.java @@ -23,7 +23,6 @@ package org.openecomp.sdc.heat.services.tree; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.tosca.services.YamlUtil; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -34,6 +33,7 @@ import org.openecomp.sdc.heat.datatypes.structure.Artifact; import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.tosca.services.YamlUtil; import java.io.InputStream; import java.util.HashMap; @@ -101,10 +101,14 @@ public class HeatTreeManager { .values().stream().filter(heatStructureTree -> tree.getHeat().contains(heatStructureTree)) .forEach(heatStructureTree -> tree.getHeat().remove(heatStructureTree)); - heatContentMap.getFileList().stream().filter(fileName -> !manifestFiles.contains(fileName)) + heatContentMap.getFileList().stream().filter(fileName -> isNotInManifestFiles(fileName)) .forEach(fileName -> addTreeOther(fileName)); } + private boolean isNotInManifestFiles(String fileName) { + return !manifestFiles.contains(fileName); + } + private void addTreeOther(String fileName) { if (tree.getOther() == null) { tree.setOther(new HashSet<>()); @@ -132,7 +136,9 @@ public class HeatTreeManager { Set artifactSet = HeatTreeManagerUtil.getArtifactFiles(filename, hot, globalContext); addHeatArtifactFiles(fileHeatStructureTree, artifactSet); - } catch (Exception ignore) { /* invalid yaml no need to process reference */ } + } catch (Exception ignore) { /* invalid yaml no need to process reference */ + logger.debug("",ignore); + } } diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java index b8df50b87c..3802018c99 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerUtil.java @@ -166,7 +166,7 @@ public class HeatTreeManagerUtil { Map resourceDefValueMap = resource.getProperties() == null ? null : (Map) resource.getProperties().get( PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap()); - if (MapUtils.isNotEmpty(resourceDefValueMap)) { + if (MapUtils.isNotEmpty(resourceDefValueMap) && resourceDefValueMap != null) { Object resourceDefType = resourceDefValueMap.get("type"); if (Objects.nonNull(resourceDefType)) { if (resourceDefType instanceof String) { -- cgit 1.2.3-korg