Examples of ErrorEvent


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

                if (!resultCanonicalPath.startsWith(this.uploadRootPath)) {
                    result = null;
                }
                return result;
            } catch (IOException e) {
                error.fire(new ErrorEvent("no file found"));
                result = null;
            }
            return result;
        }
        return null;
View Full Code Here

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

        createDirectoryIfNotExist(avatarPath);
        try {
            InputStream is = new FileInputStream(avatarData);
            return writeFile(avatarPath, is, "", Constants.AVATAR_SIZE, true);
        } catch (IOException ioe) {
            error.fire(new ErrorEvent("error saving avatar"));
            return false;
        }
    }
View Full Code Here

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

                if (!writeFile(fileName, in, d.getFilePostfix(), d.getX(), true)) {
                    return false;
                }
                in.close();
            } catch (IOException ioe) {
                error.fire(new ErrorEvent("Error", "error saving image: " + ioe.getMessage()));
                return false;
            }
        }

        return true;
View Full Code Here

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

        }

        try {
            Files.createParentDirs(file2);
        } catch (IOException ioe) {
            error.fire(new ErrorEvent("Error moving file", ioe.getMessage()));
        }

        file.renameTo(file2);
    }
View Full Code Here

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

        String format = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(newFileName).split("/")[1];
        try {
            // Read file form disk
            bsrc = FileManipulation.bitmapToImage(inputStream, format);
        } catch (IOException e1) {
            error.fire(new ErrorEvent("Error", "error reading file<br/>" + e1.getMessage()));
            return false;
        }
        int resizedParam = bsrc.getWidth() > bsrc.getHeight() ? bsrc.getWidth() : bsrc.getHeight();
        double scale = (double) size / resizedParam;
        Double widthInDouble = ((Double) scale * bsrc.getWidth());
        int width = widthInDouble.intValue();
        Double heightInDouble = ((Double) scale * bsrc.getHeight());
        int height = heightInDouble.intValue();
        // Too small picture or original size
        if (width > bsrc.getWidth() || height > bsrc.getHeight() || size == 0) {
            width = bsrc.getWidth();
            height = bsrc.getHeight();
        }
        // scale image if need
        BufferedImage bdest = FileManipulation
            .getScaledInstance(bsrc, width, height, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
        // Determine new path of image file
        String dest = includeUploadRoot ? this.uploadRootPath + transformPath(newFileName, pattern) : transformPath(
            newFileName, pattern);
        try {
            // save to disk
            FileManipulation.imageToBitmap(bdest, dest, format);
        } catch (IOException ex) {
            error.fire(new ErrorEvent("Error", "error saving image to disc: " + ex.getMessage()));
            return false;
        }
        return true;
    }
View Full Code Here

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

        }
    }

    private void addError(Image image, String error) {
        String imageName = (image != null) ? image.getName() : "";
        this.error.fire(new ErrorEvent("(" + imageName + ") " + error));
    }
View Full Code Here

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

                new FacesMessage("", Constants.SHELF_MUST_BE_NOT_NULL_ERROR));
            return;
        }
        // Album name must be unique in shelf
        if (user.hasAlbumWithName(album)) {
            error.fire(new ErrorEvent("", Constants.SAME_ALBUM_EXIST_ERROR));
            return;
        }
        // All data is valid
        validationSuccess = true;
        try {
            // Save to DB
            album.setCreated(new Date());
            albumAction.addAlbum(album);
        } catch (Exception e) {
            error.fire(new ErrorEvent("Error", Constants.ALBUM_SAVING_ERROR + "<br/>" + e.getMessage()));
            return;
        }
        // Reset 'album' component in conversation scope

        albumEvent.select(new EventTypeQualifier(Events.ALBUM_ADDED_EVENT)).fire(new AlbumEvent(album));
View Full Code Here

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

                shelf = model.getSelectedShelf();
            } else if (user.getShelves().size() > 0) {
                shelf = user.getShelves().get(0);
            }
            if (shelf == null) {
                error.fire(new ErrorEvent("", Constants.NO_SHELF_ERROR));
                setErrorInCreate(true);
                return;
            }
        }
        album.setShelf(shelf);
View Full Code Here

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

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

        }
        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
TOP
Copyright © 2018 www.massapi.com. 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.