diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2021-01-15 17:38:30 +0100 |
---|---|---|
committer | Adam Wudzinski <adam.wudzinski@nokia.com> | 2021-01-18 16:58:27 +0100 |
commit | f3b0ef4dc7cc21b273ea160781b5170b2d105e1a (patch) | |
tree | 04550aed49f28b599d2702a519ad7d51a855aac8 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java | |
parent | bd5a1006210092f9ac5c48352cc94f6264e961ef (diff) |
Map VSP PM_DICTIONARY Type to VF PM_DICTIONARY Type
File defined in ZIP VSP package as PM_DICTIONARY will be now mapped to PM_DICTIONARY type in VF. Also PmDictionaryValidator is run on files with PM_DICTIONARY type in ZIP Manifest file, instead of file naming convention.
Issue-ID: SDC-3390
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
Change-Id: I2e21353b9e80b6bb68c4c6d408ad1ffa33314e7b
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java')
2 files changed, 56 insertions, 2 deletions
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)); } } |