Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.FileContent


        roller/testdata/roller-custom.properties */
        FileContentManager fmgr = WebloggerFactory.getWeblogger().getFileContentManager();

        // File should not exist initially
        try {
            FileContent fileContent = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
            assertTrue("Non-existant file retrieved without any exception", false);
        } catch (FileNotFoundException e) {
            assertTrue("Exception thrown for non-existant file as expected", true);
        }

        // store a file
        InputStream is = getClass().getResourceAsStream("/bookmarks.opml");
        fmgr.saveFileContent(testWeblog, "bookmarks-file-id", is);

        // make sure file was stored successfully
        FileContent fileContent1 = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
        assertEquals("bookmarks-file-id", fileContent1.getFileId());


        // delete file
        fmgr.deleteFile(testWeblog, "bookmarks-file-id");

        // File should not exist after delete
        try {
            FileContent fileContent = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
            assertTrue("Non-existant file retrieved without any exception", false);
        } catch (FileNotFoundException e) {
            assertTrue("Exception thrown for non-existant file as expected", true);
        }

View Full Code Here


            throw new FilePathException("Invalid file id ["+fileId+"], "+
                    "path is a directory.");
        }
       
        // everything looks good, return resource
        return new FileContent(weblog, fileId, resourceFile);
    }
View Full Code Here

    }

    private void updateThumbnail(MediaFile mediaFile) {
        try {
            FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();
            FileContent fc = cmgr.getFileContent(mediaFile.getWeblog(), mediaFile.getId());
            BufferedImage img = null;

            img = ImageIO.read(fc.getInputStream());

            // determine and save width and height
            mediaFile.setWidth(img.getWidth());
            mediaFile.setHeight(img.getHeight());
            strategy.store(mediaFile);
View Full Code Here

    public MediaFile getMediaFile(String id, boolean includeContent) throws WebloggerException {
        MediaFile mediaFile = (MediaFile) this.strategy.load(MediaFile.class, id);
        if (includeContent) {
            FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();

            FileContent content = cmgr.getFileContent(mediaFile.getDirectory().getWeblog(), id);
            mediaFile.setContent(content);

            try {
                FileContent thumbnail = cmgr.getFileContent(mediaFile.getDirectory().getWeblog(), id + "_sm");
                mediaFile.setThumbnailContent(thumbnail);

            } catch (Exception e) {
                if (log.isDebugEnabled()) {
                    log.debug("Cannot load thumbnail for image " + id, e);
View Full Code Here

            mf = (MediaFile) q.getSingleResult();
        } catch (NoResultException e) {
            return null;
        }
        FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();
        FileContent content = cmgr.getFileContent(mf.getDirectory().getWeblog(), mf.getId());
        mf.setContent(content);
        return mf;
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.FileContent

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.