List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getInteger
public static int getInteger(String name)
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());/*from w ww .j ava2 s .c o m*/ }
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected boolean isThumbnailEnabled(int index) throws SystemException { if ((index == THUMBNAIL_INDEX_DEFAULT) && GetterUtil.getBoolean(PropsUtil.get(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_ENABLED))) { return true; } else if ((index == THUMBNAIL_INDEX_CUSTOM_1) && ((PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_HEIGHT) > 0) || (PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_WIDTH) > 0))) { return true; } else if ((index == THUMBNAIL_INDEX_CUSTOM_2) && ((PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_HEIGHT) > 0) || (PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_WIDTH) > 0))) { return true; }//from ww w. java 2 s . c o m return false; }
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;// w w w.j a v a2s.c om } 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); } }