Example usage for com.liferay.portal.util PrefsPropsUtil getInteger

List of usage examples for com.liferay.portal.util PrefsPropsUtil getInteger

Introduction

In this page you can find the example usage for com.liferay.portal.util PrefsPropsUtil getInteger.

Prototype

public static int getInteger(String name) 

Source Link

Usage

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  www  .ja  v a2 s  .c om

    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.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.java

License:Open Source License

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

    try {//from   ww 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);
    }
}