diff options
author | aribeiro <anderson.ribeiro@est.tech> | 2019-09-03 08:37:55 +0000 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2019-09-03 13:38:08 +0000 |
commit | ccc1f364baea63733e93c6f4eb26ea97eeb77960 (patch) | |
tree | 2ce098bd1d4a28e611dd91f2eea6605a51cbf463 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main | |
parent | e79935cbaa180a86eea2c7631de14c16bef9b3d8 (diff) |
Onboard Package Handling
Retain the original onboarded package when it comes in zip/csar format.
Issue-ID: SDC-2510
Change-Id: Ie293db25eca8872be26ffc8475b25ccace1aab6f
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
9 files changed, 194 insertions, 103 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java index 238dbc08d0..5cf66874c4 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java @@ -16,21 +16,19 @@ package org.openecomp.sdc.vendorsoftwareproduct; +import java.io.IOException; +import java.util.Optional; import org.apache.commons.lang3.tuple.Pair; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - public interface OrchestrationTemplateCandidateManager { - UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload, - String fileSuffix, String networkPackageName); OrchestrationTemplateActionResponse process(String vspId, Version version); @@ -44,4 +42,6 @@ public interface OrchestrationTemplateCandidateManager { Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version); void abort(String vspId, Version version); + + UploadFileResponse upload(final VspDetails vspDetails, final OnboardPackageInfo onboardPackageInfo); } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java index 57f6b672be..d5d5c8045b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java @@ -16,6 +16,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -34,19 +39,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationT import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUploadFactory; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationProcessFactory; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackage; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; - public class OrchestrationTemplateCandidateManagerImpl implements OrchestrationTemplateCandidateManager { @@ -61,18 +61,16 @@ public class OrchestrationTemplateCandidateManagerImpl } @Override - public UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload, - String fileSuffix, String networkPackageName) { - OrchestrationTemplateFileHandler orchestrationTemplateFileHandler = - OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(fileSuffix); - - VspDetails vspDetails = getVspDetails(vspId, version); - - UploadFileResponse uploadResponse = orchestrationTemplateFileHandler - .upload(vspDetails, fileToUpload, fileSuffix, networkPackageName, candidateService); - - uploadResponse.setNetworkPackageName(networkPackageName); - return uploadResponse; + public UploadFileResponse upload(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo) { + final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage(); + final OrchestrationTemplateFileHandler orchestrationTemplateFileHandler = + OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(onboardPackage.getFileExtension()); + + final UploadFileResponse uploadFileResponse = + orchestrationTemplateFileHandler.upload(vspDetails, onboardPackageInfo, candidateService); + uploadFileResponse.setNetworkPackageName(onboardPackage.getFilename()); + return uploadFileResponse; } @Override @@ -153,4 +151,4 @@ public class OrchestrationTemplateCandidateManagerImpl private VspDetails getVspDetails(String vspId, Version version) { return vspInfoDao.get(new VspDetails(vspId, version)); } -} +}
\ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java index 87dd29d095..d87c9c8dbb 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java @@ -20,9 +20,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; +import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; + +import java.io.ByteArrayInputStream; +import java.util.Optional; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.utilities.file.FileContentHandler; -import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.common.utils.SdcCommon; @@ -32,33 +35,32 @@ import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackage; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.io.InputStream; -import java.util.Optional; - -import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; - public abstract class BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler { - protected static final Logger logger = - LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class); + protected static final Logger logger = LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class); + @Override - public UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload, - String fileSuffix, String networkPackageName, - CandidateService candidateService) { - UploadFileResponse uploadFileResponse = new UploadFileResponse(); + public UploadFileResponse upload(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo, + final CandidateService candidateService) { + final OnboardPackage onboardPackage = onboardPackageInfo.getOnboardPackage(); + final UploadFileResponse uploadFileResponse = new UploadFileResponse(); uploadFileResponse.setOnboardingType(getHandlerType()); - if (isNotEmptyFileToUpload(fileSuffix, fileToUpload, uploadFileResponse, candidateService)) { + if (isFileFileToUploadEmpty(onboardPackage, uploadFileResponse, candidateService)) { return uploadFileResponse; } - byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload); - if (isInvalidRawZipData(fileSuffix, uploadFileResponse, uploadedFileData, candidateService)) { + final byte[] fileContentByteArray = onboardPackage.getFileContent().array(); + if (isInvalidRawZipData(onboardPackage.getFileExtension(), + uploadFileResponse, fileContentByteArray, candidateService)) { return uploadFileResponse; } - Optional<FileContentHandler> optionalContentMap = - getFileContentMap(uploadFileResponse, uploadedFileData); + final Optional<FileContentHandler> optionalContentMap = + getFileContentMap(uploadFileResponse, fileContentByteArray); if (!optionalContentMap.isPresent()) { logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString())); @@ -71,27 +73,27 @@ public abstract class BaseOrchestrationTemplateHandler implements OrchestrationT if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) { return uploadFileResponse; } - if (updateCandidateData(vspDetails, uploadedFileData, optionalContentMap.get(), fileSuffix, - networkPackageName, candidateService, uploadFileResponse)) { + if (updateCandidateData(vspDetails, onboardPackageInfo, candidateService, uploadFileResponse, + optionalContentMap.get())) { return uploadFileResponse; } return uploadFileResponse; } - protected abstract boolean updateCandidateData(VspDetails vspDetails, - byte[] uploadedFileData, - FileContentHandler contentMap, - String fileSuffix, - String networkPackageName, - CandidateService candidateService, - UploadFileResponse uploadFileResponse); + protected abstract boolean updateCandidateData(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo, + final CandidateService candidateService, + final UploadFileResponse uploadFileResponse, + final FileContentHandler contentMap); - private boolean isNotEmptyFileToUpload(String fileSuffix, InputStream fileToUpload, - UploadFileResponse uploadFileResponse, - CandidateService candidateService) { + private boolean isFileFileToUploadEmpty(final OnboardPackage onboardPackage, + final UploadFileResponse uploadFileResponse, + final CandidateService candidateService) { + final ByteArrayInputStream fileToUpload = new ByteArrayInputStream( + onboardPackage.getFileContent().array()); Optional<ErrorMessage> errorMessage = - candidateService.validateNonEmptyFileToUpload(fileToUpload, fileSuffix); + candidateService.validateNonEmptyFileToUpload(fileToUpload, onboardPackage.getFileExtension()); if (errorMessage.isPresent()) { uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get()); return true; diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java index 669efa6dc5..61d1799aa0 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; +import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; import org.apache.commons.lang3.tuple.Pair; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; @@ -34,19 +39,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.Validator; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.ValidatorFactory; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackage; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.List; -import java.util.Optional; - -import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; - public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler { - @Override public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse, byte[] uploadedFileData) { @@ -74,16 +73,20 @@ public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateH } @Override - protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData, - FileContentHandler contentMap, - String fileSuffix, String networkPackageName, - CandidateService candidateService, - UploadFileResponse uploadFileResponse) { + protected boolean updateCandidateData(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo, + final CandidateService candidateService, + final UploadFileResponse uploadFileResponse, + final FileContentHandler contentMap) { try { + final OnboardPackage csarPackage = onboardPackageInfo.getOnboardPackage(); + final OnboardPackage originalOnboardPackage = onboardPackageInfo.getOriginalOnboardPackage(); candidateService.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), - new OrchestrationTemplateCandidateData(ByteBuffer.wrap(uploadedFileData), "", fileSuffix, - networkPackageName)); - } catch (Exception exception) { + new OrchestrationTemplateCandidateData(csarPackage.getFileContent(), + "", csarPackage.getFileExtension(), + csarPackage.getFilename(), originalOnboardPackage.getFilename(), originalOnboardPackage.getFileExtension(), + originalOnboardPackage.getFileContent())); + } catch (final Exception exception) { logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString()), exception); uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java index 953d88bc4d..2d2f1ae92b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java @@ -18,14 +18,13 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.io.InputStream; - @FunctionalInterface public interface OrchestrationTemplateFileHandler { - UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload, - String fileSuffix, String networkPackageName, - CandidateService candidateService); + UploadFileResponse upload(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo, + final CandidateService candidateService); } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java index 7e323928e1..bc4fb668b0 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration; +import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; + +import java.util.Optional; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.Messages; @@ -30,12 +33,10 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCan import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackage; +import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.util.Optional; - -import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; - public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler { @@ -47,22 +48,22 @@ public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHa } @Override - protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData, - FileContentHandler contentMap, - String fileSuffix, String networkPackageName, - CandidateService candidateService, - UploadFileResponse uploadFileResponse) { + protected boolean updateCandidateData(final VspDetails vspDetails, + final OnboardPackageInfo onboardPackageInfo, + final CandidateService candidateService, + final UploadFileResponse uploadFileResponse, + final FileContentHandler contentMap) { try { - OrchestrationTemplateCandidateData candidateData = + final OnboardPackage zipPackage = onboardPackageInfo.getOnboardPackage(); + final OrchestrationTemplateCandidateData candidateData = new CandidateEntityBuilder(candidateService) - .buildCandidateEntityFromZip(vspDetails, uploadedFileData, contentMap, + .buildCandidateEntityFromZip(vspDetails, zipPackage.getFileContent().array(), contentMap, uploadFileResponse.getErrors()); - candidateData.setFileSuffix(fileSuffix); - candidateData.setFileName(networkPackageName); - + candidateData.setFileName(zipPackage.getFilename()); + candidateData.setFileSuffix(zipPackage.getFileExtension()); candidateService .updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData); - } catch (Exception exception) { + } catch (final Exception exception) { logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString()), exception); uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java index a86ce33e47..875d6f2953 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java @@ -16,6 +16,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.impl.AbstractToscaSolConverter; import org.openecomp.core.impl.ToscaConverterImpl; @@ -47,15 +55,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImp import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler { private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class); @@ -133,8 +132,13 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem ETSIService etsiService = new ETSIServiceImpl(); ToscaServiceModel toscaServiceModel; if (etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) { - fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() + - EXT_SEPARATOR + candidateData.getFileSuffix(), candidateData.getContentData().array()); + if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) { + fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getOriginalFileName() + + EXT_SEPARATOR + candidateData.getOriginalFileSuffix(), candidateData.getOriginalFileContentData().array()); + } else { + fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() + + EXT_SEPARATOR + candidateData.getFileSuffix(), candidateData.getContentData().array()); + } final ResourceTypeEnum resourceType = etsiService.getResourceType(fileContentHandler); toscaServiceModel = instantiateToscaConverterFor(resourceType).convert(fileContentHandler); } else { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java new file mode 100644 index 0000000000..b8ef598d65 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackage.java @@ -0,0 +1,38 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types; + +import java.nio.ByteBuffer; +import lombok.Getter; + +@Getter +public class OnboardPackage { + + private final String filename; + private final String fileExtension; + private final ByteBuffer fileContent; + + public OnboardPackage(final String filename, final String fileExtension, final ByteBuffer fileContent) { + this.filename = filename; + this.fileExtension = fileExtension; + this.fileContent = fileContent; + } + +} diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java new file mode 100644 index 0000000000..308db035db --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OnboardPackageInfo.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.vendorsoftwareproduct.types; + +import java.nio.ByteBuffer; +import lombok.Getter; + +@Getter +public class OnboardPackageInfo { + + private final OnboardPackage originalOnboardPackage; + private final OnboardPackage onboardPackage; + + public OnboardPackageInfo(final String filename, + final String fileExtension, + final ByteBuffer fileContent, + final OnboardPackage onboardPackage) { + originalOnboardPackage = new OnboardPackage(filename, fileExtension, fileContent); + this.onboardPackage = onboardPackage; + } + + public OnboardPackageInfo(final String filename, + final String fileExtension, + final ByteBuffer fileContent) { + originalOnboardPackage = new OnboardPackage(filename, fileExtension, fileContent); + this.onboardPackage = originalOnboardPackage; + } + +}
\ No newline at end of file |