summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java28
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java69
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java218
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java24
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java63
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java203
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java107
9 files changed, 340 insertions, 396 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java
index 533f041621..a1b85daa8c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/HeatFileAnalyzer.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,13 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services;
-import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
-
import java.io.IOException;
import java.util.Map;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
/**
* @author Avrahamg
@@ -31,17 +29,17 @@ import java.util.Map;
*/
public interface HeatFileAnalyzer {
- static boolean isEnvFile(String fileName) {
- return fileName.endsWith(".env");
- }
+ static boolean isEnvFile(String fileName) {
+ return fileName.endsWith(".env");
+ }
- static boolean isYamlFile(String fileName) {
- return fileName.endsWith(".yml") || fileName.endsWith(".yaml");
- }
+ static boolean isYamlFile(String fileName) {
+ return fileName.endsWith(".yml") || fileName.endsWith(".yaml");
+ }
- static boolean isYamlOrEnvFile(String fileName) {
- return isYamlFile(fileName) || isEnvFile(fileName);
- }
+ static boolean isYamlOrEnvFile(String fileName) {
+ return isYamlFile(fileName) || isEnvFile(fileName);
+ }
- AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException;
+ AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java
index 0b82638277..3696bd33fd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionDataExtractor.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.composition;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
@@ -25,7 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData
public interface CompositionDataExtractor {
- CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel);
+ CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel);
- String getComponentDisplayName(String componentName);
+ String getComponentDisplayName(String componentName);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index d33533a7d0..7467d59c04 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -15,9 +15,15 @@
*
* Modifications copyright (c) 2021 Nokia
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -30,61 +36,42 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHe
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
public interface CandidateService {
- Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload,
- String fileSuffix);
- Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData);
+ Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream heatFileToUpload, String fileSuffix);
+
+ Optional<ErrorMessage> validateRawZipData(String fileSuffix, byte[] uploadedFileData);
- OrchestrationTemplateCandidateData createCandidateDataEntity(
- CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
- AnalyzedZipHeatFiles analyzedZipHeatFiles);
+ OrchestrationTemplateCandidateData createCandidateDataEntity(CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles);
- void updateCandidateUploadData(String vspId, Version version,
- OrchestrationTemplateCandidateData uploadData);
+ void updateCandidateUploadData(String vspId, Version version, OrchestrationTemplateCandidateData uploadData);
- Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
- Version version);
+ Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version);
- void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
- FilesDataStructure fileDataStructure);
+ void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version, FilesDataStructure fileDataStructure);
- Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId,
- Version version);
+ Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidate(String vspId, Version version);
- Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId,
- Version version);
+ Optional<OrchestrationTemplateCandidateData> getOrchestrationTemplateCandidateInfo(String vspId, Version version);
- byte[] getZipData(ByteBuffer contentData) throws IOException;
+ byte[] getZipData(ByteBuffer contentData) throws IOException;
- void deleteOrchestrationTemplateCandidate(String vspId, Version version);
+ void deleteOrchestrationTemplateCandidate(String vspId, Version version);
- Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
- OrchestrationTemplateCandidateData candidateDataEntity,
- String manifest,
- OnboardingTypesEnum type,
- Map<String, List<ErrorMessage>> uploadErrors);
+ Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId, OrchestrationTemplateCandidateData candidateDataEntity,
+ String manifest, OnboardingTypesEnum type,
+ Map<String, List<ErrorMessage>> uploadErrors);
- byte[] replaceManifestInZip(ByteBuffer contentData, String manifest,
- OnboardingTypesEnum type) throws IOException;
+ byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, OnboardingTypesEnum type) throws IOException;
- Optional<ManifestContent> createManifest(VspDetails vspDetails,
- FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles);
+ Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
- String createManifest(VspDetails vspDetails, FilesDataStructure structure);
+ String createManifest(VspDetails vspDetails, FilesDataStructure structure);
- String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
+ String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
- Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
+ Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
- void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
+ void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
index 90490e7153..22ec1c3f79 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,24 +18,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
+import java.util.Optional;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import java.util.Optional;
-
public interface ManifestCreator {
- Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure);
- Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest);
+ Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure);
+
+ Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure,
+ ManifestContent existingManifest);
- Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler
- fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
+ Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
- boolean isFileBaseFile(String fileName);
+ boolean isFileBaseFile(String fileName);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
index 04d240a8e6..fffdaef75a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,134 +17,126 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.impl;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.regex.Pattern;
import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
-import java.io.*;
-import java.util.*;
-import java.util.regex.Pattern;
-
public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
- private static final String HEAT_IDENTIFIER_REGEX = "^heat_template_version:.*";
- private static final String HEAT_RESOURCES_REGEX = "^resources:\\s*$";
- private static final String HEAT_PARAMETERS_REGEX = "^parameters:\\s*$";
- private static final String HEAT_CONDITIONS_REGEX = "^conditions:\\s*$";
- private static final String HEAT_OUTPUTS_REGEX = "^outputs:\\s*$";
- private static final String HEAT_PARAMETER_GROUP_REGEX = "^parameter_groups:\\s*$";
- private static final String HEAT_DESCRIPTION_REGEX = "^description:\\s*$";
- //allowing spaces at start followed by 'type:' + spaces + any characters + ('.yml' or '.yaml')+
- // spaces
- private static final String HEAT_NESTED_RESOURCE_REGEX = "\\s*type:\\s*\\S*.(yml|yaml)\\s*$";
-
-
- private static final String IDENTIFIER = "IDENTIFIER";
- private static final String RESOURCES = "RESOURCES";
- private static final String PARAMETERS = "PARAMETERS";
- private static final String CONDITIONS = "CONDITIONS";
- private static final String OUTPUTS = "OUTPUTS";
- private static final String PARAMETER_GROUP = "PARAMETER_GROUP";
- private static final String DESCRIPTION = "DESCRIPTION";
- private static final String NESTED_PATTERN = "NESTED_PATTERN";
-
- private final Map<String, Pattern> patterns;
-
- public HeatFileAnalyzerRowDataImpl() {
- patterns = new HashMap<>();
- patterns.put(IDENTIFIER, Pattern.compile(HEAT_IDENTIFIER_REGEX));
- patterns.put(RESOURCES, Pattern.compile(HEAT_RESOURCES_REGEX));
- patterns.put(PARAMETERS, Pattern.compile(HEAT_PARAMETERS_REGEX));
- patterns.put(CONDITIONS, Pattern.compile(HEAT_CONDITIONS_REGEX));
- patterns.put(OUTPUTS, Pattern.compile(HEAT_OUTPUTS_REGEX));
- patterns.put(PARAMETER_GROUP, Pattern.compile(HEAT_PARAMETER_GROUP_REGEX));
- patterns.put(DESCRIPTION, Pattern.compile(HEAT_DESCRIPTION_REGEX));
- patterns.put(NESTED_PATTERN, Pattern.compile(HEAT_NESTED_RESOURCE_REGEX));
- }
-
- @Override
- public AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files)
- throws IOException {
- AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles();
- for (Map.Entry<String, byte[]> fileData : files.entrySet()) {
- String fileName = fileData.getKey();
- if (!HeatFileAnalyzer.isYamlFile(fileName)) {
- analyzedZipHeatFiles.addOtherNonModuleFile(fileName);
- continue;
- }
-
- boolean foundHeatIdentifier = false;
- try (InputStream is = new ByteArrayInputStream(fileData.getValue());
- BufferedReader bfReader = new BufferedReader(new InputStreamReader(is))) {
+ private static final String HEAT_IDENTIFIER_REGEX = "^heat_template_version:.*";
+ private static final String HEAT_RESOURCES_REGEX = "^resources:\\s*$";
+ private static final String HEAT_PARAMETERS_REGEX = "^parameters:\\s*$";
+ private static final String HEAT_CONDITIONS_REGEX = "^conditions:\\s*$";
+ private static final String HEAT_OUTPUTS_REGEX = "^outputs:\\s*$";
+ private static final String HEAT_PARAMETER_GROUP_REGEX = "^parameter_groups:\\s*$";
+ private static final String HEAT_DESCRIPTION_REGEX = "^description:\\s*$";
+ //allowing spaces at start followed by 'type:' + spaces + any characters + ('.yml' or '.yaml')+
+
+ // spaces
+ private static final String HEAT_NESTED_RESOURCE_REGEX = "\\s*type:\\s*\\S*.(yml|yaml)\\s*$";
+ private static final String IDENTIFIER = "IDENTIFIER";
+ private static final String RESOURCES = "RESOURCES";
+ private static final String PARAMETERS = "PARAMETERS";
+ private static final String CONDITIONS = "CONDITIONS";
+ private static final String OUTPUTS = "OUTPUTS";
+ private static final String PARAMETER_GROUP = "PARAMETER_GROUP";
+ private static final String DESCRIPTION = "DESCRIPTION";
+ private static final String NESTED_PATTERN = "NESTED_PATTERN";
+ private final Map<String, Pattern> patterns;
+
+ public HeatFileAnalyzerRowDataImpl() {
+ patterns = new HashMap<>();
+ patterns.put(IDENTIFIER, Pattern.compile(HEAT_IDENTIFIER_REGEX));
+ patterns.put(RESOURCES, Pattern.compile(HEAT_RESOURCES_REGEX));
+ patterns.put(PARAMETERS, Pattern.compile(HEAT_PARAMETERS_REGEX));
+ patterns.put(CONDITIONS, Pattern.compile(HEAT_CONDITIONS_REGEX));
+ patterns.put(OUTPUTS, Pattern.compile(HEAT_OUTPUTS_REGEX));
+ patterns.put(PARAMETER_GROUP, Pattern.compile(HEAT_PARAMETER_GROUP_REGEX));
+ patterns.put(DESCRIPTION, Pattern.compile(HEAT_DESCRIPTION_REGEX));
+ patterns.put(NESTED_PATTERN, Pattern.compile(HEAT_NESTED_RESOURCE_REGEX));
+ }
- String line;
- boolean isResourcesSection = false;
- Set<String> nestedFilesNames = new HashSet<>();
- while ((line = bfReader.readLine()) != null) {
- if (!foundHeatIdentifier && isMatch(patterns.get(IDENTIFIER), line)) {
- foundHeatIdentifier = true;
- analyzedZipHeatFiles.addModuleFile(fileName);
- if (isResourcesSection) // it means the identifier is located after the resources
- // section
- {
- break;
+ @Override
+ public AnalyzedZipHeatFiles analyzeFilesNotEligibleForModulesFromFileAnalyzer(Map<String, byte[]> files) throws IOException {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles();
+ for (Map.Entry<String, byte[]> fileData : files.entrySet()) {
+ String fileName = fileData.getKey();
+ if (!HeatFileAnalyzer.isYamlFile(fileName)) {
+ analyzedZipHeatFiles.addOtherNonModuleFile(fileName);
+ continue;
}
- } else if (isMatch(patterns.get(RESOURCES), line)) {
- isResourcesSection = true;
- } else if (isResourceSectionEnd(line, isResourcesSection)) {
- if (foundHeatIdentifier) {
- break;
+ boolean foundHeatIdentifier = false;
+ try (InputStream is = new ByteArrayInputStream(fileData.getValue()); BufferedReader bfReader = new BufferedReader(
+ new InputStreamReader(is))) {
+ String line;
+ boolean isResourcesSection = false;
+ Set<String> nestedFilesNames = new HashSet<>();
+ while ((line = bfReader.readLine()) != null) {
+ if (!foundHeatIdentifier && isMatch(patterns.get(IDENTIFIER), line)) {
+ foundHeatIdentifier = true;
+ analyzedZipHeatFiles.addModuleFile(fileName);
+ if (isResourcesSection) // it means the identifier is located after the resources
+
+ // section
+ {
+ break;
+ }
+ } else if (isMatch(patterns.get(RESOURCES), line)) {
+ isResourcesSection = true;
+ } else if (isResourceSectionEnd(line, isResourcesSection)) {
+ if (foundHeatIdentifier) {
+ break;
+ }
+ } else if (isResourcesSection) {
+ Optional<String> optionalNestedFileName = fetchNestedFileName(line);
+ optionalNestedFileName.ifPresent(nestedFilesNames::add);
+ }
+ }
+ analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames, foundHeatIdentifier));
}
- } else if (isResourcesSection) {
- Optional<String> optionalNestedFileName = fetchNestedFileName(line);
- optionalNestedFileName
- .ifPresent(nestedFilesNames::add);
- }
}
- analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames,
- foundHeatIdentifier));
- }
+ return analyzedZipHeatFiles;
}
- return analyzedZipHeatFiles;
- }
-
- private Optional<String> fetchNestedFileName(String line) {
- if (isMatch(patterns.get(NESTED_PATTERN), line)) {
- String trimmedLine = line.trim();
- String nestedFileName = trimmedLine
- .substring(trimmedLine.indexOf("type:") + "type:".length(), trimmedLine.length())
- .trim();
- return Optional.of(nestedFileName);
+ private Optional<String> fetchNestedFileName(String line) {
+ if (isMatch(patterns.get(NESTED_PATTERN), line)) {
+ String trimmedLine = line.trim();
+ String nestedFileName = trimmedLine.substring(trimmedLine.indexOf("type:") + "type:".length(), trimmedLine.length()).trim();
+ return Optional.of(nestedFileName);
+ }
+ return Optional.empty();
}
- return Optional.empty();
- }
- private Set<String> fetchFileNamesToReturn(Set<String> filesNamesToReturn,
- boolean foundHeatIdentifier) {
- if (!foundHeatIdentifier) {
- return new HashSet<>();
- } else {
- return filesNamesToReturn;
+ private Set<String> fetchFileNamesToReturn(Set<String> filesNamesToReturn, boolean foundHeatIdentifier) {
+ if (!foundHeatIdentifier) {
+ return new HashSet<>();
+ } else {
+ return filesNamesToReturn;
+ }
}
- }
- private boolean isResourceSectionEnd(String line, boolean isResourcesSection) {
- return isResourcesSection && isStartOfNonResourcesHeatSection(line);
- }
-
- private boolean isStartOfNonResourcesHeatSection(String line) {
- return isMatch(patterns.get(PARAMETERS), line) ||
- isMatch(patterns.get(CONDITIONS), line) ||
- isMatch(patterns.get(OUTPUTS), line) ||
- isMatch(patterns.get(PARAMETER_GROUP), line) ||
- isMatch(patterns.get(DESCRIPTION), line);
- }
+ private boolean isResourceSectionEnd(String line, boolean isResourcesSection) {
+ return isResourcesSection && isStartOfNonResourcesHeatSection(line);
+ }
- private boolean isMatch(Pattern pattern, String line) {
- return pattern.matcher(line).matches();
- }
+ private boolean isStartOfNonResourcesHeatSection(String line) {
+ return isMatch(patterns.get(PARAMETERS), line) || isMatch(patterns.get(CONDITIONS), line) || isMatch(patterns.get(OUTPUTS), line) || isMatch(
+ patterns.get(PARAMETER_GROUP), line) || isMatch(patterns.get(DESCRIPTION), line);
+ }
+ private boolean isMatch(Pattern pattern, String line) {
+ return pattern.matcher(line).matches();
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java
index 8b56b3fbc0..dad05b64f2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java
@@ -17,27 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi;
+import com.vdurmont.semver4j.Semver;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
-
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.tosca.csar.Manifest;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import com.vdurmont.semver4j.Semver;
-
-
public interface ETSIService {
/**
- * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1
- * and contains mandatory Entries in Tosca.meta
+ * Checks package structure is CSAR with TOSCA-Metadata directory according to SOL004 v2.5.1 and contains mandatory Entries in Tosca.meta
+ *
* @param handler contains csar artifacts
* @return true if all condition matched, false otherwise
* @throws IOException when TOSCA.meta file is invalid
@@ -50,20 +46,19 @@ public interface ETSIService {
* @param handler The file handler containing the artifacts to move.
* @return A Map with pairs of from and to path of the moved artifacts.
*/
- Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler)
- throws IOException;
+ Optional<Map<String, Path>> moveNonManoFileToArtifactFolder(final FileContentHandler handler) throws IOException;
/**
* Updates the main descriptor paths referring the artifacts that were moved.
*
- * @param toscaServiceModel The tosca service model containing the main descriptor.
+ * @param toscaServiceModel The tosca service model containing the main descriptor.
* @param fromToMovedArtifactMap A Map representing the from and to artifacts path changes.
*/
- void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel,
- final Map<String, Path> fromToMovedArtifactMap);
+ void updateMainDescriptorPaths(final ToscaServiceModel toscaServiceModel, final Map<String, Path> fromToMovedArtifactMap);
/**
* Retrieves the manifest file from the CSAR
+ *
* @param handler contains csar artifacts
* @throws IOException when TOSCA.meta file or manifest file is invalid
*/
@@ -71,6 +66,7 @@ public interface ETSIService {
/**
* Determines the type of resource that the CSAR represents
+ *
* @param handler contains csar artifacts
* @throws IOException when TOSCA.meta file or manifest file is invalid
*/
@@ -78,6 +74,7 @@ public interface ETSIService {
/**
* Determines the type of resource that the CSAR represents
+ *
* @param manifest contains manifest content
* @throws IOException when TOSCA.meta file or manifest file is invalid
*/
@@ -85,9 +82,9 @@ public interface ETSIService {
Path getOriginalManifestPath(final FileContentHandler handler) throws IOException;
-
/**
* Determines the highest compatible specification version based on ETSI manifest file
+ *
* @param handler contains csar artifacts
* @return Semver representing highest compatible specification version
*/
@@ -95,6 +92,7 @@ public interface ETSIService {
/**
* Verifies if SOL004 3.3.1 manifest file has onap_cnf_helm non mano entry
+ *
* @return true if manifest files has onap_cnf_helm non mano entry
*/
boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java
index 4aaa9a8a03..35bed3852b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGenerator.java
@@ -12,12 +12,14 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-*/
-
+ */
package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator;
import freemarker.template.Template;
import freemarker.template.TemplateException;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -25,39 +27,34 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
public class SchemaGenerator {
- public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR";
- private SchemaGenerator() {
- // Utility classes, which are a collection of static members, are not meant to be instantiated
- }
- /**
- * Generate string.
- *
- * @param schemaTemplateContext the schema template context
- * @param entityType the entity type
- * @param input the input
- * @return the string
- */
- public static String generate(SchemaTemplateContext schemaTemplateContext,
- CompositionEntityType entityType, SchemaTemplateInput input) {
- Template schemaTemplate =
- SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType);
- return processTemplate(input, schemaTemplate);
- }
+ public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR";
+
+ private SchemaGenerator() {
+ // Utility classes, which are a collection of static members, are not meant to be instantiated
+ }
+
+ /**
+ * Generate string.
+ *
+ * @param schemaTemplateContext the schema template context
+ * @param entityType the entity type
+ * @param input the input
+ * @return the string
+ */
+ public static String generate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType, SchemaTemplateInput input) {
+ Template schemaTemplate = SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType);
+ return processTemplate(input, schemaTemplate);
+ }
- private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) {
- try (Writer writer = new StringWriter(1024)) {
- schemaTemplate.process(input, writer);
- return writer.toString();
- } catch (IOException | TemplateException exception) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(SCHEMA_GENERATION_ERROR).withMessage(exception.getMessage()).build(), exception);
+ private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) {
+ try (Writer writer = new StringWriter(1024)) {
+ schemaTemplate.process(input, writer);
+ return writer.toString();
+ } catch (IOException | TemplateException exception) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(SCHEMA_GENERATION_ERROR)
+ .withMessage(exception.getMessage()).build(), exception);
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java
index 3937ca2f2e..9d00e45bc5 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorConfig.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,13 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator;
import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
@@ -33,122 +36,106 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
public class SchemaGeneratorConfig {
- public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
- "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
- public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
- "Error occurred while loading questionnaire schema schemaTemplates";
- private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates";
- private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>();
- private static ApplicationConfig applicationConfig =
- ApplicationConfigFactory.getInstance().createInterface();
- private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
- private static StringTemplateLoader stringLoader = new StringTemplateLoader();
-
- static {
- configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(),
- File.pathSeparator);
- configuration.setDefaultEncoding("UTF-8");
- configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
- configuration.setLogTemplateExceptions(true);
- configuration.setTemplateLoader(stringLoader);
- }
-
- public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext,
- CompositionEntityType entityType,
- String schemaTemplateString) {
- applicationConfig.insertValue(CONFIGURATION_NAMESPACE,
- new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString);
- }
-
- /**
- * Gets schema template.
- *
- * @param schemaTemplateContext the schema template context
- * @param entityType the entity type
- * @return the schema template
- */
- public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext,
- CompositionEntityType entityType) {
- SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType);
- ConfigurationData configurationData =
- applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString());
-
- SchemaTemplate schemaTemplate = schemaTemplates.get(id);
- if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) {
- stringLoader.putTemplate(id.toString(), configurationData.getValue());
- Template template;
- try {
- template = configuration.getTemplate(id.toString());
- } catch (IOException exception) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR)
- .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
- }
- schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp());
- schemaTemplates.put(id, schemaTemplate);
+ public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR = "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
+ public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG = "Error occurred while loading questionnaire schema schemaTemplates";
+ private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates";
+ private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>();
+ private static ApplicationConfig applicationConfig = ApplicationConfigFactory.getInstance().createInterface();
+ private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
+ private static StringTemplateLoader stringLoader = new StringTemplateLoader();
+
+ static {
+ configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(), File.pathSeparator);
+ configuration.setDefaultEncoding("UTF-8");
+ configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+ configuration.setLogTemplateExceptions(true);
+ configuration.setTemplateLoader(stringLoader);
}
- return schemaTemplate.template;
- }
-
- private static class SchemaTemplateId {
- private SchemaTemplateContext context;
- private CompositionEntityType entityType;
- public SchemaTemplateId(SchemaTemplateContext context, CompositionEntityType entityType) {
- this.context = context;
- this.entityType = entityType;
+ public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType,
+ String schemaTemplateString) {
+ applicationConfig
+ .insertValue(CONFIGURATION_NAMESPACE, new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString);
}
- @Override
- public String toString() {
- return context + "." + entityType;
+ /**
+ * Gets schema template.
+ *
+ * @param schemaTemplateContext the schema template context
+ * @param entityType the entity type
+ * @return the schema template
+ */
+ public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext, CompositionEntityType entityType) {
+ SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType);
+ ConfigurationData configurationData = applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString());
+ SchemaTemplate schemaTemplate = schemaTemplates.get(id);
+ if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) {
+ stringLoader.putTemplate(id.toString(), configurationData.getValue());
+ Template template;
+ try {
+ template = configuration.getTemplate(id.toString());
+ } catch (IOException exception) {
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR)
+ .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
+ }
+ schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp());
+ schemaTemplates.put(id, schemaTemplate);
+ }
+ return schemaTemplate.template;
}
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
-
- SchemaTemplateId that = (SchemaTemplateId) obj;
-
- if (entityType != that.entityType) {
- return false;
- }
- if (context != that.context) {
- return false;
- }
-
- return true;
+ private static class SchemaTemplateId {
+
+ private SchemaTemplateContext context;
+ private CompositionEntityType entityType;
+
+ public SchemaTemplateId(SchemaTemplateContext context, CompositionEntityType entityType) {
+ this.context = context;
+ this.entityType = entityType;
+ }
+
+ @Override
+ public String toString() {
+ return context + "." + entityType;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ SchemaTemplateId that = (SchemaTemplateId) obj;
+ if (entityType != that.entityType) {
+ return false;
+ }
+ if (context != that.context) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = entityType != null ? entityType.hashCode() : 0;
+ result = 31 * result + (context != null ? context.hashCode() : 0);
+ return result;
+ }
}
- @Override
- public int hashCode() {
- int result = entityType != null ? entityType.hashCode() : 0;
- result = 31 * result + (context != null ? context.hashCode() : 0);
- return result;
- }
- }
+ private static class SchemaTemplate {
- private static class SchemaTemplate {
- private Template template;
- private long timestamp;
+ private Template template;
+ private long timestamp;
- public SchemaTemplate(Template template, long timestamp) {
- this.template = template;
- this.timestamp = timestamp;
+ public SchemaTemplate(Template template, long timestamp) {
+ this.template = template;
+ this.timestamp = timestamp;
+ }
}
- }
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index eb4b29d742..726fcbf21f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.services.utils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.Messages;
@@ -37,70 +42,52 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.HeatFileAnalyzerRow
import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
public class CandidateEntityBuilder {
- private final CandidateService candidateService;
-
- public CandidateEntityBuilder(CandidateService candidateService) {
- this.candidateService = candidateService;
- }
- public OrchestrationTemplateCandidateData buildCandidateEntityFromZip(
- VspDetails vspDetails, byte[] uploadedFileData, FileContentHandler contentMap,
- Map<String, List<ErrorMessage>> uploadErrors) throws Exception {
- //mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ private final CandidateService candidateService;
- try (InputStream zipFileManifest = contentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
- HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
- AnalyzedZipHeatFiles analyzedZipHeatFiles =
- heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
- HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
-
- CandidateDataEntityTo candidateDataEntityTo =
- new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData,
- tree, contentMap);
- candidateDataEntityTo.setErrors(uploadErrors);
- OrchestrationTemplateCandidateData candidateDataEntity =
- candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
- analyzedZipHeatFiles);
- return candidateDataEntity;
+ public CandidateEntityBuilder(CandidateService candidateService) {
+ this.candidateService = candidateService;
}
- }
- private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
- FileContentHandler contentMap,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws IOException {
- addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
- HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
- heatTreeManager.createTree();
- return heatTreeManager.getTree();
- }
+ public OrchestrationTemplateCandidateData buildCandidateEntityFromZip(VspDetails vspDetails, byte[] uploadedFileData,
+ FileContentHandler contentMap, Map<String, List<ErrorMessage>> uploadErrors)
+ throws Exception {
+ //mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ try (InputStream zipFileManifest = contentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
+ AnalyzedZipHeatFiles analyzedZipHeatFiles = heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
+ HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
+ CandidateDataEntityTo candidateDataEntityTo = new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData,
+ tree, contentMap);
+ candidateDataEntityTo.setErrors(uploadErrors);
+ OrchestrationTemplateCandidateData candidateDataEntity = candidateService
+ .createCandidateDataEntity(candidateDataEntityTo, zipFileManifest, analyzedZipHeatFiles);
+ return candidateDataEntity;
+ }
+ }
- private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails,
- FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws IOException {
- try (InputStream manifest = fileContentHandler.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ private HeatStructureTree getHeatStructureTree(VspDetails vspDetails, FileContentHandler contentMap, AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws IOException {
+ addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
+ HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
+ heatTreeManager.createTree();
+ return heatTreeManager.getTree();
+ }
- if (Objects.isNull(manifest)) {
- Optional<ManifestContent> manifestContentOptional =
- candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
- if (!manifestContentOptional.isPresent()) {
- throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails, FileContentHandler fileContentHandler,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ try (InputStream manifest = fileContentHandler.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ if (Objects.isNull(manifest)) {
+ Optional<ManifestContent> manifestContentOptional = candidateService
+ .createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ if (!manifestContentOptional.isPresent()) {
+ throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ }
+ ManifestContent manifestContent = manifestContentOptional.get();
+ fileContentHandler.addFile(SdcCommon.MANIFEST_NAME, String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
+ }
+ } finally {
}
- ManifestContent manifestContent = manifestContentOptional.get();
- fileContentHandler.addFile(
- SdcCommon.MANIFEST_NAME,
- String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
- }
- } finally {
}
- }
}