diff options
Diffstat (limited to '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')
1 files changed, 49 insertions, 34 deletions
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; } } |