summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-03-08 13:33:17 +0530
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-03-08 08:46:07 +0000
commit2b60bd08c6b209c0817fac84970c35df4abca6ed (patch)
tree46483522798ca139bce9ce8c08c988001aad730d /openecomp-be/lib
parent9a79dcedfaaf173d2f301bb18b1832a799b1bc2f (diff)
Download processed file
Download processed file Change-Id: Ieaaea0ce231bc0418d9d997d652f85f1743031f0 Issue-ID: SDC-1087 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
-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
5 files changed, 68 insertions, 18 deletions
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);