if (wre.getCause() == null || !(wre.getCause() instanceof FileUploadException))
{
throw wre;
}
FileUploadException e = (FileUploadException)wre.getCause();
// Create model with exception and maximum size values
final Map<String, Object> model = new HashMap<String, Object>();
model.put("exception", e);
model.put("maxSize", getMaxSize());
if (e instanceof SizeLimitExceededException)
{
// Resource key should be <form-id>.uploadTooLarge to
// override default message
final String defaultValue = "Upload must be less than " + getMaxSize();
String msg = getString(getId() + "." + UPLOAD_TOO_LARGE_RESOURCE_KEY,
Model.of(model), defaultValue);
error(msg);
}
else
{
// Resource key should be <form-id>.uploadFailed to override
// default message
final String defaultValue = "Upload failed: " + e.getLocalizedMessage();
String msg = getString(getId() + "." + UPLOAD_FAILED_RESOURCE_KEY,
Model.of(model), defaultValue);
error(msg);
log.warn(msg, e);