From c8a540b3c234449163f6fb1899807bba951113b4 Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Mon, 11 Sep 2017 15:45:37 +0300 Subject: Create new VSP, onboard from TOSCA file - UI Change-Id: I018c6d07a4b9ec7e6b1507ab37e2550865423cfe Issue-ID: SDC-230 Signed-off-by: shrek2000 --- .../vendorsoftwareproduct/dao/type/VspDetails.java | 22 +++++++++++++++ .../filedatastructuremodule/CandidateService.java | 9 ++++-- .../services/utils/CandidateEntityBuilder.java | 8 ++++++ .../VendorSoftwareProductInfoDaoZusammenImpl.java | 10 +++++-- .../CandidateServiceImpl.java | 33 ++++++++++++++-------- 5 files changed, 66 insertions(+), 16 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib') 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/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java index 2758e3dfe9..ccadeced62 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java @@ -61,6 +61,11 @@ public class VspDetails implements VersionableEntity { private Long writetimeMicroSeconds; private String onboardingMethod; + + private String onboardingOrigin; + + private String networkPackageName; + public VspDetails() { } @@ -215,12 +220,29 @@ public class VspDetails implements VersionableEntity { this.oldVersion = oldVersion; } + public String getOnboardingOrigin() { + return onboardingOrigin; + } + + public void setOnboardingOrigin(String onboardingOrigin) { + this.onboardingOrigin = onboardingOrigin; + } + public String getOnboardingMethod() { return onboardingMethod; } public void setOnboardingMethod(String onboardingMethod) { this.onboardingMethod = onboardingMethod; } + + public String getNetworkPackageName() { + return networkPackageName; + } + + public void setNetworkPackageName(String networkPackageName) { + this.networkPackageName = networkPackageName; + } + @Override public String toString() { return String.format( 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 4ca623e6a3..6cc639fac0 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 @@ -21,10 +21,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule; import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles; @@ -61,9 +61,12 @@ public interface CandidateService { Optional fetchZipFileByteArrayInputStream(String vspId, OrchestrationTemplateCandidateData candidateDataEntity, - String manifest, Map> uploadErrors); + String manifest, + OnboardingTypesEnum type, + Map> uploadErrors); - byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId) + byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId, + OnboardingTypesEnum type) throws IOException; Optional createManifest(VspDetails vspDetails, 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 9540f3d965..ca5329344b 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 @@ -75,6 +75,14 @@ public class CandidateEntityBuilder { return candidateDataEntity; } +// public OrchestrationTemplateCandidateData buildOrchestrationTemplateFromCsar(VspDetails vspDetails, +// byte[] uploadedFileData, +// FileContentHandler contentMap, +// Map> uploadErrors, +// String user){ +// +// } + private HeatStructureTree getHeatStructureTree(VspDetails vspDetails, FileContentHandler contentMap, 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/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java index eef90d4742..7ad7929ccb 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java @@ -200,6 +200,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP info.addProperty(InfoPropertyName.featureGroups.name(), vspDetails.getFeatureGroups()); info.addProperty(InfoPropertyName.oldVersion.name(), vspDetails.getOldVersion()); info.addProperty(InfoPropertyName.onboardingMethod.name(), vspDetails.getOnboardingMethod()); + info.addProperty(InfoPropertyName.obBoardingOrigin.name(), vspDetails.getOnboardingOrigin()); + info.addProperty(InfoPropertyName.networkPackageName.name(), vspDetails.getNetworkPackageName()); } private VspDetails mapInfoToVspDetails(String vspId, Version version, Info info, @@ -215,6 +217,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP Version.valueOf(info.getProperty(InfoPropertyName.vendorVersion.name()))); vspDetails.setLicenseAgreement(info.getProperty(InfoPropertyName.licenseAgreement.name())); vspDetails.setFeatureGroups(info.getProperty(InfoPropertyName.featureGroups.name())); + vspDetails.setWritetimeMicroSeconds( modificationTime == null ? creationTime.getTime() : modificationTime.getTime()); vspDetails.setVersion(version); @@ -223,7 +226,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP //Boolean oldVersion = ind == null || "true".equals( ind.toLowerCase()); vspDetails.setOldVersion(oldVersion); vspDetails.setOnboardingMethod(info.getProperty(InfoPropertyName.onboardingMethod.name())); - + vspDetails.setOnboardingOrigin(info.getProperty(InfoPropertyName.obBoardingOrigin.name())); + vspDetails.setNetworkPackageName(info.getProperty(InfoPropertyName.networkPackageName.name())); return vspDetails; } @@ -239,7 +243,9 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP licenseAgreement, featureGroups, oldVersion, - onboardingMethod + onboardingMethod, + obBoardingOrigin, + networkPackageName } } 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 6ccece1e76..e5f1a4c3ac 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 @@ -23,6 +23,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructurem import org.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; @@ -89,17 +90,17 @@ public class CandidateServiceImpl implements CandidateService { } @Override - public Optional validateNonEmptyFileToUpload(InputStream heatFileToUpload) { + public Optional validateNonEmptyFileToUpload(InputStream fileToUpload) { mdcDataDebugMessage.debugEntryMessage(null); - if (Objects.isNull(heatFileToUpload)) { + if (Objects.isNull(fileToUpload)) { return Optional.of(new ErrorMessage(ErrorLevel.ERROR, Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage())); } else { try { - int available = heatFileToUpload.available(); + int available = fileToUpload.available(); if (available == 0) { mdcDataDebugMessage.debugExitMessage(null); return Optional.of(new ErrorMessage(ErrorLevel.ERROR, @@ -321,10 +322,7 @@ public class CandidateServiceImpl implements CandidateService { public void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, String itemId) { mdcDataDebugMessage.debugEntryMessage(null); - - //vendorSoftwareProductDao.updateCandidateUploadData(uploadData); orchestrationTemplateCandidateDataDao.update(itemId, uploadData); - mdcDataDebugMessage.debugExitMessage(null); } @@ -393,11 +391,12 @@ public class CandidateServiceImpl implements CandidateService { public Optional fetchZipFileByteArrayInputStream(String vspId, OrchestrationTemplateCandidateData candidateDataEntity, String manifest, + OnboardingTypesEnum type, Map> uploadErrors) { byte[] file; ByteArrayInputStream byteArrayInputStream = null; try { - file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId); + file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type); byteArrayInputStream = new ByteArrayInputStream( Objects.isNull(file) ? candidateDataEntity.getContentData().array() : file); @@ -413,7 +412,8 @@ public class CandidateServiceImpl implements CandidateService { } @Override - public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId) + public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId, + OnboardingTypesEnum type) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -433,12 +433,12 @@ public class CandidateServiceImpl implements CandidateService { } } else { manifestWritten = true; - writeManifest(manifest, zos); + writeManifest(manifest, type, zos); } zos.closeEntry(); } if (!manifestWritten) { - writeManifest(manifest, zos); + writeManifest(manifest, type, zos); zos.closeEntry(); } } @@ -451,7 +451,14 @@ public class CandidateServiceImpl implements CandidateService { return candidateServiceValidator.validateFileDataStructure(filesDataStructure); } - private void writeManifest(String manifest, ZipOutputStream zos) throws IOException { + private void writeManifest(String manifest, + OnboardingTypesEnum type, + ZipOutputStream zos) throws IOException { + + if(isManifestNeedsToGetWritten(type)){ + return; + } + zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME)); try (InputStream manifestStream = new ByteArrayInputStream( manifest.getBytes(StandardCharsets.UTF_8))) { @@ -463,6 +470,10 @@ public class CandidateServiceImpl implements CandidateService { } } + private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) { + return type.equals(OnboardingTypesEnum.CSAR); + } + private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) { if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) { -- cgit 1.2.3-korg