if (user == null) {
return;
}
try {
if (user.hasShelfWithName(shelf)) {
error.fire(new ErrorEvent(Constants.SAME_SHELF_EXIST_ERROR));
shelfAction.resetShelf(shelf);
return;
}
if (editFromInplace) {
// We need validate shelf name manually
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Shelf>> constraintViolations = validator.validate(shelf);
if (constraintViolations.size() > 0) {
for (ConstraintViolation<Shelf> cv : constraintViolations) {
error.fire(new ErrorEvent("Constraint violation", cv.getMessage()));
}
// If error occured we need refresh album to display correct value in inplaceInput
shelfAction.resetShelf(shelf);
return;
}
}
shelfAction.editShelf(shelf);
} catch (Exception e) {
error.fire(new ErrorEvent("Error", Constants.SHELF_SAVING_ERROR + " <br/>" + e.getMessage()));
shelfAction.resetShelf(shelf);
return;
}
shelfEvent.select(new EventTypeQualifier(Events.SHELF_EDITED_EVENT)).fire(new ShelfEvent(shelf));
}