aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java37
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java10
3 files changed, 49 insertions, 5 deletions
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
index ecaf852a16..3e1b16d82f 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
@@ -2430,3 +2430,10 @@ errors:
message: "Error: Input name contains invalid characters. It should have only letters, numbers and underscores.",
messageId: "SVC4736"
}
+ #---------SVC4139------------------------------
+ # %1 - The action that is not supported
+ NOT_SUPPORTED: {
+ code: 400,
+ message: '%1 is not yet supported',
+ messageId: "SVC4139"
+ }
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;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 8a2cdef16e..07fff19f0b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -423,10 +423,12 @@ class ComponentInstanceBusinessLogicTest {
when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST))
.thenReturn(ActionStatus.INVALID_CONTENT);
- ComponentException e = assertThrows(ComponentException.class,
- () -> componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
- ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId"));
- assertThat(e.getActionStatus()).isEqualTo(ActionStatus.INVALID_CONTENT);
+ final Either<List<ComponentInstanceProperty>, ResponseFormat> response = componentInstanceBusinessLogic.createOrUpdatePropertiesValues(
+ ComponentTypeEnum.RESOURCE_INSTANCE, containerComponentID, resourceInstanceId, properties, "userId");
+ assertThat(response.isRight()).as("Response should be an error").isTrue();
+ final ResponseFormat responseFormat = response.right().value();
+ assertThat(responseFormat.getStatus()).as("Response status should be as expected").isEqualTo(400);
+ assertThat(responseFormat.getMessageId()).as("Error message id should be as expected").isEqualTo("SVC4000");
}
@Test