summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java22
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaFunctionExceptionSupplier.java36
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaGetFunctionExceptionSupplier.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java3
5 files changed, 63 insertions, 17 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 4bf81727e6..dcccfd961d 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
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ToscaFunctionExceptionSupplier;
import org.openecomp.sdc.be.components.impl.exceptions.ToscaGetFunctionExceptionSupplier;
import org.openecomp.sdc.be.components.impl.instance.ComponentInstanceChangeOperationOrchestrator;
import org.openecomp.sdc.be.components.impl.utils.DirectivesUtil;
@@ -1960,9 +1961,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
validateMandatoryFields(property);
validatePropertyExistsOnComponent(property, containerComponent, foundResourceInstance);
String propertyParentUniqueId = property.getParentUniqueId();
- if (property.isGetFunction()) {
- validateToscaGetFunction(property, containerComponent);
- property.setValue(property.getToscaGetFunction().generatePropertyValue());
+ if (property.isToscaFunction()) {
+ if (property.getToscaFunction().getType() == null) {
+ throw ToscaFunctionExceptionSupplier.missingFunctionType().get();
+ }
+ if (property.isToscaGetFunction()) {
+ validateToscaGetFunction(property, containerComponent);
+ }
+ property.setValue(property.getToscaFunction().getValue());
}
Either<String, ResponseFormat> updatedPropertyValue = updatePropertyObjectValue(property, containerComponent.getModel());
if (updatedPropertyValue.isRight()) {
@@ -2297,7 +2303,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// Specific Update Logic
String newValue = property.getValue();
- if (property.hasGetFunction()) {
+ if (property.hasToscaFunction()) {
return Either.left(newValue);
}
@@ -2369,7 +2375,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> void validateToscaGetFunction(T property, Component parentComponent) {
- final ToscaGetFunctionDataDefinition toscaGetFunction = property.getToscaGetFunction();
+ final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
validateGetToscaFunctionAttributes(toscaGetFunction);
validateGetPropertySource(toscaGetFunction.getFunctionType(), toscaGetFunction.getPropertySource());
if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_INPUT) {
@@ -2407,7 +2413,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
private <T extends PropertyDefinition> void validateGetFunction(final T property,
final List<? extends ToscaPropertyData> parentProperties,
final String model) {
- final ToscaGetFunctionDataDefinition toscaGetFunction = property.getToscaGetFunction();
+ final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
if (CollectionUtils.isEmpty(parentProperties)) {
throw ToscaGetFunctionExceptionSupplier
.propertyNotFoundOnTarget(toscaGetFunction.getPropertyName(), toscaGetFunction.getPropertySource(),
@@ -2428,11 +2434,11 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (!property.getType().equals(referredProperty.getType())) {
throw ToscaGetFunctionExceptionSupplier
- .propertyTypeDiverge(toscaGetFunction.getFunctionType(), referredProperty.getType(), property.getType()).get();
+ .propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
throw ToscaGetFunctionExceptionSupplier
- .propertySchemaDiverge(toscaGetFunction.getFunctionType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
+ .propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
index 7c01a35a32..e810999504 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicNew.java
@@ -140,8 +140,8 @@ public class GroupBusinessLogicNew {
if (!isOnlyGroupPropertyValueChanged(gp, originalProperties.get(updatedPropertyName))) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY, updatedPropertyName);
}
- if (gp.hasGetFunction()) {
- gp.setValue(gp.getToscaGetFunction().generatePropertyValue());
+ if (gp.hasToscaFunction()) {
+ gp.setValue(gp.getToscaFunction().getValue());
}
if (StringUtils.isEmpty(gp.getValue())) {
gp.setValue(originalProperties.get(updatedPropertyName).getDefaultValue());
@@ -237,13 +237,13 @@ public class GroupBusinessLogicNew {
groupProperty1Duplicate.setValue(null);
groupProperty1Duplicate.setSchema(null);
groupProperty1Duplicate.setParentUniqueId(null);
- groupProperty1Duplicate.setToscaGetFunction(null);
+ groupProperty1Duplicate.setToscaFunction(null);
groupProperty1Duplicate.setToscaGetFunctionType(null);
GroupProperty groupProperty2Duplicate = new GroupProperty(groupProperty2);
groupProperty2Duplicate.setValue(null);
groupProperty2Duplicate.setSchema(null);
groupProperty2Duplicate.setParentUniqueId(null);
- groupProperty2Duplicate.setToscaGetFunction(null);
+ groupProperty2Duplicate.setToscaFunction(null);
groupProperty2Duplicate.setToscaGetFunctionType(null);
return StringUtils.equals(groupProperty1Duplicate.getValueUniqueUid(), groupProperty2Duplicate.getValueUniqueUid()) && groupProperty1Duplicate
.equals(groupProperty2Duplicate);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaFunctionExceptionSupplier.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaFunctionExceptionSupplier.java
new file mode 100644
index 0000000000..2ba72ab80b
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaFunctionExceptionSupplier.java
@@ -0,0 +1,36 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.components.impl.exceptions;
+
+import java.util.function.Supplier;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class ToscaFunctionExceptionSupplier {
+
+ public static Supplier<ByActionStatusComponentException> missingFunctionType() {
+ return () -> new ByActionStatusComponentException(ActionStatus.TOSCA_FUNCTION_MISSING_ATTRIBUTE, "type");
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaGetFunctionExceptionSupplier.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaGetFunctionExceptionSupplier.java
index 44d6f50740..7adc93765a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaGetFunctionExceptionSupplier.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/exceptions/ToscaGetFunctionExceptionSupplier.java
@@ -26,7 +26,7 @@ import java.util.function.Supplier;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
import org.openecomp.sdc.be.datatypes.enums.PropertySource;
import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
@@ -38,6 +38,7 @@ public class ToscaGetFunctionExceptionSupplier {
final String errorMsg = String.format("%s on %s", toscaGetFunctionType.getFunctionName(), propertySource.getName());
return () -> new ByActionStatusComponentException(ActionStatus.NOT_SUPPORTED, errorMsg);
}
+
public static Supplier<ByActionStatusComponentException> propertyNotFoundOnTarget(final String propertyName,
final PropertySource propertySource,
final ToscaGetFunctionType functionType) {
@@ -106,21 +107,21 @@ public class ToscaGetFunctionExceptionSupplier {
return () -> new ByActionStatusComponentException(ActionStatus.NOT_SUPPORTED, "Tosca function " + functionType.getFunctionName());
}
- public static Supplier<ByActionStatusComponentException> propertyTypeDiverge(final ToscaGetFunctionType functionType,
+ public static Supplier<ByActionStatusComponentException> propertyTypeDiverge(final ToscaFunctionType functionType,
final String referredPropertyType,
final String propertyType) {
return () -> new ByActionStatusComponentException(
ActionStatus.TOSCA_GET_FUNCTION_TYPE_DIVERGE,
- functionType.getFunctionName(), referredPropertyType, propertyType
+ functionType.getName(), referredPropertyType, propertyType
);
}
- public static Supplier<ByActionStatusComponentException> propertySchemaDiverge(final ToscaGetFunctionType functionType,
+ public static Supplier<ByActionStatusComponentException> propertySchemaDiverge(final ToscaFunctionType functionType,
final String referredPropertySchemaType,
final String propertySchemaType) {
return () -> new ByActionStatusComponentException(
ActionStatus.TOSCA_GET_FUNCTION_SCHEMA_DIVERGE,
- functionType.getFunctionName(), referredPropertySchemaType, propertySchemaType
+ functionType.getName(), referredPropertySchemaType, propertySchemaType
);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index c1f45fe7ad..7d58687bfd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -83,6 +83,8 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ConstraintConvertor;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionJsonDeserializer;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -228,6 +230,7 @@ public class ComponentsUtils {
log.trace("convert json to object. json=\n{}", data);
SimpleModule module = new SimpleModule("customDeserializationModule");
module.addDeserializer(PropertyConstraint.class, new PropertyConstraintJacksonDeserializer());
+ module.addDeserializer(ToscaFunction.class, new ToscaFunctionJsonDeserializer());
mapper.registerModule(module);
component = mapper.readValue(data, clazz);
if (component == null) {