From 433947b5ab5e28fc29aee447de934de89a707419 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Thu, 19 Sep 2019 16:14:01 +0100 Subject: Centralize onboarding package validation Change-Id: I3cc58cf15f62008e83cfc7ddb095d07ab216b82a Issue-ID: SDC-2583 Signed-off-by: andre.schmid --- .../services/impl/etsi/ETSIServiceImpl.java | 17 ++++++++--------- .../filedatastructuremodule/CandidateServiceImpl.java | 2 +- .../dao/ServiceModelDaoFactoryTest.java | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core') 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/etsi/ETSIServiceImpl.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/etsi/ETSIServiceImpl.java index e727078daa..ca60577b29 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/etsi/ETSIServiceImpl.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/etsi/ETSIServiceImpl.java @@ -152,12 +152,11 @@ public class ETSIServiceImpl implements ETSIService { private Optional updateNonManoPathInHandler(final FileContentHandler handler, final NonManoType nonManoType, final Path nonManoOriginalFilePath) { final Path fixedSourcePath = fixNonManoPath(nonManoOriginalFilePath); - final Map packageFileMap = handler.getFiles(); - if (packageFileMap.containsKey(fixedSourcePath.toString())) { + if (handler.containsFile(fixedSourcePath.toString())) { final Path newNonManoPath = Paths.get(nonManoType.getType(), nonManoType.getLocation() , fixedSourcePath.getFileName().toString()); - if (!packageFileMap.containsKey(newNonManoPath.toString())) { - packageFileMap.put(newNonManoPath.toString(), packageFileMap.remove(fixedSourcePath.toString())); + if (!handler.containsFile(newNonManoPath.toString())) { + handler.addFile(newNonManoPath.toString(), handler.remove(fixedSourcePath.toString())); return Optional.of(newNonManoPath); } } @@ -254,10 +253,10 @@ public class ETSIServiceImpl implements ETSIService { ToscaMetadata metadata; if (handler.containsFile(TOSCA_META_PATH_FILE_NAME)) { metadata = OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContent(TOSCA_META_PATH_FILE_NAME)); + .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME)); } else if (handler.containsFile(TOSCA_META_ORIG_PATH_FILE_NAME)) { metadata = OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContent(TOSCA_META_ORIG_PATH_FILE_NAME)); + .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); } else { throw new IOException("TOSCA.meta file not found!"); } @@ -267,7 +266,7 @@ public class ETSIServiceImpl implements ETSIService { private ToscaMetadata getOriginalMetadata(final FileContentHandler handler) throws IOException { if (handler.containsFile(TOSCA_META_ORIG_PATH_FILE_NAME)) { return OnboardingToscaMetadata - .parseToscaMetadataFile(handler.getFileContent(TOSCA_META_ORIG_PATH_FILE_NAME)); + .parseToscaMetadataFile(handler.getFileContentAsStream(TOSCA_META_ORIG_PATH_FILE_NAME)); } else { throw new IOException(String.format("%s file not found", TOSCA_META_ORIG_PATH_FILE_NAME)); } @@ -276,9 +275,9 @@ public class ETSIServiceImpl implements ETSIService { private InputStream getManifestInputStream(FileContentHandler handler, String manifestLocation) throws IOException { InputStream io; if (manifestLocation == null || !handler.containsFile(manifestLocation)) { - io = handler.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME); + io = handler.getFileContentAsStream(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME); } else { - io = handler.getFileContent(manifestLocation); + io = handler.getFileContentAsStream(manifestLocation); } if (io == null) { 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 07dc53dfae..5535416838 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 @@ -132,7 +132,7 @@ public class CandidateServiceImpl implements CandidateService { analyzedZipHeatFiles); handleOtherResources(tree, usedEnvFiles, structure); FilesDataStructure fileDataStructureFromManifest = - createFileDataStructureFromManifest(zipContentMap.getFileContent(SdcCommon.MANIFEST_NAME)); + createFileDataStructureFromManifest(zipContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)); List structureArtifacts = structure.getArtifacts(); structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter (artifact -> isNotStrctureArtifact(structureArtifacts, 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/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java index 3e37125442..1118260a16 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java @@ -174,7 +174,7 @@ public class ServiceModelDaoFactoryTest { artifacts.put("art4", ("this is art4 desc:" + CommonMethods.nextUuId()).getBytes()); FileContentHandler fileContentHandler = new FileContentHandler(); - fileContentHandler.putAll(artifacts); + fileContentHandler.setFiles(artifacts); return fileContentHandler; } -- cgit 1.2.3-korg