if (user == null) {
return;
}
try {
if (user.hasImageWithName(image)) {
error.fire(new ErrorEvent("Error", Constants.SAME_IMAGE_EXIST_ERROR));
imageAction.resetImage(image);
return;
}
if (editFromInplace) {
// We need validate image name manually
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Image>> constraintViolations = validator.validate(image);
if (constraintViolations.size() > 0) {
for (ConstraintViolation<Image> cv : constraintViolations) {
error.fire(new ErrorEvent("Constraint violation", cv.getMessage()));
}
// If error occurred we need refresh album to display correct value in inplaceInput
imageAction.resetImage(image);
return;
}
}
imageAction.editImage(image, !editFromInplace);
} catch (Exception e) {
error.fire(new ErrorEvent("Error", Constants.IMAGE_SAVING_ERROR + " <br/>" + e.getMessage()));
imageAction.resetImage(image);
return;
}
navEvent.fire(new NavEvent(NavigationEnum.ALBUM_IMAGE_PREVIEW));
}