use of org.apache.ofbiz.minilang.MiniLangRuntimeException in project ofbiz-framework by apache.
the class PropertyToField method exec.
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
String resource = resourceFse.expandString(methodContext.getEnvMap());
String property = propertyFse.expandString(methodContext.getEnvMap());
String value = null;
if (noLocale) {
value = EntityUtilProperties.getPropertyValue(resource, property, methodContext.getDelegator());
} else {
value = EntityUtilProperties.getMessage(resource, property, methodContext.getLocale(), methodContext.getDelegator());
}
value = FlexibleStringExpander.expandString(value, methodContext.getEnvMap());
if (value.isEmpty()) {
value = defaultFse.expandString(methodContext.getEnvMap());
}
List<? extends Object> argList = argListFma.get(methodContext.getEnvMap());
if (argList != null) {
try {
value = MessageFormat.format(value, argList.toArray());
} catch (IllegalArgumentException e) {
throw new MiniLangRuntimeException("Exception thrown while formatting the property value: " + e.getMessage(), this);
}
}
fieldFma.put(methodContext.getEnvMap(), value);
return true;
}
Aggregations