summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java62
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java370
-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.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/VspZusammenUtil.java13
6 files changed, 405 insertions, 47 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index eef8c3cd44..c13e89cb76 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -65,39 +65,39 @@ public class HealingManagerImpl implements HealingManager {
public Optional<Version> healItemVersion(final String itemId, final Version version,
final ItemType itemType, final boolean force) {
String user = getUser();
- if (force || isPrivateHealingNeededByFlag(itemId, version.getId(), user)) {
-
- Map<String, Collection<String>> healersByType = getItemHealers(itemType);
- List<String> failureMessages = new LinkedList<>();
- List<Healer> structureHealersToRun =
- getHealersToRun(healersByType.get(HealerType.structure.name()), itemId, version,
- failureMessages);
- List<Healer> dataHealersToRun =
- getHealersToRun(healersByType.get(HealerType.data.name()), itemId, version,
- failureMessages);
-
- if (structureHealersToRun.isEmpty() && dataHealersToRun.isEmpty()) {
- markAsHealed(itemId, version.getId(), user);
- markAsHealed(itemId, version.getId(), PUBLIC_USER);
- return Optional.empty();
- }
-
- Optional<Version> healVersion = getHealVersion(itemId, version);
- if (!healVersion.isPresent()) {
- // do NOT turn off flag here (in thought of saving version calculate performance next
- // time) because maybe next time the next version will be available (due to deletion of
- // the taken one)
- return Optional.empty();
- }
+ if (!force && !isPrivateHealingNeededByFlags(itemId, version.getId(), user)) {
+ return Optional.empty();
+ }
- failureMessages.addAll(
- doHeal(itemId, healVersion.get(), version, structureHealersToRun, dataHealersToRun, user,
- force));
+ Map<String, Collection<String>> healersByType = getItemHealers(itemType);
+ List<String> failureMessages = new LinkedList<>();
+ List<Healer> structureHealersToRun =
+ getHealersToRun(healersByType.get(HealerType.structure.name()), itemId, version,
+ failureMessages);
+ List<Healer> dataHealersToRun =
+ getHealersToRun(healersByType.get(HealerType.data.name()), itemId, version,
+ failureMessages);
+
+ if (structureHealersToRun.isEmpty() && dataHealersToRun.isEmpty()) {
+ markAsHealed(itemId, version.getId(), user);
+ markAsHealed(itemId, version.getId(), PUBLIC_USER);
+ return Optional.empty();
+ }
- handleFailures(failureMessages);
- return healVersion;
+ Optional<Version> healVersion = getHealVersion(itemId, version);
+ if (!healVersion.isPresent()) {
+ // do NOT turn off flag here (in thought of saving version calculate performance next
+ // time) because maybe next time the next version will be available (due to deletion of
+ // the taken one)
+ return Optional.empty();
}
- return Optional.empty();
+
+ failureMessages.addAll(
+ doHeal(itemId, healVersion.get(), version, structureHealersToRun, dataHealersToRun, user,
+ force));
+ handleFailures(failureMessages);
+
+ return healVersion;
}
private Optional<Version> getHealVersion(String itemId, Version version) {
@@ -200,7 +200,7 @@ public class HealingManagerImpl implements HealingManager {
return failureMessages;
}
- private boolean isPrivateHealingNeededByFlag(String itemId, String version, String user) {
+ private boolean isPrivateHealingNeededByFlags(String itemId, String version, String user) {
Optional<Boolean> userHealingFlag = getHealingFlag(itemId, version, user);
return userHealingFlag.orElseGet(() -> isPublicHealingNeededByFlag(itemId, version));
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
index 2fc23372de..51de9d0802 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
@@ -1,7 +1,8 @@
{
"vsp": {
"structure": [
- "org.openecomp.sdc.healing.healers.OwnerHealer"
+ "org.openecomp.sdc.healing.healers.OwnerHealer",
+ "org.openecomp.sdc.healing.healers.NetworkPackageHealer"
],
"data": [
"org.openecomp.sdc.healing.healers.ToscaServiceModelHealer"
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java
new file mode 100644
index 0000000000..756521d49d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NetworkPackageHealer.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+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;
+import com.amdocs.zusammen.datatypes.Id;
+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 org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Objects;
+
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+public class NetworkPackageHealer implements Healer {
+
+ private static final byte[] EMPTY_DATA_BYTES = "{}".getBytes();
+ private static final String MISSING_ORCHESTRATION_TEMPLATE_CANDIDATE_ERROR =
+ "Vsp with invalid structure: does not contain element OrchestrationTemplateCandidate";
+ private static final String MISSING_ORCHESTRATION_TEMPLATE_CANDIDATE_CONTENT_ERROR =
+ "Vsp with invalid structure: does not contain element OrchestrationTemplateCandidateContent"
+ + " under OrchestrationTemplateCandidate";
+
+ private static final String MISSING_VSP_MODEL_ERROR =
+ "Vsp with invalid structure: does not contain element VspModel";
+ private static final String MISSING_ORCHESTRATION_TEMPLATE_ERROR =
+ "Vsp with invalid structure: does not contain element OrchestrationTemplate"
+ + " under VspModel element";
+ private static final String MISSING_ORCHESTRATION_TEMPLATE_VALIDATE_DATA_ERROR =
+ "Vsp with invalid structure: does not contain element OrchestrationTemplateValidationData"
+ + " under OrchestrationTemplate element";
+
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private ZusammenAdaptor zusammenAdaptor;
+ private CandidateService candidateService;
+
+ public NetworkPackageHealer() {
+ this.vspInfoDao = VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ this.zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
+ this.candidateService = CandidateServiceFactory.getInstance().createInterface();
+ }
+
+ @Override
+ public boolean isHealingNeeded(String itemId, Version version) {
+ return OnboardingMethod.NetworkPackage.name()
+ .equals(vspInfoDao.get(new VspDetails(itemId, version)).getOnboardingMethod()) &&
+ isVspMissingAddedElements(itemId, version);
+ }
+
+ @Override
+ public void heal(String itemId, Version version) throws Exception {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(itemId, version.getId());
+
+ Element candidateElement =
+ getElement(context, elementContext, null, ElementType.OrchestrationTemplateCandidate,
+ MISSING_ORCHESTRATION_TEMPLATE_CANDIDATE_ERROR);
+
+ Collection<Element> candidateSubs =
+ zusammenAdaptor.listElementData(context, elementContext, candidateElement.getElementId());
+
+ Id candidateValidationElementId =
+ creatIfAbsentCandidateValidationElementId(candidateSubs, context,
+ elementContext, candidateElement);
+
+ Element orchestrationTemplateElement = getOrchestrationTemplateElement(context, elementContext);
+
+ Collection<Element> orchestrationTemplateSubs = zusammenAdaptor
+ .listElementData(context, elementContext, orchestrationTemplateElement.getElementId());
+
+ Id structureElementId = createIfAbsentStructureElementId(orchestrationTemplateSubs, context,
+ elementContext, orchestrationTemplateElement);
+
+ Element orchestrationTemplateValidationElement = getOrchestrationTemplateValidationElement
+ (orchestrationTemplateSubs);
+
+ OrchestrationTemplateEntity orchestrationTemplateEntity =
+ getOrchestrationTemplateEntity(orchestrationTemplateElement,
+ orchestrationTemplateValidationElement);
+
+ if (StringUtils.isEmpty(orchestrationTemplateEntity.getFileSuffix())) {
+ return;
+ }
+
+ Element candidateContentElement = getCandidateContentElement(candidateSubs);
+
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(itemId, version));
+ if (isEqual(orchestrationTemplateEntity,
+ getCandidateData(candidateElement, candidateContentElement))) {
+
+ if (isProcessedEntityValid(orchestrationTemplateEntity)) {
+ emptyStructureElementAndSub(context, elementContext, candidateElement.getElementId(),
+ ElementType.OrchestrationTemplateCandidate, candidateContentElement.getElementId(),
+ ElementType.OrchestrationTemplateCandidateContent);
+
+ populateOrchestrationTemplateStructure(orchestrationTemplateElement.getData(),
+ structureElementId, vspDetails, context, elementContext);
+ } else {
+ emptyStructureElementAndSub(context, elementContext,
+ orchestrationTemplateElement.getElementId(), ElementType.OrchestrationTemplate,
+ orchestrationTemplateValidationElement.getElementId(),
+ ElementType.OrchestrationTemplateValidationData);
+
+ populateCandidateValidationData(context, elementContext, candidateValidationElementId,
+ orchestrationTemplateEntity.getValidationData());
+ }
+ } else {
+ populateOrchestrationTemplateStructure(orchestrationTemplateElement.getData(),
+ structureElementId, vspDetails, context, elementContext);
+ }
+ }
+
+ private boolean isVspMissingAddedElements(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ return zusammenAdaptor.listElementsByName(context, elementContext, null,
+ ElementType.OrchestrationTemplateCandidate.name()).stream()
+ .noneMatch(candidateSub -> ElementType.OrchestrationTemplateCandidateValidationData.name()
+ .equals(candidateSub.getInfo().getName()));
+ }
+
+ private boolean isEqual(OrchestrationTemplateEntity orchestrationTemplateEntity,
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData) {
+ return orchestrationTemplateEntity.getFileName()
+ .equals(orchestrationTemplateCandidateData.getFileName()) &&
+ orchestrationTemplateEntity.getFileSuffix()
+ .equals(orchestrationTemplateCandidateData.getFileSuffix());
+ }
+
+ private boolean isProcessedEntityValid(OrchestrationTemplateEntity orchestrationTemplateEntity) {
+ return !orchestrationTemplateEntity.getValidationData().contains(ErrorLevel.ERROR.name());
+ }
+
+ private void populateCandidateValidationData(SessionContext context,
+ ElementContext elementContext,
+ Id candidateValidationElementId,
+ String validationData) {
+ ZusammenElement candidateValidationElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateValidationData,
+ Action.UPDATE);
+ candidateValidationElement.setElementId(candidateValidationElementId);
+ candidateValidationElement.setData(new ByteArrayInputStream(validationData.getBytes()));
+
+ zusammenAdaptor.saveElement(context, elementContext, candidateValidationElement,
+ "Healed Orchestration Template Candidate Validation data");
+ }
+
+ private void populateOrchestrationTemplateStructure(InputStream processedFile,
+ Id structureElementId, VspDetails vspDetails,
+ SessionContext context,
+ ElementContext elementContext)
+ throws Exception {
+ byte[] byteData = FileUtils.toByteArray(processedFile);
+ FileContentHandler contentMap =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteData);
+ OrchestrationTemplateCandidateData orchestrationTemplateEntityData =
+ new CandidateEntityBuilder(candidateService)
+ .buildCandidateEntityFromZip(vspDetails, byteData, contentMap, null);
+ String fileDataStructure = orchestrationTemplateEntityData.getFilesDataStructure();
+
+ ZusammenElement orchestrationTemplateStructure =
+ buildStructuralElement(ElementType.OrchestrationTemplateStructure, Action.UPDATE);
+ orchestrationTemplateStructure.setElementId(structureElementId);
+ orchestrationTemplateStructure.setData(new ByteArrayInputStream(fileDataStructure.getBytes()));
+
+ zusammenAdaptor.saveElement(context, elementContext, orchestrationTemplateStructure,
+ "Healed Orchestration Template Structure");
+ }
+
+ private Element getOrchestrationTemplateElement(SessionContext context,
+ ElementContext elementContext) {
+ ElementInfo vspModelElement = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name())
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(MISSING_VSP_MODEL_ERROR).build()));
+
+ return getElement(context, elementContext, vspModelElement.getId(),
+ ElementType.OrchestrationTemplate, MISSING_ORCHESTRATION_TEMPLATE_ERROR);
+ }
+
+ private Element getOrchestrationTemplateValidationElement(
+ Collection<Element> orchestrationTemplateSubs) {
+ return orchestrationTemplateSubs.stream()
+ .filter(orchestrationTemplateSub -> ElementType.OrchestrationTemplateValidationData.name()
+ .equals(orchestrationTemplateSub.getInfo().getName()))
+ .findFirst()
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(MISSING_ORCHESTRATION_TEMPLATE_VALIDATE_DATA_ERROR).build()));
+
+ }
+
+ private Element getCandidateContentElement(Collection<Element> candidateSubs) {
+ return candidateSubs.stream()
+ .filter(candidateSub -> ElementType.OrchestrationTemplateCandidateContent.name()
+ .equals(candidateSub.getInfo().getName()))
+ .findFirst()
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(MISSING_ORCHESTRATION_TEMPLATE_CANDIDATE_CONTENT_ERROR).build()));
+ }
+
+ private Id createIfAbsentStructureElementId(Collection<Element> orchestrationTemplateSubs,
+ SessionContext context, ElementContext elementContext,
+ Element orchestrationTemplateElement) {
+ return orchestrationTemplateSubs.stream()
+ .filter(orchestrationTemplateSub -> ElementType.OrchestrationTemplateStructure.name()
+ .equals(orchestrationTemplateSub.getInfo().getName()))
+ .findFirst().map(Element::getElementId)
+ .orElse(addStructureSubElement(context, elementContext,
+ ElementType.OrchestrationTemplateStructure,
+ orchestrationTemplateElement.getElementId()));
+ }
+
+ private Id creatIfAbsentCandidateValidationElementId(Collection<Element> candidateSubs,
+ SessionContext context, ElementContext
+ elementContext, Element candidateElement) {
+ return candidateSubs.stream()
+ .filter(candidateSub -> ElementType.OrchestrationTemplateCandidateValidationData.name()
+ .equals(candidateSub.getInfo().getName()))
+ .findFirst().map(Element::getElementId)
+ .orElse(addStructureSubElement(context, elementContext,
+ ElementType.OrchestrationTemplateCandidateValidationData,
+ candidateElement.getElementId()));
+ }
+
+ private Element getElement(SessionContext context, ElementContext elementContext,
+ Id parentElementId, ElementType elementType, String errorMessage) {
+ return zusammenAdaptor
+ .getElementByName(context, elementContext, parentElementId, elementType.name())
+ .orElseThrow(() -> new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withMessage(errorMessage).build()));
+ }
+
+ private OrchestrationTemplateEntity getOrchestrationTemplateEntity(
+ Element orchestrationTemplateElement, Element validationDataElement) {
+ OrchestrationTemplateEntity orchestrationTemplateEntity = new OrchestrationTemplateEntity();
+
+ if (isNotEmpty(orchestrationTemplateElement.getData())) {
+ orchestrationTemplateEntity.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.getData())));
+ }
+ orchestrationTemplateEntity.setFileSuffix(
+ validationDataElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ orchestrationTemplateEntity.setFileName(
+ validationDataElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ if (isNotEmpty(validationDataElement.getData())) {
+ orchestrationTemplateEntity
+ .setValidationData(new String(FileUtils.toByteArray(validationDataElement.getData())));
+ }
+ return orchestrationTemplateEntity;
+ }
+
+ private OrchestrationTemplateCandidateData getCandidateData(Element candidateElement,
+ Element candidateContentElement) {
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+ candidateData
+ .setFilesDataStructure(new String(FileUtils.toByteArray(candidateElement.getData())));
+ candidateData
+ .setContentData(ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.getData())));
+ candidateData.setFileSuffix(
+ candidateContentElement.getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ candidateData.setFileName(
+ candidateContentElement.getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ return candidateData;
+ }
+
+ private Id addStructureSubElement(SessionContext context, ElementContext elementContext,
+ ElementType elementType, Id parentElementId) {
+ ZusammenElement newElement = buildStructuralElement(elementType, Action.CREATE);
+
+ ZusammenElement parentElement = buildElement(parentElementId, Action.IGNORE);
+ parentElement.addSubElement(newElement);
+
+ return zusammenAdaptor.saveElement(context, elementContext, parentElement,
+ String.format("Add element %s under element id %s", elementType.name(), parentElementId))
+ .getSubElements().iterator().next().getElementId();
+ }
+
+ private void emptyStructureElementAndSub(SessionContext context, ElementContext elementContext,
+ Id elementId, ElementType elementType, Id subElementId,
+ ElementType subElementType) {
+ ZusammenElement subElement = buildStructuralElement(subElementType, Action.UPDATE);
+ subElement.setElementId(subElementId);
+ subElement.setData(new ByteArrayInputStream(EMPTY_DATA_BYTES));
+
+ ZusammenElement element = buildStructuralElement(elementType, Action.UPDATE);
+ element.setElementId(elementId);
+ element.setData(new ByteArrayInputStream(EMPTY_DATA_BYTES));
+ element.addSubElement(subElement);
+
+ zusammenAdaptor.saveElement(context, elementContext, element,
+ String.format("Empty element %s and its sub element %s", elementType.name(),
+ subElementType.name()));
+ }
+
+ public enum InfoPropertyName {
+ FILE_SUFFIX("fileSuffix"),
+ FILE_NAME("fileName");
+
+ private String val;
+
+ InfoPropertyName(String val) {
+ this.val = val;
+ }
+
+ private String getVal() {
+ return val;
+ }
+ }
+
+ private boolean isNotEmpty(InputStream elementData) {
+ byte[] byteElementData;
+ if (Objects.isNull(elementData)) {
+ return false;
+ }
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException e) {
+ return true;
+ }
+ return !ArrayUtils.isEmpty(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/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 bf592e2169..22fe1dd98c 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
@@ -271,7 +271,7 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null,
ElementType.OrchestrationTemplateCandidate.name());
- if (element.isPresent() && !VspZusammenUtil.isEmpty(element.get().getData())) {
+ if (element.isPresent() && !VspZusammenUtil.hasEmptyData(element.get().getData())) {
return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
}
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 3b3cdfead3..26280ecafa 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
@@ -187,7 +187,7 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
orchestrationTemplateElement.get().getElementId(),
ElementType.OrchestrationTemplateStructure.name());
if (orchestrationTemplateStructureElement.isPresent() &&
- !VspZusammenUtil.isEmpty(orchestrationTemplateStructureElement.get().getData())) {
+ !VspZusammenUtil.hasEmptyData(orchestrationTemplateStructureElement.get().getData())) {
return Optional.of(new String(
FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData())));
}
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 09fd948030..d096b35d0d 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,19 +30,6 @@ 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;