Search in sources :

Example 1 with ImageImpl

use of com.liferay.portal.model.impl.ImageImpl in project liferay-ide by liferay.

the class WebServerServlet method convertFileEntry.

protected Image convertFileEntry(boolean smallImage, FileEntry fileEntry) throws PortalException, SystemException {
    try {
        Image image = new ImageImpl();
        image.setModifiedDate(fileEntry.getModifiedDate());
        InputStream is = null;
        if (smallImage) {
            is = ImageProcessorUtil.getThumbnailAsStream(fileEntry.getFileVersion(), ImageProcessorImpl.THUMBNAIL_INDEX_DEFAULT);
        } else {
            is = fileEntry.getContentStream();
        }
        byte[] bytes = FileUtil.getBytes(is);
        image.setTextObj(bytes);
        image.setType(fileEntry.getExtension());
        return image;
    } catch (PortalException pe) {
        throw pe;
    } catch (SystemException se) {
        throw se;
    } catch (Exception e) {
        throw new SystemException(e);
    }
}
Also used : SystemException(com.liferay.portal.kernel.exception.SystemException) InputStream(java.io.InputStream) PortalException(com.liferay.portal.kernel.exception.PortalException) Image(com.liferay.portal.model.Image) RenderedImage(java.awt.image.RenderedImage) ImageImpl(com.liferay.portal.model.impl.ImageImpl) ServletException(javax.servlet.ServletException) RepositoryException(com.liferay.portal.kernel.repository.RepositoryException) NoSuchFileEntryException(com.liferay.portlet.documentlibrary.NoSuchFileEntryException) NoSuchFolderException(com.liferay.portlet.documentlibrary.NoSuchFolderException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) IOException(java.io.IOException) NoSuchGroupException(com.liferay.portal.NoSuchGroupException)

Aggregations

NoSuchGroupException (com.liferay.portal.NoSuchGroupException)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)1 Image (com.liferay.portal.model.Image)1 ImageImpl (com.liferay.portal.model.impl.ImageImpl)1 PrincipalException (com.liferay.portal.security.auth.PrincipalException)1 NoSuchFileEntryException (com.liferay.portlet.documentlibrary.NoSuchFileEntryException)1 NoSuchFolderException (com.liferay.portlet.documentlibrary.NoSuchFolderException)1 RenderedImage (java.awt.image.RenderedImage)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ServletException (javax.servlet.ServletException)1