aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java4
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java29
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java4
-rw-r--r--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.java2
-rw-r--r--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/OrchestrationTemplateCandidateDaoZusammenImpl.java2
-rw-r--r--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/OrchestrationTemplateDaoZusammenImpl.java46
-rw-r--r--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/VspZusammenUtil.java13
-rw-r--r--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.java23
11 files changed, 123 insertions, 36 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
index cb3abeebc2..ee9ab56b15 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
@@ -64,8 +64,8 @@ public interface OrchestrationTemplateCandidate extends VspEntities {
@GET
@Path("/")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
- @ApiOperation(value = "Get uploaded candidate HEAT file",
- notes = "Downloads in process candidate HEAT file",
+ @ApiOperation(value = "Get uploaded Network Package file",
+ notes = "Downloads in uploaded Network Package file",
response = File.class)
Response get(
@PathParam("vspId") String vspId,
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index d856cfc6e5..a152e44f98 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -25,6 +25,10 @@ import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.activitylog.dao.type.ActivityType;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
@@ -54,12 +58,14 @@ import java.util.Optional;
import static org.openecomp.core.utilities.file.FileUtils.getFileExtension;
import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
@Named
@Service("orchestrationTemplateCandidate")
@Scope(value = "prototype")
public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate {
-
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class);
private OrchestrationTemplateCandidateManager candidateManager =
OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface();
private VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory
@@ -84,13 +90,24 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
@Override
public Response get(String vspId, String versionId, String user) throws IOException {
Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId));
-
- if (!zipFile.isPresent()) {
- return Response.status(Response.Status.NOT_FOUND).build();
+ String fileName = null;
+ if (zipFile.isPresent()) {
+ fileName = "Candidate." + zipFile.get().getLeft();
+ } else {
+ zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId)));
+
+ if (!zipFile.isPresent()) {
+ ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(
+ Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
+ ""));
+ LOGGER.error(errorMessage.getMessage());
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ fileName = "Processed." + zipFile.get().getLeft();
}
Response.ResponseBuilder response = Response.ok(zipFile.get().getRight());
- String filename = "Candidate." + zipFile.get().getLeft();
- response.header("Content-Disposition", "attachment; filename=" + filename);
+ response.header("Content-Disposition", "attachment; filename=" + fileName);
return response.build();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 423f9a51bb..1b07f681ac 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -16,6 +16,7 @@
package org.openecomp.sdc.vendorsoftwareproduct;
+import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
@@ -68,6 +69,7 @@ public interface VendorSoftwareProductManager {
File getInformationArtifact(String vspId, Version version);
+ public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
Collection<ComputeEntity> getComputeByVsp(String vspId, Version version);
}
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 97a4a213af..cfb4c9dbfd 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
@@ -22,10 +22,8 @@ import org.apache.commons.lang3.tuple.Pair;
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.Messages;
import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -52,8 +50,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-
public class OrchestrationTemplateCandidateManagerImpl
implements OrchestrationTemplateCandidateManager {
private static final Logger LOGGER =
@@ -128,10 +124,6 @@ public class OrchestrationTemplateCandidateManagerImpl
fetchCandidateDataEntity(vspId, version);
if (!candidateDataEntity.isPresent()) {
- ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
- ""));
- LOGGER.error(errorMessage.getMessage());
return Optional.empty();
}
OnboardingTypesEnum type =
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index ada88b8e1b..f116abef16 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -18,6 +18,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.core.dao.UniqueValueDao;
import org.openecomp.core.enrichment.api.EnrichmentManager;
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
@@ -82,6 +84,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilde
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
@@ -144,6 +147,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private final ImageDao imageDao;
private final ManualVspToscaManager manualVspToscaManager;
private final UniqueValueUtil uniqueValueUtil;
+ private final CandidateService candidateService;
public VendorSoftwareProductManagerImpl(
VspMergeDao vspMergeDao,
@@ -163,7 +167,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
ComputeDao computeDao,
ImageDao imageDao,
ManualVspToscaManager manualVspToscaManager,
- UniqueValueDao uniqueValueDao) {
+ UniqueValueDao uniqueValueDao,
+ CandidateService candidateService) {
this.vspMergeDao = vspMergeDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
@@ -182,6 +187,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
this.imageDao = imageDao;
this.manualVspToscaManager = manualVspToscaManager;
this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
+ this.candidateService = candidateService;
registerToVersioning();
}
@@ -817,6 +823,24 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
}
+ @Override
+ public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
+
+ OrchestrationTemplateEntity orchestrationTemplateEntity =
+ orchestrationTemplateDao.get(vspId, version);
+
+ if (isOrchestrationTemplateMissing(orchestrationTemplateEntity)) {
+ return Optional.empty();
+ }
+
+ if (CommonUtil.isFileOriginFromZip(orchestrationTemplateEntity.getFileSuffix())) {
+ return Optional.of(new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService
+ .getZipData(orchestrationTemplateEntity.getContentData())));
+ }
+ return Optional.of(new ImmutablePair<>(orchestrationTemplateEntity.getFileSuffix(),
+ orchestrationTemplateEntity.getContentData().array()));
+ }
+
void updateUniqueName(String oldVspName, String newVspName) {
uniqueValueUtil.updateUniqueValue(
VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index da4328dd91..75351e2fc5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -25,6 +25,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateMan
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.*;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
@@ -47,7 +48,8 @@ public class VspManagerFactoryImpl extends VspManagerFactory {
ComputeDaoFactory.getInstance().createInterface(),
ImageDaoFactory.getInstance().createInterface(),
new ManualVspToscaManagerImpl(),
- UniqueValueDaoFactory.getInstance().createInterface());
+ UniqueValueDaoFactory.getInstance().createInterface(), CandidateServiceFactory
+ .getInstance().createInterface());
@Override
public VendorSoftwareProductManager createInterface() {
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 f3d2916636..00120759d6 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
@@ -61,6 +61,8 @@ public interface CandidateService {
OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
Version version);
+ byte[] getZipData(ByteBuffer contentData) throws IOException;
+
void deleteOrchestrationTemplateCandidate(String vspId, Version version);
Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
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/OrchestrationTemplateCandidateDaoZusammenImpl.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/OrchestrationTemplateCandidateDaoZusammenImpl.java
index 22fe1dd98c..b72d684065 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/OrchestrationTemplateCandidateDaoZusammenImpl.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/OrchestrationTemplateCandidateDaoZusammenImpl.java
@@ -72,7 +72,7 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
zusammenAdaptor.getElementByName(context, elementContext, null,
ElementType.OrchestrationTemplateCandidate.name());
if (candidateElement.isPresent()) {
- if (VspZusammenUtil.hasEmptyData(candidateElement.get().getData())) {
+ if (VspZusammenUtil.isEmpty(candidateElement.get().getData())) {
return null;
}
OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
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/OrchestrationTemplateDaoZusammenImpl.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/OrchestrationTemplateDaoZusammenImpl.java
index 26280ecafa..0c1317f956 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/OrchestrationTemplateDaoZusammenImpl.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/OrchestrationTemplateDaoZusammenImpl.java
@@ -33,6 +33,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
+import java.util.Collection;
import java.util.Optional;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
@@ -40,8 +41,8 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao {
- private static final Logger LOGGER = LoggerFactory.getLogger
- (OrchestrationTemplateDaoZusammenImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(
+ OrchestrationTemplateDaoZusammenImpl.class);
private ZusammenAdaptor zusammenAdaptor;
public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -106,27 +107,38 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
Optional<Element> orchestrationTemplateElement = zusammenAdaptor
.getElementByName(context, elementContext, vspModel.get().getId(),
ElementType.OrchestrationTemplate.name());
- if (!orchestrationTemplateElement.isPresent()) {
+ if (orchestrationTemplateElement.isPresent() &&
+ VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.get().getData())) {
return orchestrationTemplate;
}
- if (!VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.get().getData())) {
- orchestrationTemplate.setContentData(
+ orchestrationTemplate.setContentData(
ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.get().getData())));
+
+ Collection<Element> subElements = orchestrationTemplateElement.get().getSubElements();
+ if (subElements.isEmpty()) {
+ return orchestrationTemplate;
}
- Optional<Element> validationDataElement =
- zusammenAdaptor.getElementByName(context, elementContext,
- orchestrationTemplateElement.get().getElementId(),
- ElementType.OrchestrationTemplateValidationData.name());
- if (validationDataElement.isPresent()) {
- orchestrationTemplate.setFileSuffix(validationDataElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- orchestrationTemplate.setFileName(validationDataElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
- if (!VspZusammenUtil.hasEmptyData(validationDataElement.get().getData())) {
- orchestrationTemplate.setValidationData(
- new String(FileUtils.toByteArray(validationDataElement.get().getData())));
+ for (Element element : subElements) {
+ Optional<Element> subElement = zusammenAdaptor.getElement(context,
+ elementContext, element.getElementId().toString());
+
+ if (subElement.get().getInfo().getName().equals(ElementType
+ .OrchestrationTemplateValidationData.name())) {
+ orchestrationTemplate.setFileSuffix(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ orchestrationTemplate.setFileName(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ if (!VspZusammenUtil.hasEmptyData(subElement.get().getData())) {
+ orchestrationTemplate.setValidationData(
+ new String(FileUtils.toByteArray(subElement.get().getData())));
+ }
+ } else if (subElement.get().getInfo().getName().equals(ElementType
+ .OrchestrationTemplateStructure.name())) {
+ orchestrationTemplate.setFilesDataStructure(new String(FileUtils.toByteArray(subElement
+ .get().getData())));
+
}
}
return orchestrationTemplate;
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/VspZusammenUtil.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/VspZusammenUtil.java
index d096b35d0d..09fd948030 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/VspZusammenUtil.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/VspZusammenUtil.java
@@ -30,6 +30,19 @@ class VspZusammenUtil {
return head;
}
+ static boolean isEmpty(InputStream elementData) {
+ byte[] byteElementData;
+ if (Objects.isNull(elementData)) {
+ return true;
+ }
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException e) {
+ return false;
+ }
+ return ArrayUtils.isEmpty(byteElementData);
+ }
+
static boolean hasEmptyData(InputStream elementData) {
String EMPTY_DATA = "{}";
byte[] byteElementData;
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 18910e3507..b962a79738 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
@@ -422,6 +422,29 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
+ public byte[] getZipData(ByteBuffer contentData)
+ throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try (final ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipInputStream zipStream = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
+ ZipEntry zipEntry;
+ while ((zipEntry = zipStream.getNextEntry()) != null) {
+ ZipEntry locZipEntry = new ZipEntry(zipEntry.getName());
+ zos.putNextEntry(locZipEntry);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = zipStream.read(buf)) > 0) {
+ zos.write(buf, 0, (len < buf.length) ? len : buf.length);
+ }
+ zos.closeEntry();
+ }
+ }
+ return baos.toByteArray();
+ }
+
+ @Override
public Optional<List<ErrorMessage>> validateFileDataStructure(
FilesDataStructure filesDataStructure) {
return candidateServiceValidator.validateFileDataStructure(filesDataStructure);