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 --- .../VendorSoftwareProductInfoDaoZusammenImpl.java | 10 +++++-- .../CandidateServiceImpl.java | 33 ++++++++++++++-------- 2 files changed, 30 insertions(+), 13 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main') 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