aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java41
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java52
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java23
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java12
22 files changed, 153 insertions, 215 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 df13e80fe8..cbbd5eeef6 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
@@ -2536,3 +2536,12 @@ errors:
message: "Error: Component '%1' with Vendor Release '%2' already exists.",
messageId: "SVC4152"
}
+
+ #-----------SVC4153---------------------------
+ # %1 - "Model name"
+ DATA_TYPES_NOT_LOADED: {
+ code: 500,
+ message: "Error: Could not fetch data types from data base with model %1",
+ messageId: "SVC4153"
+ }
+
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
index f8d487169a..953f5e3804 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
@@ -54,7 +54,7 @@ public class AnnotationBusinessLogic {
if (isNotEmpty(inputAnnotationList)) {
for (Annotation annotation : inputAnnotationList) {
AnnotationTypeDefinition dbAnnotationTypeDefinition = annotationTypeOperations.getLatestType(annotation.getType());
- validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition);
+ validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition, input.getModel());
}
}
input.setAnnotations(inputAnnotationList);
@@ -66,15 +66,16 @@ public class AnnotationBusinessLogic {
return annotationTypeOperations;
}
- private void validateMergeAndSetAnnoProps(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
- annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition);
+ private void validateMergeAndSetAnnoProps(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
+ annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition, model);
List<PropertyDataDefinition> mergedPropertiesList = mergePropsOfAnnoDataTypeWithParsedAnnoProps(annotation.getProperties(),
dbAnnotationTypeDefinition.getProperties());
annotation.setProperties(mergedPropertiesList);
}
- private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(List<PropertyDataDefinition> annoProperties,
- List<PropertyDefinition> typePropertiesList) {
+ private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(final List<PropertyDataDefinition> annoProperties,
+ final List<PropertyDefinition> typePropertiesList) {
Set<PropertyDataDefinition> mergedPropertiesSet = new HashSet<>(typePropertiesList);
Map<String, PropertyDefinition> typePropsMap = MapUtil.toMap(typePropertiesList, PropertyDefinition::getName);
for (PropertyDataDefinition propertyDataDefinitionObject : annoProperties) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index 687a5d56ef..2380d48deb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -104,13 +104,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (isAttributeExist(resource.getAttributes(), resourceId, newAttributeDef.getName())) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_ALREADY_EXIST, newAttributeDef.getName()));
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ // fetch DataTypes by Model Name
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ handleAttributeDefaultValue(newAttributeDef, allDataTypes);
// add the new attribute to resource on graph
// need to get StorageOperationStatus and convert to ActionStatus from
@@ -252,14 +253,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
// add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
+ StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, allDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 792e6963c0..3cb76806c8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -118,7 +118,6 @@ public abstract class BaseBusinessLogic {
protected AttributeOperation attributeOperation;
protected ApplicationDataTypeCache applicationDataTypeCache;
protected ToscaOperationFacade toscaOperationFacade;
- protected ApplicationDataTypeCache dataTypeCache;
protected IGroupOperation groupOperation;
protected IGroupInstanceOperation groupInstanceOperation;
protected InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
@@ -191,11 +190,6 @@ public abstract class BaseBusinessLogic {
}
@Autowired
- public void setDataTypeCache(ApplicationDataTypeCache dataTypeCache) {
- this.dataTypeCache = dataTypeCache;
- }
-
- @Autowired
public void setPropertyOperation(PropertyOperation propertyOperation) {
this.propertyOperation = propertyOperation;
}
@@ -341,21 +335,12 @@ public abstract class BaseBusinessLogic {
}
<T extends PropertyDataDefinition> String updateInputPropertyObjectValue(T property) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
String propertyType = property.getType();
String innerType = getInnerType(property);
// Specific Update Logic
Either<Object, Boolean> isValid = propertyOperation
- .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType, allDataTypes);
+ .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel()));
String newValue = property.getValue();
if (isValid.isRight()) {
Boolean res = isValid.right().value();
@@ -433,21 +418,6 @@ public abstract class BaseBusinessLogic {
return null;
}
- protected Map<String, DataTypeDefinition> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
- if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.DATA_TYPE_CANNOT_BE_EMPTY);
- } else {
- BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
- }
- }
- return allDataTypes.left().value();
- }
-
Either<Boolean, ResponseFormat> validatePropertyDefaultValue(IComplexDefaultValue property, Map<String, DataTypeDefinition> dataTypes) {
String type;
String innerType = null;
@@ -706,7 +676,8 @@ public abstract class BaseBusinessLogic {
if (inputPathArr.length > 1) {
inputPathArr = ArrayUtils.remove(inputPathArr, 0);
}
- Map<String, DataTypeDefinition> dataTypeDefinitionMap = applicationDataTypeCache.getAll().left().value();
+ final Map<String, DataTypeDefinition> dataTypeDefinitionMap =
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, inputDefinition.getModel());
String propertyType = inputDefinition.getParentPropertyType();
for (String anInputPathArr : inputPathArr) {
if (ToscaType.isPrimitiveType(propertyType)) {
@@ -774,4 +745,8 @@ public abstract class BaseBusinessLogic {
}
return result.left().value();
}
+
+ public String getComponentModelByComponentId(final String componentId) throws BusinessLogicException {
+ return getComponent(componentId).getModel();
+ }
}
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 bce343efaf..e2c3df172d 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
@@ -2227,16 +2227,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> validatePropertyObjectValue(T property, String newValue, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String propertyType = property.getType();
String innerType = getInnerType(property);
@@ -2275,16 +2266,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> updatePropertyObjectValue(T property, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String innerType = null;
String propertyType = property.getType();
ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
@@ -2341,15 +2323,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends AttributeDefinition> Either<String, ResponseFormat> updateAttributeObjectValue(final T attribute) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update attribute value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
String innerType = null;
final String attributeType = attribute.getType();
final ToscaPropertyType type = ToscaPropertyType.isValidType(attributeType);
@@ -2374,7 +2347,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// Specific Update Logic
String newValue = attribute.getValue();
- final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType, allDataTypesEither.left().value());
+ final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, attribute.getModel()));
if (isValid.isRight()) {
final Boolean res = isValid.right().value();
if (!Boolean.TRUE.equals(res)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
index be61e7b112..db53800d7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
@@ -40,7 +40,7 @@ public class DataTypesService {
}
public Either<Map<String, DataTypeDefinition>, ResponseFormat> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(null);
if (allDataTypes.isRight()) {
JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index 0d85675c45..ae9ab04a87 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -1068,19 +1068,13 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
boolean fromCsar) {
Map<String, GroupDataDefinition> groups = new HashMap<>();
Either<List<GroupDefinition>, ResponseFormat> result = null;
- Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
+ Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult;
+
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
@@ -1150,18 +1144,11 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
Either<List<GroupDefinition>, ResponseFormat> result = null;
Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
List<GroupDataDefinition> groups = new ArrayList<>();
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 0d9681a8dc..28faf73c21 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -289,14 +289,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
}
//Validate value and Constraint of input
- Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs);
+ Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs, component.getModel());
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return Either.right(constraintValidatorResponse.right().value());
}
validateCanWorkOnComponent(component, userId);
Map<String, DataTypeDefinition> dataTypes;
- dataTypes = getAllDataTypes(applicationDataTypeCache);
+ dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
List<InputDefinition> componentsOldInputs = Optional.ofNullable(component.getInputs()).orElse(Collections.emptyList());
for (InputDefinition newInput : inputs) {
InputDefinition currInput = getInputFromInputsListById(componentsOldInputs, newInput);
@@ -335,7 +335,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return result;
}
- private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs) {
+ private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs, final String model) {
PropertyValueConstraintValidationUtil propertyValueConstraintValidationUtil = PropertyValueConstraintValidationUtil.getInstance();
List<InputDefinition> inputDefinitions = new ArrayList<>();
for (InputDefinition inputDefinition : inputs) {
@@ -350,7 +350,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
inputDefinitions.add(inputDef);
}
- return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache);
+ return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache, model);
}
public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
@@ -571,7 +571,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
List<InputDefinition> resourceProperties = component.getInputs();
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(applicationDataTypeCache);
+ final Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
String inputName = inputDefinition.getKey();
@@ -609,8 +609,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
log.trace("#createListInputsInGraph: enter");
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(
- applicationDataTypeCache);
+ Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
dataTypes.putAll(privateDataTypes);
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
@@ -829,7 +828,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_ALREADY_EXIST, inputName));
return result;
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate input default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newInputDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
index d7564ed50e..bbdae470e1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
@@ -78,10 +78,6 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
artifactToscaOperation);
}
- public Map<String, DataTypeDefinition> getAllDataTypes() {
- return getAllDataTypes(applicationDataTypeCache);
- }
-
/**
* Create new property on component in graph
*
@@ -123,7 +119,7 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, propertyName));
return result;
} else {
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate property default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newPropertyDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 2435b5e937..c401948495 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -83,7 +83,6 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
@@ -152,7 +151,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
@@ -2301,21 +2299,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
- log.debug("#createResourceInstancesRelations - Before get all datatypes. ");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR while update property value on instance. Status is: " + status);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName);
- }
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, existingNodeTypesByResourceNames, instInputs, i));
resource.getComponentInstances().stream().filter(i -> !i.isCreatedFromCsar()).forEach(
i -> processUiComponentInstance(oldResource, i, instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts,
@@ -2536,7 +2523,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void processComponentInstance(String yamlName, Resource resource, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -2574,12 +2561,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -2602,7 +2589,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return originResource;
}
- private void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ private void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo, ComponentInstance currentCompInstance,
Resource originResource) {
@@ -2612,18 +2599,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
originResource.getCapabilities().forEach((k, v) -> addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values().forEach(l -> addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(originCapabilities, newPropertiesMap, allDataTypes);
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- private void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
- Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ private void updateCapabilityPropertiesValues(Map<String, List<CapabilityDefinition>> originCapabilities,
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap,
+ Map<String, DataTypeDefinition> allDataTypes) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
private void addCapabilitiesProperties(Map<String, Map<String, UploadPropInfo>> newPropertiesMap, List<UploadCapInfo> capabilities) {
@@ -4931,7 +4918,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("Invalid type for property {}", property);
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
type = property.getType();
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
ResponseFormat responseFormat = validateMapOrListPropertyType(property, innerType, allDataTypes);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 6efdab4a96..9f1669c135 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -320,7 +320,7 @@ public class ResourceImportManager {
if (toscaElements.isLeft()) {
final Map<String, Object> toscaAttributes = (Map<String, Object>) foundElements.get(0);
if (MapUtils.isNotEmpty(toscaAttributes)) {
- resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes));
+ resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes, resource.getModel()));
}
}
// Derived From
@@ -914,10 +914,12 @@ public class ResourceImportManager {
}
private List<DataTypeDefinition> extractDataTypeFromJson(final ResourceBusinessLogic resourceBusinessLogic,
- final Map<String, Object> foundElements) {
+ final Map<String, Object> foundElements,
+ final String model) {
final List<DataTypeDefinition> dataTypeDefinitionList = new ArrayList<>();
if (MapUtils.isNotEmpty(foundElements)) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll = resourceBusinessLogic.dataTypeCache.getAll();
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll =
+ resourceBusinessLogic.applicationDataTypeCache.getAll(model);
if (dataTypeCacheAll.isLeft()) {
for (final Entry<String, Object> attributeNameValue : foundElements.entrySet()) {
final Object value = attributeNameValue.getValue();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 21d27f3fa0..50cf5d8c65 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -382,11 +382,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (STATIC.equals(sourceValue)) {
// Validate constraint on input value
Either<Boolean, ResponseFormat> constraintValidationResult = validateOperationInputConstraint(operationInputDefinition, consumptionValue,
- type);
+ type, containerService.getModel());
if (constraintValidationResult.isRight()) {
return Either.right(constraintValidationResult.right().value());
}
- return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition);
+ return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition, containerService.getModel());
}
if (Objects.isNull(sourceValue)) {
List<PropertyDefinition> propertyDefinitions;
@@ -523,13 +523,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
public Either<Operation, ResponseFormat> handleConsumptionStaticValue(String value, String type, Operation operation,
- OperationInputDefinition operationInputDefinition) {
+ OperationInputDefinition operationInputDefinition, String model) {
boolean isInputTypeSimilarToOperation = isAssignedValueFromValidType(type, value);
if (!isInputTypeSimilarToOperation) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONSUMPTION_TYPE, type));
}
//Validate Constraint and Value
- Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type);
+ Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type, model);
if (constraintValidationResponse.isRight()) {
return Either.right(constraintValidationResponse.right().value());
}
@@ -538,7 +538,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Boolean, ResponseFormat> validateOperationInputConstraint(OperationInputDefinition operationInputDefinition, String value,
- String type) {
+ String type, String model) {
ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
propertyDefinition.setType(operationInputDefinition.getParentPropertyType());
InputDefinition inputDefinition = new InputDefinition();
@@ -548,8 +548,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (Objects.nonNull(operationInputDefinition.getParentPropertyType())) {
inputDefinition.setProperties(Collections.singletonList(propertyDefinition));
}
- return PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ return PropertyValueConstraintValidationUtil.getInstance().validatePropertyConstraints(Collections.singletonList(inputDefinition),
+ applicationDataTypeCache, model);
}
private void addStaticValueToInputOperation(String value, Operation operation, OperationInputDefinition operationInputDefinition) {
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 c0c68d6c47..1a5a996a46 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
@@ -66,7 +66,6 @@ import org.openecomp.sdc.be.components.validation.component.ComponentValidator;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
@@ -108,6 +107,7 @@ import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -120,7 +120,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.CsarUtils;
@@ -965,20 +964,14 @@ public class ServiceImportBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
log.debug("enter ServiceImportBusinessLogic createResourceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
@@ -1333,20 +1326,13 @@ public class ServiceImportBusinessLogic {
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
log.debug("enter ServiceImportBusinessLogic createServiceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Service finalResource = service;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
- instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties,
+ instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
@@ -1376,7 +1362,7 @@ public class ServiceImportBusinessLogic {
}
protected void processComponentInstance(String yamlName, Component component, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -1416,12 +1402,12 @@ public class ServiceImportBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.VF) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, component, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -1557,7 +1543,7 @@ public class ServiceImportBusinessLogic {
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
- protected void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo,
ComponentInstance currentCompInstance, Resource originResource) {
@@ -1569,18 +1555,18 @@ public class ServiceImportBusinessLogic {
originResource.getCapabilities().forEach((k, v) -> serviceImportParseLogic.addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values()
.forEach(l -> serviceImportParseLogic.addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap, originResource.getModel());
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- protected void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void updateCapabilityPropertiesValues(Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap, String model) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
protected void updatePropertyValues(List<ComponentInstanceProperty> properties, Map<String, UploadPropInfo> newProperties,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
index 9888129071..272798f869 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
@@ -43,15 +43,15 @@ public class PropertyDataValueMergeBusinessLogic {
private static final Logger LOGGER = Logger.getLogger(PropertyDataValueMergeBusinessLogic.class);
private final PropertyValueMerger propertyValueMerger;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final PropertyConvertor propertyConvertor;
private final Gson gson = new Gson();
@Autowired
- public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache dataTypeCache,
+ public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache applicationDataTypeCache,
PropertyConvertor propertyConvertor) {
this.propertyValueMerger = propertyValueMerger;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
}
@@ -60,7 +60,7 @@ public class PropertyDataValueMergeBusinessLogic {
* @param newProp the new property to merge value into
*/
public void mergePropertyValue(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, List<String> getInputNamesToMerge) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(oldProp.getModel());
if (dataTypesEither.isRight()) {
LOGGER.debug("failed to fetch data types, skip merging of previous property values. status: {}", dataTypesEither.right().value());
} else {
@@ -116,4 +116,5 @@ public class PropertyDataValueMergeBusinessLogic {
String getInputEntry = "\"%s\":\"%s\"";
return value != null && value.contains(String.format(getInputEntry, ToscaFunctions.GET_INPUT.getFunctionName(), inputName));
}
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
index b4f6bbe7db..a443e5f90b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
@@ -21,52 +21,49 @@ package org.openecomp.sdc.be.components.validation;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.components.impl.utils.ExceptionUtils;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
@Component
public class AnnotationValidator {
- private static final Logger log = Logger.getLogger(ResourceImportManager.class);
private final PropertyValidator propertyValidator;
private final ExceptionUtils exceptionUtils;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final ComponentsUtils componentsUtils;
- public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache dataTypeCache,
+ public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache applicationDataTypeCache,
ComponentsUtils componentsUtils) {
this.propertyValidator = propertyValidator;
this.exceptionUtils = exceptionUtils;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.componentsUtils = componentsUtils;
}
- public List<Annotation> validateAnnotationsProperties(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
+ public List<Annotation> validateAnnotationsProperties(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
List<Annotation> validAnnotations = new ArrayList<>();
- if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties())) {
+ if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties(), model)) {
validAnnotations.add(annotation);
}
return validAnnotations;
}
- private boolean propertiesValidator(List<PropertyDataDefinition> properties, List<PropertyDefinition> dbAnnotationTypeDefinitionProperties) {
+ private boolean propertiesValidator(final List<PropertyDataDefinition> properties,
+ final List<PropertyDefinition> dbAnnotationTypeDefinitionProperties, final String model) {
List<PropertyDefinition> propertyDefinitionsList = new ArrayList<>();
if (properties == null || dbAnnotationTypeDefinitionProperties == null) {
return false;
}
properties.stream().forEach(property -> propertyDefinitionsList.add(new PropertyDefinition(property)));
- Map<String, DataTypeDefinition> allDataTypes = dataTypeCache.getAll().left().on(error -> exceptionUtils.rollBackAndThrow(error));
- propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties, allDataTypes);
+ propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties,
+ applicationDataTypeCache.getAll(model).left().on(error -> exceptionUtils.rollBackAndThrow(error)));
return true;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 9569247047..e7c6ef386d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -62,10 +62,11 @@ public class PropertyValueConstraintValidationUtil {
return new PropertyValueConstraintValidationUtil();
}
- public Either<Boolean, ResponseFormat> validatePropertyConstraints(Collection<? extends PropertyDefinition> propertyDefinitionList,
- ApplicationDataTypeCache applicationDataTypeCache) {
+ public Either<Boolean, ResponseFormat> validatePropertyConstraints(final Collection<? extends PropertyDefinition> propertyDefinitionList,
+ final ApplicationDataTypeCache applicationDataTypeCache,
+ final String model) {
ResponseFormatManager responseFormatManager = getResponseFormatManager();
- dataTypeDefinitionCache = applicationDataTypeCache.getAll().left().value();
+ dataTypeDefinitionCache = applicationDataTypeCache.getAll(model).left().value();
CollectionUtils.emptyIfNull(propertyDefinitionList).stream().filter(this::isValuePresent)
.forEach(this::evaluatePropertyTypeForConstraintValidation);
if (CollectionUtils.isNotEmpty(errorMessages)) {
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 607497ca26..3b55e67c75 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
@@ -75,9 +75,11 @@ import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentEx
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
+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;
@@ -97,6 +99,7 @@ import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser;
@@ -1542,4 +1545,20 @@ public class ComponentsUtils {
return uiConstraintsMaps.stream().map(dataMap -> new com.fasterxml.jackson.databind.ObjectMapper().convertValue(dataMap, UIConstraint.class))
.collect(Collectors.toList());
}
+
+ public Map<String, DataTypeDefinition> getAllDataTypes(final ApplicationDataTypeCache applicationDataTypeCache, final String model) {
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(model);
+ if (allDataTypes.isRight()) {
+ final var operationStatus = allDataTypes.right().value();
+ if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
+ BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.DATA_TYPES_NOT_LOADED, model);
+ } else {
+ BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ }
+ return allDataTypes.left().value();
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
index 6d82e2b239..fec5dd8b7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
@@ -315,9 +315,10 @@ public class ComponentPropertyServlet extends BeGenericServlet {
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
return buildErrorResponse(responseFormat);
}
- //Validate value and Constraint of property
+ //Validate value and Constraint of property and Fetch all data types from cache
Either<Boolean, ResponseFormat> constraintValidatorResponse = PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(properties.values(), applicationDataTypeCache);
+ .validatePropertyConstraints(properties.values(), applicationDataTypeCache,
+ propertyBusinessLogic.getComponentModelByComponentId(componentId));
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return buildErrorResponse(constraintValidatorResponse.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index ac195f9315..9d3817431f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -120,7 +120,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Data types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
- public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @Parameter(description = "model") @QueryParam("model") String modelName) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
init();
@@ -128,7 +129,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
if (responseWrapper.isEmpty()) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {} - modifier id is {}", url, userId);
- Map<String, DataTypeDefinition> dataTypes = propertyBusinessLogic.getAllDataTypes();
+ final Map<String, DataTypeDefinition> dataTypes = resourceBusinessLogic.getComponentsUtils()
+ .getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), modelName);
String dataTypeJson = gson.toJson(dataTypes);
Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
responseWrapper.setInnerElement(okResponse);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
index 0b0ecd21d1..30420876b7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
@@ -66,17 +66,17 @@ public class GroupExportParserImpl implements GroupExportParser {
private static final Logger log = Logger.getLogger(GroupExportParserImpl.class);
private final PropertyConvertor propertyConvertor;
private Map<String, DataTypeDefinition> dataTypes;
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Autowired
- public GroupExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public GroupExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -86,7 +86,7 @@ public class GroupExportParserImpl implements GroupExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
index d544d34b66..7fe8e941a5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
@@ -52,19 +52,19 @@ import org.springframework.context.event.EventListener;
public class PolicyExportParserImpl implements PolicyExportParser {
private static final Logger log = Logger.getLogger(PolicyExportParserImpl.class);
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private Map<String, DataTypeDefinition> dataTypes;
private PropertyConvertor propertyConvertor;
@Autowired
- public PolicyExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public PolicyExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -74,7 +74,7 @@ public class PolicyExportParserImpl implements PolicyExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 3fe3bd5c42..ef5192c048 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -157,7 +157,7 @@ public class ToscaExportHandler {
.of("Service Function", "Service Role", "Naming Policy", "Service Type");
private static final YamlUtil yamlUtil = new YamlUtil();
private static final String COULD_NOT_PARSE_COMPONENT_ATTRIBUTES_COMPONENT_UNIQUE_ID = "Could not parse component '{}' attributes. Component unique id '{}'.";
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private ToscaOperationFacade toscaOperationFacade;
private CapabilityRequirementConverter capabilityRequirementConverter;
private PolicyExportParser policyExportParser;
@@ -170,7 +170,7 @@ public class ToscaExportHandler {
private InterfacesOperationsConverter interfacesOperationsConverter;
@Autowired
- public ToscaExportHandler(final ApplicationDataTypeCache dataTypeCache,
+ public ToscaExportHandler(final ApplicationDataTypeCache applicationDataTypeCache,
final ToscaOperationFacade toscaOperationFacade,
final CapabilityRequirementConverter capabilityRequirementConverter,
final PolicyExportParser policyExportParser,
@@ -181,7 +181,7 @@ public class ToscaExportHandler {
final OutputConverter outputConverter,
final InterfaceLifecycleOperation interfaceLifecycleOperation,
final InterfacesOperationsConverter interfacesOperationsConverter) {
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.toscaOperationFacade = toscaOperationFacade;
this.capabilityRequirementConverter = capabilityRequirementConverter;
this.policyExportParser = policyExportParser;
@@ -323,7 +323,7 @@ public class ToscaExportHandler {
if (MapUtils.isNotEmpty(proxyInterfaceTypes)) {
toscaNode.setInterface_types(proxyInterfaceTypes);
}
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -701,7 +701,7 @@ public class ToscaExportHandler {
List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream().map(InterfaceDataDefinition::getType)
.collect(Collectors.toList());
toscaNode.setInterface_types(addInterfaceTypeElement(component, allGlobalInterfaceTypes));
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to fetch all data types :", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -1182,7 +1182,7 @@ public class ToscaExportHandler {
String derivedFrom = ((Resource) origComponent).getToscaResourceName();
toscaNodeType.setDerived_from(derivedFrom);
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(origComponent.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
}