summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-01-26 15:53:57 +0000
committerJvD_Ericsson <jeff.van.dam@est.tech>2023-01-27 12:20:26 +0000
commitaa14db6b062be61ae8cba2bda1bb1aae6737d790 (patch)
tree89f7aa728b549b7b1605c188230c446546aa4bad /catalog-be/src/main/java
parentea6f082cd544f72400ac3e9eedb28880ebd9ccf0 (diff)
Fix added datatype property not include in model definitions
Issue-ID: SDC-4349 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: Ie94d697a64816f83be4783f1e52657b7fdd77b8c
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
index a7327bf184..13e2ba3259 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
@@ -144,21 +144,22 @@ public class DataTypeServlet extends BeGenericServlet {
public Response createProperty(@Parameter(in = ParameterIn.PATH, required = true, description = "The data type id")
@PathParam("id") final String id,
@RequestBody(description = "Property to add", required = true) final PropertyDefinitionDto propertyDefinitionDto) {
- Optional<DataTypeDataDefinition> dataType = dataTypeOperation.getDataTypeByUid(id);
- dataType.ifPresentOrElse(dt -> {
- String model = dt.getModel();
- Optional<DataTypeDataDefinition> propertyDataType = dataTypeOperation.getDataTypeByNameAndModel(propertyDefinitionDto.getType(), model);
- if (propertyDataType.isEmpty()) {
- if (model == null || model.isEmpty()) {
- model = "SDC AID";
- }
- throw new OperationException(ActionStatus.INVALID_MODEL,
- String.format("Property model is not the same as the data type model. Must be be '%s'", model));
- }
- }, () -> {
+ Optional<DataTypeDataDefinition> dataTypeOptional = dataTypeOperation.getDataTypeByUid(id);
+ dataTypeOptional.orElseThrow(() -> {
throw new OperationException(ActionStatus.DATA_TYPE_NOT_FOUND, String.format("Failed to find data type '%s'", id));
});
+ DataTypeDataDefinition dataType = dataTypeOptional.get();
+ String model = dataType.getModel();
+ Optional<DataTypeDataDefinition> propertyDataType = dataTypeOperation.getDataTypeByNameAndModel(propertyDefinitionDto.getType(), model);
+ if (propertyDataType.isEmpty()) {
+ if (model == null || model.isEmpty()) {
+ model = "SDC AID";
+ }
+ throw new OperationException(ActionStatus.INVALID_MODEL,
+ String.format("Property model is not the same as the data type model. Must be be '%s'", model));
+ }
final PropertyDefinitionDto property = dataTypeOperation.createProperty(id, propertyDefinitionDto);
+ dataTypeOperation.addPropertyToAdditionalTypeDataType(dataType, property);
dataTypeBusinessLogic.updateApplicationDataTypeCache(id);
return Response.status(Status.CREATED).entity(property).build();
}