summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-01-12 13:41:59 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-04-09 06:46:27 +0000
commit6d65fde29c1859a7099d91ed0e8911bcb1823a38 (patch)
treea570de61d7bc39ccfdc2590d4813c97c2d58c18a /catalog-be/src/main/java/org
parent74f9a13c4211c5d75bbcff1ceb794bd060c6a49f (diff)
Allow property to take its value from defined input list
Issue-ID: SDC-3547 Change-Id: Ic438e8f8943d0f1c656e386611b88b25f879e83b Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 8515c5c468..d0c72e566c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -73,6 +73,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ForwardingPathUtils;
import org.openecomp.sdc.be.impl.ServiceFilterUtils;
@@ -1972,6 +1973,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resultOp = Either.left(updatedProperties);
return resultOp;
+ } catch (final ComponentException e) {
+ return Either.right(e.getResponseFormat());
} finally {
if (resultOp == null || resultOp.isRight()) {
janusGraphDao.rollback();
@@ -2169,10 +2172,17 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
innerType = propDef.getType();
}
+
// Specific Update Logic
+ String newValue = property.getValue();
+
+ if (property.getToscaGetFunctionType() != null) {
+ validateToscaGetFunction(property);
+ return Either.left(newValue);
+ }
+
Either<Object, Boolean> isValid = propertyOperation
.validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType, allDataTypes);
- String newValue = property.getValue();
if (isValid.isRight()) {
Boolean res = isValid.right().value();
if (!res) {
@@ -2198,6 +2208,31 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return Either.left(newValue);
}
+ private <T extends PropertyDefinition> void validateToscaGetFunction(T property) {
+ if (property.getToscaGetFunctionType() == ToscaGetFunctionType.GET_INPUT) {
+ final List<GetInputValueDataDefinition> getInputValues = property.getGetInputValues();
+ if (CollectionUtils.isEmpty(getInputValues)) {
+ log.debug("No input information provided. Cannot set get_input.");
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
+ }
+ if (getInputValues.size() > 1) {
+ log.debug("More than one input provided. Cannot set get_input.");
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
+ }
+ final GetInputValueDataDefinition getInputValueDataDefinition = getInputValues.get(0);
+
+ if (!property.getType().equals(getInputValueDataDefinition.getInputType())) {
+ log.debug("Input type '{}' diverges from the property type '{}'. Cannot set get_input.",
+ getInputValueDataDefinition.getInputType(), property.getType());
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
+ }
+ return;
+ }
+
+ throw new ByActionStatusComponentException(ActionStatus.NOT_SUPPORTED,
+ "Tosca function " + property.getToscaGetFunctionType().getToscaGetFunctionName());
+ }
+
private ResponseFormat updateInputOnContainerComponent(ComponentInstanceInput input, String newValue, Component containerComponent,
ComponentInstance foundResourceInstance) {
StorageOperationStatus status;