From 7b9c6ebc95a237b2657d0619d72f64466c80b2eb Mon Sep 17 00:00:00 2001 From: Aravindhan123 Date: Tue, 12 Dec 2017 14:55:31 +0530 Subject: Fix Sonar Issues Handles translator-core ToscaConverterImpl violations. Change-Id: I751ffdde851e23a977c6c05fc1fe5551f247a670 Issue-ID: SDC-343 Signed-off-by: Aravindhan123 --- .../openecomp/core/impl/ToscaConverterImpl.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'openecomp-be') diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java index 9b3a300934..a5421c0be8 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java @@ -67,6 +67,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -77,9 +78,7 @@ import java.util.regex.Pattern; public class ToscaConverterImpl implements ToscaConverter { - public ToscaConverterImpl() { - - } + private static final String ORIGINAL = ".original"; @Override public ToscaServiceModel convert(FileContentHandler fileContentHandler) @@ -108,6 +107,9 @@ public class ToscaConverterImpl implements ToscaConverter { case definitionsFile: handleDefintionTemplate(fileEntry.getKey(), csarFiles, gsst); break; + + default: + break; } } handleMetadataFile(csarFiles); @@ -118,7 +120,7 @@ public class ToscaConverterImpl implements ToscaConverter { private void handleMetadataFile(Map csarFiles) { byte[] bytes = csarFiles.remove(metadataFile); if (bytes != null) { - csarFiles.put(metadataFile + ".original", bytes); + csarFiles.put(metadataFile + ORIGINAL, bytes); } } @@ -159,8 +161,8 @@ public class ToscaConverterImpl implements ToscaConverter { addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates); toscaServiceModel.setEntryDefinitionServiceTemplate(mainStName); toscaServiceModel.setServiceTemplates(serviceTemplates); - externalFilesHandler.addFile(metadataFile + ".original", - csarFiles.get(metadataFile + ".original")); + externalFilesHandler.addFile(metadataFile + ORIGINAL, + csarFiles.get(metadataFile + ORIGINAL)); toscaServiceModel.setArtifactFiles(externalFilesHandler); if(MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())) { @@ -277,7 +279,7 @@ public class ToscaConverterImpl implements ToscaConverter { } private void convertNodeTypes(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) { - Map nodeTypes = (Map) readerService.getNodeTypes(); + Map nodeTypes = readerService.getNodeTypes(); if (MapUtils.isEmpty(nodeTypes)) { return; } @@ -339,14 +341,12 @@ public class ToscaConverterImpl implements ToscaConverter { String inputsOrOutputs, String parameterId, ParameterDefinition parameterDefinition) { - switch (inputsOrOutputs) { - case inputs: - DataModelUtil - .addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition); - break; - case outputs: - DataModelUtil - .addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition); + if (inputsOrOutputs.equals(inputs)) { + DataModelUtil + .addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition); + } else if (inputsOrOutputs.equals(outputs)) { + DataModelUtil + .addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition); } } -- cgit 1.2.3-korg