Example usage for com.liferay.portal.kernel.util PropsKeys DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT

List of usage examples for com.liferay.portal.kernel.util PropsKeys DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT.

Prototype

String DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT

To view the source code for com.liferay.portal.kernel.util PropsKeys DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT.

Click Source Link

Usage

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.osgi.commands.AMThumbnailsOSGiCommands.java

License:Open Source License

private ThumbnailConfiguration[] _getThumbnailConfigurations() {
    return new ThumbnailConfiguration[] {
            new ThumbnailConfiguration(PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH),
                    PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT),
                    Pattern.compile(
                            DLPreviewableProcessor.THUMBNAIL_PATH + "\\d+/\\d+(?:/\\d+)+/(\\d+)(?:\\..+)?$")),
            new ThumbnailConfiguration(
                    PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_WIDTH),
                    PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_HEIGHT),
                    Pattern.compile(
                            DLPreviewableProcessor.THUMBNAIL_PATH + "\\d+/\\d+(?:/\\d+)+/(\\d+)-1(?:\\..+)?$")),
            new ThumbnailConfiguration(
                    PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_WIDTH),
                    PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_HEIGHT),
                    Pattern.compile(DLPreviewableProcessor.THUMBNAIL_PATH
                            + "\\d+/\\d+(?:/\\d+)+/(\\d+)-2(?:\\..+)?$")) };
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.processor.AMImageEntryProcessor.java

License:Open Source License

private Stream<AdaptiveMedia<AMImageProcessor>> _getThumbnailAdaptiveMedia(FileVersion fileVersion)
        throws PortalException {

    return _amImageFinder
            .getAdaptiveMediaStream(amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(fileVersion)
                    .with(AMImageAttribute.AM_IMAGE_ATTRIBUTE_WIDTH,
                            PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH))
                    .with(AMImageAttribute.AM_IMAGE_ATTRIBUTE_HEIGHT,
                            PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT))
                    .done());//w  ww  . j  a  v a2s . c o m
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.util.AMCompanyThumbnailConfigurationInitializer.java

License:Open Source License

public void initializeCompany(Company company) throws AMImageConfigurationException, IOException {

    int dlFileEntryThumbnailMaxHeight = PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT);
    int dlFileEntryThumbnailMaxWidth = PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH);

    if ((dlFileEntryThumbnailMaxHeight > 0) && (dlFileEntryThumbnailMaxWidth > 0)) {

        _createAMDocumentLibraryThumbnailConfiguration(company, dlFileEntryThumbnailMaxHeight,
                dlFileEntryThumbnailMaxWidth);
    }//from  w w w . j a v a2 s .com

    int dlFileEntryThumbnailCustom1MaxHeight = PrefsPropsUtil
            .getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_HEIGHT);
    int dlFileEntryThumbnailCustom1MaxWidth = PrefsPropsUtil
            .getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_WIDTH);

    if ((dlFileEntryThumbnailCustom1MaxHeight > 0) && (dlFileEntryThumbnailCustom1MaxWidth > 0)) {

        _createAMDocumentLibraryThumbnailConfiguration(company, dlFileEntryThumbnailCustom1MaxHeight,
                dlFileEntryThumbnailCustom1MaxWidth);
    }

    int dlFileEntryThumbnailCustom2MaxHeight = PrefsPropsUtil
            .getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_HEIGHT);
    int dlFileEntryThumbnailCustom2MaxWidth = PrefsPropsUtil
            .getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_WIDTH);

    if ((dlFileEntryThumbnailCustom2MaxHeight > 0) && (dlFileEntryThumbnailCustom2MaxWidth > 0)) {

        _createAMDocumentLibraryThumbnailConfiguration(company, dlFileEntryThumbnailCustom2MaxHeight,
                dlFileEntryThumbnailCustom2MaxWidth);
    }
}

From source file:com.liferay.portlet.admin.action.EditServerAction.java

License:Open Source License

protected void updateFileUploads(ActionRequest actionRequest, PortletPreferences preferences) throws Exception {

    long dlFileEntryThumbnailMaxHeight = ParamUtil.getLong(actionRequest, "dlFileEntryThumbnailMaxHeight");
    long dlFileEntryThumbnailMaxWidth = ParamUtil.getLong(actionRequest, "dlFileEntryThumbnailMaxWidth");
    String dlFileExtensions = getFileExtensions(actionRequest, "dlFileExtensions");
    long dlFileMaxSize = ParamUtil.getLong(actionRequest, "dlFileMaxSize");
    String journalImageExtensions = getFileExtensions(actionRequest, "journalImageExtensions");
    long journalImageSmallMaxSize = ParamUtil.getLong(actionRequest, "journalImageSmallMaxSize");
    String shoppingImageExtensions = getFileExtensions(actionRequest, "shoppingImageExtensions");
    long scImageMaxSize = ParamUtil.getLong(actionRequest, "scImageMaxSize");
    long scImageThumbnailMaxHeight = ParamUtil.getLong(actionRequest, "scImageThumbnailMaxHeight");
    long scImageThumbnailMaxWidth = ParamUtil.getLong(actionRequest, "scImageThumbnailMaxWidth");
    long shoppingImageLargeMaxSize = ParamUtil.getLong(actionRequest, "shoppingImageLargeMaxSize");
    long shoppingImageMediumMaxSize = ParamUtil.getLong(actionRequest, "shoppingImageMediumMaxSize");
    long shoppingImageSmallMaxSize = ParamUtil.getLong(actionRequest, "shoppingImageSmallMaxSize");
    long uploadServletRequestImplMaxSize = ParamUtil.getLong(actionRequest, "uploadServletRequestImplMaxSize");
    String uploadServletRequestImplTempDir = ParamUtil.getString(actionRequest,
            "uploadServletRequestImplTempDir");
    long usersImageMaxSize = ParamUtil.getLong(actionRequest, "usersImageMaxSize");

    preferences.setValue(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT,
            String.valueOf(dlFileEntryThumbnailMaxHeight));
    preferences.setValue(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH,
            String.valueOf(dlFileEntryThumbnailMaxWidth));
    preferences.setValue(PropsKeys.DL_FILE_EXTENSIONS, dlFileExtensions);
    preferences.setValue(PropsKeys.DL_FILE_MAX_SIZE, String.valueOf(dlFileMaxSize));
    preferences.setValue(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, journalImageExtensions);
    preferences.setValue(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE, String.valueOf(journalImageSmallMaxSize));
    preferences.setValue(PropsKeys.SHOPPING_IMAGE_EXTENSIONS, shoppingImageExtensions);
    preferences.setValue(PropsKeys.SHOPPING_IMAGE_LARGE_MAX_SIZE, String.valueOf(shoppingImageLargeMaxSize));
    preferences.setValue(PropsKeys.SHOPPING_IMAGE_MEDIUM_MAX_SIZE, String.valueOf(shoppingImageMediumMaxSize));
    preferences.setValue(PropsKeys.SHOPPING_IMAGE_SMALL_MAX_SIZE, String.valueOf(shoppingImageSmallMaxSize));
    preferences.setValue(PropsKeys.SC_IMAGE_MAX_SIZE, String.valueOf(scImageMaxSize));
    preferences.setValue(PropsKeys.SC_IMAGE_THUMBNAIL_MAX_HEIGHT, String.valueOf(scImageThumbnailMaxHeight));
    preferences.setValue(PropsKeys.SC_IMAGE_THUMBNAIL_MAX_WIDTH, String.valueOf(scImageThumbnailMaxWidth));
    preferences.setValue(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE,
            String.valueOf(uploadServletRequestImplMaxSize));

    if (Validator.isNotNull(uploadServletRequestImplTempDir)) {
        preferences.setValue(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_TEMP_DIR, uploadServletRequestImplTempDir);

        UploadServletRequestImpl.setTempDir(new File(uploadServletRequestImplTempDir));
    }//from   w  w w .  j  av  a  2s . c  om

    preferences.setValue(PropsKeys.USERS_IMAGE_MAX_SIZE, String.valueOf(usersImageMaxSize));

    preferences.store();
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.java

License:Open Source License

public void updateSmallImage(long smallImageId, long largeImageId) throws PortalException, SystemException {

    try {/*from  w w w.j  a va  2 s . c om*/
        RenderedImage renderedImage = null;

        Image largeImage = imageLocalService.getImage(largeImageId);

        byte[] bytes = largeImage.getTextObj();
        String contentType = largeImage.getType();

        if (bytes != null) {
            ImageBag imageBag = ImageToolUtil.read(bytes);

            renderedImage = imageBag.getRenderedImage();

            //validate(bytes);
        }

        if (renderedImage != null) {
            int height = PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT);
            int width = PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH);

            RenderedImage thumbnailRenderedImage = ImageToolUtil.scale(renderedImage, height, width);

            imageLocalService.updateImage(smallImageId,
                    ImageToolUtil.getBytes(thumbnailRenderedImage, contentType));
        }
    } catch (IOException ioe) {
        throw new ImageSizeException(ioe);
    }
}

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

License:Open Source License

@Override
public String getThumbnailStyle(boolean max, int margin) throws Exception {
    StringBundler sb = new StringBundler(5);

    if (max) {//from www .  jav  a 2  s.  co m
        sb.append("max-height: ");
    } else {
        sb.append("height: ");
    }

    sb.append(PrefsPropsUtil.getLong(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT) + 2 * margin);

    if (max) {
        sb.append("px; max-width: ");
    } else {
        sb.append("px; width: ");
    }

    sb.append(PrefsPropsUtil.getLong(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH) + 2 * margin);
    sb.append("px;");

    return sb.toString();
}

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

License:Open Source License

protected void storeThumbnailImage(FileVersion fileVersion, RenderedImage renderedImage, int index)
        throws Exception {

    if (!isThumbnailEnabled(index) || hasThumbnail(fileVersion, index)) {
        return;//from w w w  .j ava 2s .c o  m
    }

    String type = getThumbnailType(fileVersion);

    String maxHeightPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_HEIGHT;
    String maxWidthPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_MAX_WIDTH;

    if (index == THUMBNAIL_INDEX_CUSTOM_1) {
        maxHeightPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_HEIGHT;
        maxWidthPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_WIDTH;
    } else if (index == THUMBNAIL_INDEX_CUSTOM_2) {
        maxHeightPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_HEIGHT;
        maxWidthPropsKey = PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_WIDTH;
    }

    RenderedImage thumbnailRenderedImage = ImageToolUtil.scale(renderedImage,
            PrefsPropsUtil.getInteger(maxHeightPropsKey), PrefsPropsUtil.getInteger(maxWidthPropsKey));

    byte[] bytes = ImageToolUtil.getBytes(thumbnailRenderedImage, type);

    File file = null;

    try {
        file = FileUtil.createTempFile(bytes);

        addFileToStore(fileVersion.getCompanyId(), THUMBNAIL_PATH,
                getThumbnailFilePath(fileVersion, type, index), file);
    } finally {
        FileUtil.delete(file);
    }
}