diff options
author | vasraz <vasyl.razinkov@est.tech> | 2023-07-31 20:19:20 +0100 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2023-08-01 14:57:25 +0000 |
commit | 91abd701e0e2b6b35c6bc4e42b280c60be23424c (patch) | |
tree | 56eb36b18a6c5e43d06bc38027ead3a8c453d343 /catalog-be/src/main/java | |
parent | a513e9de021a02397c797c7fe460d8e37765f9f7 (diff) |
Introduce error message for missing properties during the service import
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Ic0e3afaeea09ddbd0acdc31fb2fd2ad68a22cbb1
Issue-ID: SDC-4589
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java index ac14a3c683..c022304d8b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java @@ -20,7 +20,6 @@ import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; import static org.apache.commons.collections.CollectionUtils.isNotEmpty; -import static org.apache.hc.core5.http.HttpStatus.SC_BAD_REQUEST; import static org.openecomp.sdc.be.components.impl.ImportUtils.findFirstToscaMapElement; import static org.openecomp.sdc.be.components.impl.ImportUtils.findFirstToscaStringElement; import static org.openecomp.sdc.be.components.impl.ImportUtils.getPropertyJsonStringValue; @@ -31,8 +30,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import fj.data.Either; -import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -53,7 +50,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Pattern; import java.util.stream.Collectors; -import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; @@ -61,8 +57,6 @@ import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; import org.json.simple.JSONObject; import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic; import org.openecomp.sdc.be.components.csar.CsarBusinessLogic; @@ -175,8 +169,6 @@ import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.kpi.api.ASDCKpiApi; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.ValidationUtils; -import org.openecomp.sdc.common.zip.ZipUtils; -import org.openecomp.sdc.common.zip.exception.ZipException; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; import org.yaml.snakeyaml.Yaml; @@ -852,6 +844,7 @@ public class ServiceImportBusinessLogic { if (CollectionUtils.isNotEmpty(inputs)) { final List<ComponentInstance> componentInstances = component.getComponentInstances(); final String componentUniqueId = component.getUniqueId(); + List<String> propertyMissingNames = new ArrayList<>(); for (final InputDefinition input : inputs) { boolean isSubMapProp = false; if (substitutionMappingProperties != null && !substitutionMappingProperties.isEmpty()) { @@ -861,9 +854,15 @@ public class ServiceImportBusinessLogic { if (!isSubMapProp && isInputFromComponentInstanceProperty(input.getName(), componentInstances)) { associateInputToComponentInstanceProperty(userId, input, componentInstances, componentUniqueId); } else { - associateInputToServiceProperty(userId, input, component, substitutionMappingProperties); + String propertyName = associateInputToServiceProperty(userId, input, component, substitutionMappingProperties); + if (StringUtils.isNotBlank(propertyName)) { + propertyMissingNames.add(propertyName); + } } } + if (CollectionUtils.isNotEmpty(propertyMissingNames)) { + throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.MISSING_PROPERTIES_ERROR, propertyMissingNames.toString())); + } Either<List<InputDefinition>, StorageOperationStatus> either = toscaOperationFacade.updateInputsToComponent(inputs, componentUniqueId); if (either.isRight()) { throw new ComponentException(ActionStatus.GENERAL_ERROR); @@ -930,7 +929,7 @@ public class ServiceImportBusinessLogic { } } - private void associateInputToServiceProperty(final String userId, + private String associateInputToServiceProperty(final String userId, final InputDefinition input, final Service component, final Map<String, List<String>> substitutionMappingProperties) { final List<PropertyDefinition> properties = component.getProperties(); @@ -962,8 +961,10 @@ public class ServiceImportBusinessLogic { } } else { input.setMappedToComponentProperty(false); + return propertyNameFromInput.get(); } } + return ""; } private void updateProperty(final PropertyDefinition propertyDefinition, final InputDefinition input, final String componentUniqueId) { |