summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2019-09-03 08:37:55 +0000
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-09-03 13:38:08 +0000
commitccc1f364baea63733e93c6f4eb26ea97eeb77960 (patch)
tree2ce098bd1d4a28e611dd91f2eea6605a51cbf463 /openecomp-be/lib
parente79935cbaa180a86eea2c7631de14c16bef9b3d8 (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/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java2
-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/dao/type/OrchestrationTemplateCandidateData.java38
-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.java83
-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.java37
4 files changed, 107 insertions, 53 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
index 1eb688b057..d1ddc5c48d 100644
--- a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
+++ b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
@@ -31,7 +31,7 @@ public enum ElementType {
VspModel, NetworkPackage,
OrchestrationTemplateCandidate, OrchestrationTemplateCandidateContent,
- OrchestrationTemplateCandidateValidationData,
+ OrchestrationTemplateCandidateValidationData, ORIGINAL_ONBOARDED_PACKAGE,
OrchestrationTemplateStructure, OrchestrationTemplate,
OrchestrationTemplateValidationData,
// todo - remove OrchestrationTemplateContent
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/OrchestrationTemplateCandidateData.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/OrchestrationTemplateCandidateData.java
index 398d84c8e5..57e8405138 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/OrchestrationTemplateCandidateData.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/OrchestrationTemplateCandidateData.java
@@ -27,16 +27,26 @@ public class OrchestrationTemplateCandidateData {
private String fileSuffix;
private String fileName;
private String validationData;
+ private ByteBuffer originalFileContentData;
+ private String originalFileName;
+ private String originalFileSuffix;
public OrchestrationTemplateCandidateData() {
}
- public OrchestrationTemplateCandidateData(ByteBuffer contentData, String dataStructureJson,
- String fileSuffix, String fileName) {
+ public OrchestrationTemplateCandidateData(final ByteBuffer contentData,
+ final String dataStructureJson,
+ final String fileSuffix, final String fileName,
+ final String originalFileName,
+ final String originalFileSuffix,
+ final ByteBuffer originalFileContentData) {
this.contentData = contentData;
this.filesDataStructure = dataStructureJson;
this.fileSuffix = fileSuffix;
this.fileName = fileName;
+ this.originalFileName = originalFileName;
+ this.originalFileSuffix = originalFileSuffix;
+ this.originalFileContentData = originalFileContentData;
}
public ByteBuffer getContentData() {
@@ -88,4 +98,28 @@ public class OrchestrationTemplateCandidateData {
this.validationData = validationData == null ? null
: JsonUtil.object2Json(validationData);
}
+
+ public ByteBuffer getOriginalFileContentData() {
+ return originalFileContentData;
+ }
+
+ public void setOriginalFileContentData(ByteBuffer originalFileContentData) {
+ this.originalFileContentData = originalFileContentData;
+ }
+
+ public String getOriginalFileName() {
+ return originalFileName;
+ }
+
+ public void setOriginalFileName(String originalFileName) {
+ this.originalFileName = originalFileName;
+ }
+
+ public String getOriginalFileSuffix() {
+ return originalFileSuffix;
+ }
+
+ public void setOriginalFileSuffix(String originalFileSuffix) {
+ this.originalFileSuffix = originalFileSuffix;
+ }
}
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 c3dbab55f6..4c1e2e1ef2 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
@@ -16,6 +16,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -23,7 +26,11 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import java.io.ByteArrayInputStream;
+import java.nio.ByteBuffer;
+import java.util.Optional;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
@@ -34,13 +41,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCan
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
-import java.util.Optional;
-
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
-
public class OrchestrationTemplateCandidateDaoZusammenImpl
implements OrchestrationTemplateCandidateDao {
@@ -118,26 +118,30 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
return candidate.getFileSuffix() == null ? Optional.empty() : Optional.of(candidate);
}
- private void populateCandidate(OrchestrationTemplateCandidateData candidate,
- Element candidateInfoElement,
- boolean fullData) {
- if (candidateInfoElement.getInfo().getName()
- .equals(ElementType.OrchestrationTemplateCandidateContent.name())) {
-
+ private void populateCandidate(final OrchestrationTemplateCandidateData candidate,
+ final Element candidateInfoElement,
+ final boolean fullData) {
+ final String elementName = candidateInfoElement.getInfo().getName();
+ if (ElementType.OrchestrationTemplateCandidateContent.name().equals(elementName)) {
if (fullData) {
- candidate
- .setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())));
+ candidate.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData())));
+ }
+ candidate.setFileSuffix(candidateInfoElement.getInfo()
+ .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ candidate.setFileName(candidateInfoElement.getInfo()
+ .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ } else if (ElementType.OrchestrationTemplateCandidateValidationData.name().equals(elementName)) {
+ candidate.setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData())));
+ } else if (ElementType.ORIGINAL_ONBOARDED_PACKAGE.name().equals(elementName)) {
+ candidate.setOriginalFileName(candidateInfoElement.getInfo()
+ .getProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal()));
+ candidate.setOriginalFileSuffix(candidateInfoElement.getInfo()
+ .getProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal()));
+ if (fullData) {
+ candidate.setOriginalFileContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(candidateInfoElement.getData()))
+ );
}
- candidate.setFileSuffix(
- candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- candidate.setFileName(
- candidateInfoElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
-
- } else if (candidateInfoElement.getInfo().getName()
- .equals(ElementType.OrchestrationTemplateCandidateValidationData.name())) {
-
- candidate
- .setValidationData(new String(FileUtils.toByteArray(candidateInfoElement.getData())));
}
}
@@ -166,16 +170,15 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
}
@Override
- public void update(String vspId, Version version,
- OrchestrationTemplateCandidateData candidateData) {
+ public void update(final String vspId, final Version version,
+ final OrchestrationTemplateCandidateData candidateData) {
logger.info("Uploading candidate data entity for vsp id {}", vspId);
-
- ZusammenElement candidateElement =
+ final ZusammenElement candidateElement =
buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
candidateElement
.setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes()));
- ZusammenElement candidateContentElement =
+ final ZusammenElement candidateContentElement =
buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
candidateContentElement
.setData(new ByteArrayInputStream(candidateData.getContentData().array()));
@@ -184,14 +187,24 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
candidateContentElement.getInfo()
.addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName());
- ZusammenElement validationData = buildStructuralElement(ElementType
+ if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
+ final ZusammenElement originalPackageElement =
+ buildStructuralElement(ElementType.ORIGINAL_ONBOARDED_PACKAGE, Action.UPDATE);
+ originalPackageElement.getInfo()
+ .addProperty(InfoPropertyName.ORIGINAL_FILE_NAME.getVal(), candidateData.getOriginalFileName());
+ originalPackageElement.getInfo()
+ .addProperty(InfoPropertyName.ORIGINAL_FILE_SUFFIX.getVal(), candidateData.getOriginalFileSuffix());
+ originalPackageElement.setData(new ByteArrayInputStream(candidateData.getOriginalFileContentData().array()));
+ candidateElement.addSubElement(originalPackageElement);
+ }
+ final ZusammenElement validationData = buildStructuralElement(ElementType
.OrchestrationTemplateCandidateValidationData, Action.UPDATE);
if (candidateData.getValidationData() != null) {
validationData
.setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes()));
}
- candidateElement.addSubElement(candidateContentElement);
candidateElement.addSubElement(validationData);
+ candidateElement.addSubElement(candidateContentElement);
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
@@ -261,7 +274,9 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
public enum InfoPropertyName {
FILE_SUFFIX("fileSuffix"),
- FILE_NAME("fileName");
+ FILE_NAME("fileName"),
+ ORIGINAL_FILE_NAME("originalFilename"),
+ ORIGINAL_FILE_SUFFIX("originalFileSuffix");
private final String val;
@@ -269,7 +284,7 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
this.val = val;
}
- String getVal() {
+ private String getVal() {
return val;
}
}
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 93a706c688..3255e186e4 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
@@ -16,6 +16,25 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
+import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
@@ -49,20 +68,6 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-
public class CandidateServiceImpl implements CandidateService {
private static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator();
@@ -300,8 +305,8 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
- public void updateCandidateUploadData(String vspId, Version version,
- OrchestrationTemplateCandidateData uploadData) {
+ public void updateCandidateUploadData(final String vspId, final Version version,
+ final OrchestrationTemplateCandidateData uploadData) {
orchestrationTemplateCandidateDao.update(vspId, version, uploadData);
}