aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2019-09-19 16:14:01 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-11-03 15:41:37 +0000
commit433947b5ab5e28fc29aee447de934de89a707419 (patch)
treea485b95b2ae7716ced4825fb7b9eb2b6eeb3433b /openecomp-be/lib/openecomp-sdc-translator-lib
parentee64a64fb0705422c18608304e63a505d10d8ba1 (diff)
Centralize onboarding package validation
Change-Id: I3cc58cf15f62008e83cfc7ddb095d07ab216b82a Issue-ID: SDC-2583 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java4
6 files changed, 18 insertions, 19 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
index f1732fa4f9..76ef37327e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
@@ -280,11 +280,11 @@ public class TranslationContext {
}
public void setFiles(Map<String, byte[]> files) {
- this.files.putAll(files);
+ this.files.setFiles(files);
}
- public InputStream getFileContent(String fileName) {
- return files.getFileContent(fileName);
+ public InputStream getFileContentAsStream(final String fileName) {
+ return files.getFileContentAsStream(fileName);
}
public void addFile(String name, byte[] content) {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
index 9c21c9cbf6..6b03e29348 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
@@ -120,7 +120,7 @@ public class HeatToToscaUtil {
public static TranslatorOutput loadAndTranslateTemplateData(FileContentHandler fileNameContentMap) {
HeatToToscaTranslator heatToToscaTranslator = HeatToToscaTranslatorFactory.getInstance().createInterface();
- try (InputStream fileContent = fileNameContentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ try (InputStream fileContent = fileNameContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
heatToToscaTranslator.addManifest(SdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
} catch (IOException e) {
throw new SdcRuntimeException("Failed to read manifest", e);
@@ -128,7 +128,7 @@ public class HeatToToscaUtil {
fileNameContentMap.getFileList().stream().filter(fileName -> !(fileName.equals(SdcCommon.MANIFEST_NAME)))
.forEach(fileName -> heatToToscaTranslator.addFile(fileName,
- FileUtils.toByteArray(fileNameContentMap.getFileContent(fileName))));
+ fileNameContentMap.getFileContent(fileName)));
Map<String, List<ErrorMessage>> errors = heatToToscaTranslator.validate();
if (MapUtils.isNotEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors))) {
@@ -233,7 +233,7 @@ public class HeatToToscaUtil {
fileDataCollection.addBaseFiles(fileData);
}
HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil().yamlToObject(
- translationContext.getFileContent(fileName), HeatOrchestrationTemplate.class);
+ translationContext.getFileContentAsStream(fileName), HeatOrchestrationTemplate.class);
if (MapUtils.isNotEmpty(heatOrchestrationTemplate.getResources())) {
referenced.addAll(applyFilterOnFileCollection(heatOrchestrationTemplate, translationContext,
fileDataCollection, filteredFiles));
@@ -565,7 +565,7 @@ public class HeatToToscaUtil {
private static boolean isNestedVlanResource(String nestedHeatFileName, TranslationContext translationContext) {
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject(
- translationContext.getFileContent(nestedHeatFileName), HeatOrchestrationTemplate.class);
+ translationContext.getFileContentAsStream(nestedHeatFileName), HeatOrchestrationTemplate.class);
return Objects.nonNull(nestedHeatOrchestrationTemplate.getResources()) && nestedHeatOrchestrationTemplate
.getResources().values()
.stream().anyMatch(
@@ -575,7 +575,7 @@ public class HeatToToscaUtil {
public static Optional<String> getSubInterfaceParentPortNodeTemplateId(TranslateTo subInterfaceTo) {
String subInterfaceResourceType = getSubInterfaceResourceType(subInterfaceTo.getResource());
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject(
- subInterfaceTo.getContext().getFileContent(subInterfaceResourceType), HeatOrchestrationTemplate.class);
+ subInterfaceTo.getContext().getFileContentAsStream(subInterfaceResourceType), HeatOrchestrationTemplate.class);
if (Objects.isNull(nestedHeatOrchestrationTemplate.getResources())) {
return Optional.empty();
}
@@ -664,7 +664,7 @@ public class HeatToToscaUtil {
public static boolean isNestedVfcResource(Resource resource, TranslationContext context) {
Optional<String> nestedHeatFileName = HeatToToscaUtil.getNestedHeatFileName(resource);
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject(
- context.getFileContent(nestedHeatFileName.get()), HeatOrchestrationTemplate.class);
+ context.getFileContentAsStream(nestedHeatFileName.get()), HeatOrchestrationTemplate.class);
Map<String, Resource> resources = nestedHeatOrchestrationTemplate.getResources();
return Objects.nonNull(resources) && resources.values().stream()
.anyMatch(ConsolidationDataUtil::isComputeResource);
@@ -1366,8 +1366,8 @@ public class HeatToToscaUtil {
private static FileContentHandler getCsarArtifactFiles(TranslationContext translationContext) {
FileContentHandler artifactFiles = new FileContentHandler();
- artifactFiles.setFiles(translationContext.getFiles());
- artifactFiles.setFiles(translationContext.getExternalArtifacts());
+ artifactFiles.addAll(translationContext.getFiles());
+ artifactFiles.addAll(translationContext.getExternalArtifacts());
HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(translationContext.getFiles());
heatTreeManager.createTree();
@@ -1415,7 +1415,7 @@ public class HeatToToscaUtil {
}
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil().yamlToObject(
- translationContext.getFileContent(nestedHeatFileName.get()), HeatOrchestrationTemplate.class);
+ translationContext.getFileContentAsStream(nestedHeatFileName.get()), HeatOrchestrationTemplate.class);
if (MapUtils.isNotEmpty(nestedHeatOrchestrationTemplate.getResources())) {
ContrailV2VirtualMachineInterfaceHelper contrailV2VirtualMachineInterfaceHelper =
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
index 32b5e29ac7..866f78c1b5 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
@@ -129,7 +129,7 @@ public class TranslationService {
TranslationContext context) {
String heatFileName = heatFileData.getFile();
HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil()
- .yamlToObject(context.getFileContent(heatFileName), HeatOrchestrationTemplate.class);
+ .yamlToObject(context.getFileContentAsStream(heatFileName), HeatOrchestrationTemplate.class);
translateInputParameters(serviceTemplate, heatOrchestrationTemplate, heatFileData, context,
heatFileName);
@@ -389,7 +389,7 @@ public class TranslationService {
}
for (FileData fileRelatedData : fileRelatedDataList) {
if (fileRelatedData.getType().equals(FileData.Type.HEAT_ENV)) {
- return new YamlUtil().yamlToObject(context.getFileContent(fileRelatedData.getFile()),
+ return new YamlUtil().yamlToObject(context.getFileContentAsStream(fileRelatedData.getFile()),
Environment.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
index 588c403f7d..6328541927 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
@@ -81,7 +81,7 @@ public class VolumeTranslationHelper {
String resourceId, TranslateTo translateTo, List<FileData> fileDatas) {
for (FileData data : fileDatas) {
HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil()
- .yamlToObject(translateTo.getContext().getFiles().getFileContent(data.getFile()),
+ .yamlToObject(translateTo.getContext().getFiles().getFileContentAsStream(data.getFile()),
HeatOrchestrationTemplate.class);
Map<String, Output> outputs = heatOrchestrationTemplate.getOutputs();
if (Objects.isNull(outputs)) {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
index 812fcc90d6..16316f45af 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
@@ -28,7 +28,6 @@ import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.Resource;
@@ -237,7 +236,7 @@ public class FunctionTranslationGetAttrImpl implements FunctionTranslation {
return Optional.empty();
}
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil()
- .yamlToObject(context.getFiles().getFileContent(nestedFile.get()), HeatOrchestrationTemplate.class);
+ .yamlToObject(context.getFiles().getFileContentAsStream(nestedFile.get()), HeatOrchestrationTemplate.class);
translatedAttributes.addAll(nestedHeatOrchestrationTemplate.getOutputs().keySet());
return Optional.of(translatedAttributes);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
index 6b7f1cf5b9..e7449c4105 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
@@ -103,7 +103,7 @@ abstract class BaseResourceConnection<T> {
.get(translateTo.getResource().getType());
List<String> paramNames;
HeatOrchestrationTemplate nestedHeatOrchestrationTemplate = new YamlUtil()
- .yamlToObject(translateTo.getContext().getFileContent(nestedFileData.getFile()),
+ .yamlToObject(translateTo.getContext().getFileContentAsStream(nestedFileData.getFile()),
HeatOrchestrationTemplate.class);
List<Map<String, T>> exposedConnectionPoints = getAllConnectionPoints();
for (Map<String, T> connectionPointsMap : exposedConnectionPoints) {
@@ -148,7 +148,7 @@ abstract class BaseResourceConnection<T> {
return Collections.emptyList();
}
HeatOrchestrationTemplate mappedNestedHeatOrchestrationTemplate = new YamlUtil()
- .yamlToObject(translateTo.getContext().getFileContent(mappedNestedHeatFileName),
+ .yamlToObject(translateTo.getContext().getFileContentAsStream(mappedNestedHeatFileName),
HeatOrchestrationTemplate.class);
ServiceTemplate mappedNestedServiceTemplate =
translateTo.getContext().getTranslatedServiceTemplates().get(mappedNestedHeatFileName);