Package org.richfaces.photoalbum.model.event

Examples of org.richfaces.photoalbum.model.event.ErrorEvent


        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));
View Full Code Here


        }
        String pathToDelete = album.getPath();
        try {
            albumAction.deleteAlbum(album);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error", Constants.ALBUM_DELETING_ERROR + "<br/>" + e.getMessage()));
            return;
        }
        // Raise 'albumDeleted' event, parameter path - path of Directory to delete
        albumEvent.select(new EventTypeQualifier(Events.ALBUM_DELETED_EVENT)).fire(new AlbumEvent(album, pathToDelete));
    }
View Full Code Here

        Object dropValue = dropEvent.getDropValue();
        if (dragValue instanceof Image) {
            // If user drag image
            if (!((Album) dropValue).getOwner().getLogin().equals(user.getLogin())) {
                // Drag in the album, that not belongs to user
                error.fire(new ErrorEvent("", Constants.DND_PHOTO_ERROR));
                return;
            }
            handleImage((Image) dragValue, (Album) dropValue);
        } else if (dragValue instanceof Album) {
            // If user drag album
            if (!((Shelf) dropValue).getOwner().getLogin().equals(user.getLogin())) {
                // Drag in the shelf, that not belongs to user
                error.fire(new ErrorEvent("", Constants.DND_ALBUM_ERROR));
                return;
            }
            handleAlbum((Album) dragValue, (Shelf) dropValue);
        }
    }
View Full Code Here

        String pathOld = dragValue.getPath();
        dropValue.addAlbum(dragValue);
        try {
            albumAction.editAlbum(dragValue);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error:", Constants.ERROR_IN_DB + "<br/>" + e.getMessage()));
            return;
        }
        albumEvent.fire(new AlbumEvent(dragValue, pathOld));
        ApplicationUtils.addToRerender(Constants.TREE_ID);
    }
View Full Code Here

        String pathOld = dragValue.getFullPath();
        dropValue.addImage(dragValue);
        try {
            albumAction.editAlbum(dropValue);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error:", Constants.ERROR_IN_DB + "<br/>" + e.getMessage()));
            return;
        }
        imageEvent.fire(new ImageEvent(dragValue, pathOld));
        ApplicationUtils.addToRerender(Constants.TREE_ID);
    }
View Full Code Here

            try {
                albumAction.editAlbum(album);
                eventAction.editEvent(event);
            } catch (PhotoAlbumException e) {
                error.fire(new ErrorEvent("Error:", Constants.ERROR_IN_DB + ": " + e.getMessage()));
            }
            albumEvent.fire(new AlbumEvent(album, pathOld));
        }
    }
View Full Code Here

        }
        String pathToDelete = image.getFullPath();
        try {
            imageAction.deleteImage(image);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error", Constants.IMAGE_DELETING_ERROR + " <br/>" + e.getMessage()));
            return;
        }
        // Raise 'imageDeleted' event, parameter path - path of file to delete
        imageEvent.fire(new ImageEvent(image, pathToDelete));
    }
View Full Code Here

        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));
    }
View Full Code Here

    public void addComment(Image image) {
        if (user == null) {
            return;
        }
        if (null == user.getLogin()) {
            error.fire(new ErrorEvent(Constants.ADDING_COMMENT_ERROR));
            return;
        }
        if (message.trim().equals("")) {
            error.fire(new ErrorEvent(Constants.NULL_COMMENT_ERROR));
            return;
        }
        Comment comment = new Comment();
        comment.setAuthor(user);
        comment.setImage(image);
        comment.setDate(new Date());
        comment.setMessage(message);
        try {
            imageAction.addComment(comment);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error", Constants.SAVE_COMMENT_ERROR + " <br/>" + e.getMessage()));
            return;
        }
        message = "";
    }
View Full Code Here

            return;
        }
        try {
            imageAction.deleteComment(comment);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error", Constants.DELETE_COMMENT_ERROR + " <br/>" + e.getMessage()));
            return;
        }
    }
View Full Code Here

TOP

Related Classes of org.richfaces.photoalbum.model.event.ErrorEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.