Search in sources :

Example 11 with FileVersion

use of com.liferay.portal.kernel.repository.model.FileVersion in project liferay-ide by liferay.

the class DLPreviewableProcessor method importPreviewFromLAR.

protected void importPreviewFromLAR(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement, String binPathSuffix, String previewType, int fileIndex) throws Exception {
    FileVersion fileVersion = fileEntry.getFileVersion();
    String binPathSegment = null;
    if (fileIndex < 0) {
        binPathSegment = previewType;
    } else {
        binPathSegment = Integer.toString(fileIndex + 1);
    }
    StringBundler sb = new StringBundler(4);
    sb.append("bin-path-preview-");
    sb.append(binPathSegment);
    sb.append("-");
    sb.append(binPathSuffix);
    String binPathName = sb.toString();
    String binPath = fileEntryElement.attributeValue(binPathName);
    InputStream is = null;
    try {
        is = portletDataContext.getZipEntryAsInputStream(binPath);
        if (is == null) {
            return;
        }
        String previewFilePath = null;
        if (fileIndex < 0) {
            previewFilePath = getPreviewFilePath(fileVersion, previewType);
        } else {
            previewFilePath = getPreviewFilePath(fileVersion, fileIndex + 1);
        }
        addFileToStore(portletDataContext.getCompanyId(), PREVIEW_PATH, previewFilePath, is);
    } finally {
        StreamUtil.cleanUp(is);
    }
}
Also used : InputStream(java.io.InputStream) FileVersion(com.liferay.portal.kernel.repository.model.FileVersion) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

FileVersion (com.liferay.portal.kernel.repository.model.FileVersion)11 InputStream (java.io.InputStream)7 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)3 PortalException (com.liferay.portal.kernel.exception.PortalException)2 StringBundler (com.liferay.portal.kernel.util.StringBundler)2 NoSuchFileEntryException (com.liferay.portlet.documentlibrary.NoSuchFileEntryException)2 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)2 IOException (java.io.IOException)2 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)1 Range (com.liferay.portal.kernel.servlet.Range)1 ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)1 Image (com.liferay.portal.model.Image)1 PrincipalException (com.liferay.portal.security.auth.PrincipalException)1 NoSuchFolderException (com.liferay.portlet.documentlibrary.NoSuchFolderException)1 RenderedImage (java.awt.image.RenderedImage)1 File (java.io.File)1 Date (java.util.Date)1 PortletURL (javax.portlet.PortletURL)1