Package org.richfaces.photoalbum.model

Examples of org.richfaces.photoalbum.model.Image


     *
     * @param comment - comment to add
     * @throws PhotoAlbumException
     */
    public void addComment(Comment comment) throws PhotoAlbumException {
        Image image = comment.getImage();
        if (!image.isAllowComments()) {
            throw new PhotoAlbumException("Cannot add comments to this image");
        }
        try {
            image.addComment(comment);
            em.persist(comment);
            em.flush();
        } catch (Exception e) {
            throw new PhotoAlbumException(e.getMessage());
        }
View Full Code Here


    public void renameImageFile(@Observes @EventType(Events.IMAGE_DRAGGED_EVENT) ImageEvent ie) {
        File file = null;
        File file2 = null;

        String pathOld = ie.getPath();
        Image image = ie.getImage();
        for (ImageDimension dimension : ImageDimension.values()) {
            file = getFileByPath(transformPath(pathOld, dimension.getFilePostfix()));
            file2 = getFileByPath(transformPath(image.getFullPath(), dimension.getFilePostfix()));
            if (file2.exists()) {
                if (file2.isDirectory()) {
                    FileManipulation.deleteDirectory(file2, false);
                } else {
                    FileManipulation.deleteFile(file2);
View Full Code Here

        // Construct image from item
        uploadFile(new FileHandler(file), model.getSelectedAlbum());
    }

    public void uploadFile(FileHandler fileHandler, Album album) {
        Image image = constructImage(fileHandler);
        try {
            // Extract metadata(size, camera model etc..)
            extractMetadata(fileHandler, image);
        } catch (Exception e1) {
            addError(fileHandler, image, Constants.FILE_PROCESSING_ERROR);
            return;
        }

        image.setAlbum(album);
        if (image.getAlbum() == null) {
            addError(fileHandler, image, Constants.NO_ALBUM_TO_DOWNLOAD_ERROR);
            return;
        }
        try {
            // Check if image with given name already exist
            if (imageAction.isImageWithThisPathExist(image.getAlbum(), image.getPath())) {
                // If exist generate new path for image
                String newPath = generateNewPath(image);
                image.setPath(newPath);
                image.setName(newPath);
            }
            // Save to database
            imageAction.addImage(image);
        } catch (Exception e) {
            addError(fileHandler, image, Constants.IMAGE_SAVING_ERROR);
            return;
        }
        try {
            // Save to disk
            if (!fileManager.addImage(image.getFullPath(), fileHandler)) {
                addError(fileHandler, image, Constants.FILE_SAVE_ERROR);
                return;
            }
        } catch (IOException ioe) {
            log.log(Level.INFO, "error", ioe);
View Full Code Here

    private Image constructImage(FileHandler fileHandler) {
        long size = fileHandler.getSize();
        String name = fileHandler.getName();

        Image image = new Image();
        image.setUploaded(new Date());
        image.setDescription(name);
        image.setName(name);
        image.setSize(size);
        image.setPath(name);
        image.setAllowComments(true);
        return image;
    }
View Full Code Here

    private void checkIsFileRecentlyDeleted() {
        if (!selectedImage.isLocalImage()) {
            return;
        }

        Image image = (Image) selectedImage.getImage();

        if (!fileManager.isFilePresent(image.getFullPath())) {
            error.fire(new ErrorEvent(Constants.IMAGE_RECENTLY_DELETED_ERROR));
            active = false;
            errorDetected = true;
            ApplicationUtils.addToRerender(Constants.MAINAREA_ID);
            model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(), image.getAlbum().getShelf(),
                image.getAlbum(), null, image.getAlbum().getImages());
            return;
        }
    }
View Full Code Here

     * @param out - OutputStream to write image
     * @param data - relative path of the image
     */
    public void paintImage(OutputStream out, Object data) throws IOException {
        Long id = Long.valueOf(data.toString());
        Image im = em.find(Image.class, id);
        if (isImageRecentlyRemoved(im)) {
            imageLoader.paintImage(out, Constants.DEFAULT_PICTURE);
            return;
        }
        if (isImageSharedOrBelongsToUser(im)) {
            imageLoader.paintImage(out, im.getFullPath());
        } else {
            return;
        }
    }
View Full Code Here

TOP

Related Classes of org.richfaces.photoalbum.model.Image

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.