use of alien4cloud.paas.exception.NotSupportedException in project alien4cloud by alien4cloud.
the class FunctionEvaluator method getPropertyValue.
private static AbstractPropertyValue getPropertyValue(Map<String, AbstractPropertyValue> properties, Map<String, PropertyDefinition> propertyDefinitions, String propertyAccessPath) {
if (properties == null || !properties.containsKey(propertyAccessPath)) {
String propertyName = PropertyUtil.getPropertyNameFromComplexPath(propertyAccessPath);
if (propertyName == null) {
// Non complex
return PropertyUtil.getDefaultFromPropertyDefinitions(propertyAccessPath, propertyDefinitions);
} else {
// Complex
PropertyDefinition propertyDefinition = propertyDefinitions.get(propertyName);
AbstractPropertyValue rawValue;
if (propertyDefinition == null) {
return null;
} else if (ToscaTypes.isSimple(propertyDefinition.getType())) {
// It's a complex path (with '.') but the type in definition is finally simple
return null;
} else if (properties != null && (rawValue = properties.get(propertyName)) != null) {
if (!(rawValue instanceof PropertyValue)) {
throw new NotSupportedException("Only support static value in a get_property");
}
Object value = MapUtil.get(((PropertyValue) rawValue).getValue(), propertyAccessPath.substring(propertyName.length() + 1));
return new ScalarPropertyValue(PropertyUtil.serializePropertyValue(value));
} else {
return null;
}
}
} else {
return properties.get(propertyAccessPath);
}
}
Aggregations