Example usage for com.liferay.portal.util PropsValues DL_FILE_ENTRY_THUMBNAIL_ENABLED

List of usage examples for com.liferay.portal.util PropsValues DL_FILE_ENTRY_THUMBNAIL_ENABLED

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues DL_FILE_ENTRY_THUMBNAIL_ENABLED.

Prototype

boolean DL_FILE_ENTRY_THUMBNAIL_ENABLED

To view the source code for com.liferay.portal.util PropsValues DL_FILE_ENTRY_THUMBNAIL_ENABLED.

Click Source Link

Usage

From source file:com.liferay.portlet.documentlibrary.util.DLImpl.java

License:Open Source License

@Override
public String getImagePreviewURL(FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay)
        throws Exception {

    String previewQueryString = null;

    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        if (ImageProcessorUtil.hasImages(fileVersion)) {
            previewQueryString = "&imagePreview=1";
        } else if (PDFProcessorUtil.hasImages(fileVersion)) {
            previewQueryString = "&previewFileIndex=1";
        } else if (VideoProcessorUtil.hasVideo(fileVersion)) {
            previewQueryString = "&videoThumbnail=1";
        }//from w  w w.j  a v a 2 s . c  om
    }

    return getImageSrc(fileEntry, fileVersion, themeDisplay, previewQueryString);
}

From source file:com.liferay.portlet.documentlibrary.util.DLImpl.java

License:Open Source License

@Override
public String getThumbnailSrc(FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay)
        throws Exception {

    String thumbnailQueryString = null;

    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        if (ImageProcessorUtil.hasImages(fileVersion)) {
            thumbnailQueryString = "&imageThumbnail=1";
        } else if (PDFProcessorUtil.hasImages(fileVersion)) {
            thumbnailQueryString = "&documentThumbnail=1";
        } else if (VideoProcessorUtil.hasVideo(fileVersion)) {
            thumbnailQueryString = "&videoThumbnail=1";
        }/*from   w w w . j  a  v a  2 s. c o m*/
    }

    return getImageSrc(fileEntry, fileVersion, themeDisplay, thumbnailQueryString);
}

From source file:com.liferay.portlet.documentlibrary.util.ImageProcessorImpl.java

License:Open Source License

public boolean hasImages(FileVersion fileVersion) {
    if (!PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        return false;
    }/*  w w  w.ja va2 s  .  c  o  m*/

    boolean hasImages = false;

    try {
        hasImages = _instance._hasImages(fileVersion);

        if (!hasImages && _instance.isSupported(fileVersion)) {
            _instance._queueGeneration(fileVersion);
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    return hasImages;
}

From source file:com.liferay.portlet.documentlibrary.util.ImageProcessorImpl.java

License:Open Source License

private void _generateImages(FileVersion fileVersion) {
    try {//ww  w  . j  av  a 2s.  c o m
        if (!PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
            return;
        }

        InputStream inputStream = fileVersion.getContentStream(false);

        byte[] bytes = FileUtil.getBytes(inputStream);

        ImageBag imageBag = ImageToolUtil.read(bytes);

        RenderedImage renderedImage = imageBag.getRenderedImage();

        if (renderedImage == null) {
            return;
        }

        storeThumbnailImages(fileVersion, renderedImage);
    } catch (NoSuchFileEntryException nsfee) {
    } catch (Exception e) {
        _log.error(e, e);
    } finally {
        _fileVersionIds.remove(fileVersion.getFileVersionId());
    }
}

From source file:com.liferay.portlet.documentlibrary.util.ImageProcessorImpl.java

License:Open Source License

private boolean _hasImages(FileVersion fileVersion) {
    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_DEFAULT)) {
            return false;
        }/*from w  w w  .  ja va  2 s . c o  m*/
    }

    try {
        if (isCustomThumbnailsEnabled(1)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_1)) {
                return false;
            }
        }

        if (isCustomThumbnailsEnabled(2)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_2)) {
                return false;
            }
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    return true;
}

From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java

License:Open Source License

private boolean _hasImages(FileVersion fileVersion) throws Exception {
    if (PropsValues.DL_FILE_ENTRY_PREVIEW_ENABLED) {
        if (!DLStoreUtil.hasFile(fileVersion.getCompanyId(), REPOSITORY_ID,
                getPreviewFilePath(fileVersion, 1))) {

            return false;
        }/*from   w  w w  .j ava  2  s .c o m*/
    }

    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_DEFAULT)) {
            return false;
        }
    }

    try {
        if (isCustomThumbnailsEnabled(1)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_1)) {
                return false;
            }
        }

        if (isCustomThumbnailsEnabled(2)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_2)) {
                return false;
            }
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    return true;
}

From source file:com.liferay.portlet.documentlibrary.util.PDFProcessorImpl.java

License:Open Source License

private boolean _isGenerateThumbnail(FileVersion fileVersion) throws Exception {

    String thumbnailFilePath = getThumbnailFilePath(fileVersion, THUMBNAIL_INDEX_DEFAULT);

    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED
            && !DLStoreUtil.hasFile(fileVersion.getCompanyId(), REPOSITORY_ID, thumbnailFilePath)) {

        return true;
    } else {//from w  w  w  . j ava 2 s  . com
        return false;
    }
}

From source file:com.liferay.portlet.documentlibrary.util.VideoProcessorImpl.java

License:Open Source License

private boolean _hasVideo(FileVersion fileVersion) throws Exception {
    if (!isSupported(fileVersion)) {
        return false;
    }//from  www  . j  av  a2  s.  c  om

    int previewsCount = 0;

    for (int i = 0; i < _PREVIEW_TYPES.length; i++) {
        String previewFilePath = getPreviewFilePath(fileVersion, _PREVIEW_TYPES[i]);

        if (DLStoreUtil.hasFile(fileVersion.getCompanyId(), REPOSITORY_ID, previewFilePath)) {

            previewsCount++;
        }
    }

    if (previewsCount != _PREVIEW_TYPES.length) {
        return false;
    }

    if (PropsValues.DL_FILE_ENTRY_THUMBNAIL_ENABLED) {
        if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_DEFAULT)) {
            return false;
        }
    }

    try {
        if (isCustomThumbnailsEnabled(1)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_1)) {
                return false;
            }
        }

        if (isCustomThumbnailsEnabled(2)) {
            if (!hasThumbnail(fileVersion, THUMBNAIL_INDEX_CUSTOM_2)) {
                return false;
            }
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    return true;
}