aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib')
-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.java4
-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.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java50
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java75
5 files changed, 129 insertions, 11 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/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 578b120256..d33533a7d0 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
@@ -12,6 +12,8 @@
* 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.
+ *
+ * Modifications copyright (c) 2021 Nokia
*/
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
@@ -80,6 +82,8 @@ public interface CandidateService {
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
+ String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
+
Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
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 fd70d20c22..90490e7153 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
@@ -3,6 +3,7 @@
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +32,8 @@ 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, FileContentHandler
fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 8bae5e8193..7c11fb65ab 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2018 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -363,6 +364,13 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
+ public String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest) {
+ return JsonUtil.object2Json(manifestCreator.createManifestFromExisting(vspDetails, structure, existingManifest)
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build())));
+ }
+
+ @Override
public Optional<ManifestContent> createManifest(VspDetails vspDetails,
FileContentHandler fileContentHandler,
AnalyzedZipHeatFiles analyzedZipHeatFiles) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
index 3f061b059c..54cc1fbf1c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2017 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,10 +55,56 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
addModulesToManifestFileDataList(filesDataStructure, fileDataList);
addNestedToManifest(filesDataStructure, fileDataList);
addArtifactsToManifestFileDataList(filesDataStructure, fileDataList);
+
+ ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
+ return Optional.of(manifestContent);
+ }
+
+ @Override
+ public Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest) {
+ if (Objects.isNull(filesDataStructure)) {
+ return Optional.empty();
+ }
+
+ List<FileData> fileDataList = new ArrayList<>();
+ addModulesToManifestFileDataList(filesDataStructure, fileDataList);
+ addNestedToManifest(filesDataStructure, fileDataList);
+ addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest);
+
ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
return Optional.of(manifestContent);
}
+ private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList, ManifestContent existingManifest) {
+ Collection<String> forArtifacts = CollectionUtils
+ .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
+ if (CollectionUtils.isNotEmpty(forArtifacts)) {
+ for (String artifact : forArtifacts) {
+ if (isCloudSpecificArtifact(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact));
+ } else if (isControllerBlueprintArchive(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
+ } else if (isHelm(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
+ } else if (isPmDictionary(artifact, existingManifest)) {
+ fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact));
+ }
+ else {
+ fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+ }
+ }
+ }
+ }
+
+ private boolean isPmDictionary(String artifact, ManifestContent existingManifest) {
+ return existingManifest.getData()
+ .stream()
+ .filter(fileData -> fileData.getType()
+ .equals(FileData.Type.PM_DICTIONARY))
+ .map(FileData::getFile)
+ .anyMatch(pmDictionaryFile -> pmDictionaryFile.equals(artifact));
+ }
+
private void addNestedToManifest(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) {
@@ -172,8 +219,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
} else if (isHelm(artifact)) {
fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
- }
- else {
+ } else {
fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
index 1a9bc2aa4c..2cea0f73e3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* 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.
@@ -20,15 +21,18 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
@@ -37,13 +41,66 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami
private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
private static final String ARTIFACT_4 = "k8s_charts.zip";
private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+ private static final String PMDICT_YAML = "pmdict.yaml";
+
@Test
- public void testIsCloudSpecificArtifact() {
+ void testIsCloudSpecificArtifact() {
assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
}
+
+ @Test
+ void shouldMapPmDictionaryTypeFromExistingManifestToPmDictionaryTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.PM_DICTIONARY);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ @Test
+ void shouldMapPmDictionaryWithOtherTypeFromExistingManifestToOtherTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.OTHER);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) {
+ ManifestContent existingManifest = new ManifestContent();
+ FileData fileData = new FileData();
+ fileData.setFile(PMDICT_YAML);
+ fileData.setType(fileType);
+ existingManifest.setData(List.of(fileData));
+ return existingManifest;
+ }
}