if (user == null) {
return;
}
try {
if (user.hasAlbumWithName(album)) {
error.fire(new ErrorEvent("", Constants.SAME_ALBUM_EXIST_ERROR));
albumAction.resetAlbum(album);
return;
}
if (editFromInplace) {
// We need validate album name manually
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Album>> constraintViolations = validator.validate(album);
if (constraintViolations.size() > 0) {
for (ConstraintViolation<Album> cv : constraintViolations) {
error.fire(new ErrorEvent("Constraint violation", cv.getMessage()));
}
// If error occured we need refresh album to display correct value in inplaceInput
albumAction.resetAlbum(album);
return;
}
}
albumAction.editAlbum(album);
} catch (Exception e) {
error.fire(new ErrorEvent("Error", Constants.ALBUM_SAVING_ERROR + "<br/>" + e.getMessage()));
albumAction.resetAlbum(album);
return;
}
// Reset 'album' component in conversation scope
albumEvent.select(new EventTypeQualifier(Events.ALBUM_EDITED_EVENT)).fire(new AlbumEvent(album));