List of usage examples for com.liferay.portal.kernel.repository.model FileVersion getFileEntry
public FileEntry getFileEntry() throws PortalException;
From source file:com.liferay.adaptive.media.image.internal.processor.AMImageProcessorImpl.java
License:Open Source License
@Override public void process(FileVersion fileVersion, String configurationEntryUuid) { if (!_amImageValidator.isValid(fileVersion)) { return;/*ww w . j av a2 s. c om*/ } Optional<AMImageConfigurationEntry> amImageConfigurationEntryOptional = _amImageConfigurationHelper .getAMImageConfigurationEntry(fileVersion.getCompanyId(), configurationEntryUuid); if (!amImageConfigurationEntryOptional.isPresent()) { return; } AMImageConfigurationEntry amImageConfigurationEntry = amImageConfigurationEntryOptional.get(); AMImageEntry amImageEntry = _amImageEntryLocalService.fetchAMImageEntry(amImageConfigurationEntry.getUUID(), fileVersion.getFileVersionId()); try { FileEntry fileEntry = fileVersion.getFileEntry(); if ((amImageEntry != null) && !fileEntry.isCheckedOut()) { return; } if ((amImageEntry != null) && fileEntry.isCheckedOut()) { _amImageEntryLocalService.deleteAMImageEntry(amImageEntry.getAmImageEntryId()); } AMImageScaler amImageScaler = _amImageScalerTracker.getAMImageScaler(fileVersion.getMimeType()); if (amImageScaler == null) { return; } AMImageScaledImage amImageScaledImage = amImageScaler.scaleImage(fileVersion, amImageConfigurationEntry); try (InputStream inputStream = amImageScaledImage.getInputStream()) { _amImageEntryLocalService.addAMImageEntry(amImageConfigurationEntry, fileVersion, amImageScaledImage.getHeight(), amImageScaledImage.getWidth(), inputStream, amImageScaledImage.getSize()); } } catch (IOException | PortalException e) { throw new AMRuntimeException.IOException(e); } }
From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java
License:Open Source License
protected void notifySubscribers(long userId, FileVersion fileVersion, String entryURL, ServiceContext serviceContext) throws PortalException { if (!fileVersion.isApproved() || Validator.isNull(entryURL)) { return;//ww w . j a va 2 s . com } DLGroupServiceSettings dlGroupServiceSettings = DLGroupServiceSettings .getInstance(fileVersion.getGroupId()); boolean commandUpdate = false; if (serviceContext.isCommandUpdate() || Constants.CHECKIN.equals(serviceContext.getCommand())) { commandUpdate = true; } if (serviceContext.isCommandAdd() && dlGroupServiceSettings.isEmailFileEntryAddedEnabled()) { } else if (commandUpdate && dlGroupServiceSettings.isEmailFileEntryUpdatedEnabled()) { } else { return; } String entryTitle = fileVersion.getTitle(); String fromName = dlGroupServiceSettings.getEmailFromName(); String fromAddress = dlGroupServiceSettings.getEmailFromAddress(); LocalizedValuesMap subjectLocalizedValuesMap = null; LocalizedValuesMap bodyLocalizedValuesMap = null; if (commandUpdate) { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedBody(); } else { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedBody(); } FileEntry fileEntry = fileVersion.getFileEntry(); Folder folder = null; long folderId = fileEntry.getFolderId(); if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { folder = _dlAppLocalService.getFolder(folderId); } SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender( DLPermission.RESOURCE_NAME); DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel(); DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService .getDLFileEntryType(dlFileEntry.getFileEntryTypeId()); subscriptionSender.setClassPK(fileVersion.getFileEntryId()); subscriptionSender.setClassName(DLFileEntryConstants.getClassName()); subscriptionSender.setCompanyId(fileVersion.getCompanyId()); if (folder != null) { subscriptionSender.setContextAttribute("[$FOLDER_NAME$]", folder.getName(), true); } else { subscriptionSender.setLocalizedContextAttribute("[$FOLDER_NAME$]", new EscapableLocalizableFunction(locale -> LanguageUtil.get(locale, "home"))); } subscriptionSender.setContextAttributes("[$DOCUMENT_STATUS_BY_USER_NAME$]", fileVersion.getStatusByUserName(), "[$DOCUMENT_TITLE$]", entryTitle, "[$DOCUMENT_URL$]", entryURL); subscriptionSender.setContextCreatorUserPrefix("DOCUMENT"); subscriptionSender.setCreatorUserId(fileVersion.getUserId()); subscriptionSender.setCurrentUserId(userId); subscriptionSender.setEntryTitle(entryTitle); subscriptionSender.setEntryURL(entryURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap)); subscriptionSender.setLocalizedContextAttribute("[$DOCUMENT_TYPE$]", new EscapableLocalizableFunction(locale -> dlFileEntryType.getName(locale))); subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap)); subscriptionSender.setMailId("file_entry", fileVersion.getFileEntryId()); int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY; if (commandUpdate) { notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY; } subscriptionSender.setNotificationType(notificationType); String portletId = PortletProviderUtil.getPortletId(FileEntry.class.getName(), PortletProvider.Action.VIEW); subscriptionSender.setPortletId(portletId); subscriptionSender.setReplyToAddress(fromAddress); subscriptionSender.setScopeGroupId(fileVersion.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), fileVersion.getGroupId()); if (folder != null) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), folder.getFolderId()); for (Long ancestorFolderId : folder.getAncestorFolderIds()) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), ancestorFolderId); } } if (dlFileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT) { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), fileVersion.getGroupId()); } else { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), dlFileEntryType.getFileEntryTypeId()); } subscriptionSender.addPersistedSubscribers(DLFileEntry.class.getName(), fileEntry.getFileEntryId()); subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.document.library.web.asset.DLFileEntryAssetRendererFactory.java
License:Open Source License
@Override public AssetRenderer<FileEntry> getAssetRenderer(long classPK, int type) throws PortalException { FileEntry fileEntry = null;/*from ww w . j ava2 s .c o m*/ FileVersion fileVersion = null; try { fileEntry = _dlAppLocalService.getFileEntry(classPK); if (type == TYPE_LATEST) { fileVersion = fileEntry.getLatestFileVersion(); } else if (type == TYPE_LATEST_APPROVED) { fileVersion = fileEntry.getFileVersion(); } else { throw new IllegalArgumentException("Unknown asset renderer type " + type); } } catch (NoSuchFileEntryException nsfee) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsfee, nsfee); } fileVersion = _dlAppLocalService.getFileVersion(classPK); fileEntry = fileVersion.getFileEntry(); } DLFileEntryAssetRenderer dlFileEntryAssetRenderer = new DLFileEntryAssetRenderer(fileEntry, fileVersion, _dlFileEntryLocalService); dlFileEntryAssetRenderer.setAssetRendererType(type); return dlFileEntryAssetRenderer; }
From source file:com.liferay.document.library.web.internal.asset.DLFileEntryAssetRendererFactory.java
License:Open Source License
@Override public AssetRenderer<FileEntry> getAssetRenderer(long classPK, int type) throws PortalException { FileEntry fileEntry = null;//w w w .java 2 s .co m FileVersion fileVersion = null; try { fileEntry = _dlAppLocalService.getFileEntry(classPK); if (type == TYPE_LATEST) { fileVersion = fileEntry.getLatestFileVersion(); } else if (type == TYPE_LATEST_APPROVED) { fileVersion = fileEntry.getFileVersion(); } else { throw new IllegalArgumentException("Unknown asset renderer type " + type); } } catch (NoSuchFileEntryException nsfee) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsfee, nsfee); } fileVersion = _dlAppLocalService.getFileVersion(classPK); fileEntry = fileVersion.getFileEntry(); } DLFileEntryAssetRenderer dlFileEntryAssetRenderer = new DLFileEntryAssetRenderer(fileEntry, fileVersion, _dlFileEntryLocalService, _trashHelper); dlFileEntryAssetRenderer.setAssetRendererType(type); return dlFileEntryAssetRenderer; }
From source file:com.liferay.document.library.web.internal.display.context.DefaultDLViewFileVersionDisplayContext.java
License:Open Source License
private FileEntry _getFileEntry(FileVersion fileVersion) throws PortalException { if (fileVersion != null) { return fileVersion.getFileEntry(); }//from w w w. j av a2 s .c o m return null; }
From source file:com.liferay.document.library.web.internal.display.context.logic.UIItemsBuilder.java
License:Open Source License
private UIItemsBuilder(HttpServletRequest request, FileVersion fileVersion, FileShortcut fileShortcut, ResourceBundle resourceBundle) { try {/* ww w .j a va 2 s.c om*/ _request = request; _fileVersion = fileVersion; _fileShortcut = fileShortcut; _resourceBundle = resourceBundle; FileEntry fileEntry = null; if (fileVersion != null) { fileEntry = fileVersion.getFileEntry(); } _fileEntry = fileEntry; _folderId = BeanParamUtil.getLong(_fileEntry, request, "folderId"); _themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); _fileEntryDisplayContextHelper = new FileEntryDisplayContextHelper(_themeDisplay.getPermissionChecker(), _fileEntry); _fileVersionDisplayContextHelper = new FileVersionDisplayContextHelper(fileVersion); } catch (PortalException pe) { throw new SystemException("Unable to build UIItemsBuilder for " + fileVersion, pe); } }
From source file:com.liferay.notifications.hook.service.impl.DLAppHelperLocalServiceImpl.java
License:Open Source License
protected List<ObjectValuePair<String, Long>> getSubscribersOVPs(FileVersion latestFileVersion) throws PortalException, SystemException { List<ObjectValuePair<String, Long>> subscribersOVPs = new ArrayList<ObjectValuePair<String, Long>>(); subscribersOVPs.add(new ObjectValuePair<String, Long>(_FOLDER_CLASS_NAME, latestFileVersion.getGroupId())); List<Long> folderIds = new ArrayList<Long>(); FileEntry fileEntry = latestFileVersion.getFileEntry(); Folder folder = fileEntry.getFolder(); if (folder != null) { folderIds.add(folder.getFolderId()); folderIds.addAll(folder.getAncestorFolderIds()); }//from ww w. ja v a 2 s . c om for (long folderId : folderIds) { subscribersOVPs.add(new ObjectValuePair<String, Long>(_FOLDER_CLASS_NAME, folderId)); } return subscribersOVPs; }
From source file:com.liferay.portlet.documentlibrary.asset.DLFileEntryAssetRendererFactory.java
License:Open Source License
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException, SystemException { FileEntry fileEntry = null;//w w w.j a v a 2 s . c o m FileVersion fileVersion = null; if (type == TYPE_LATEST) { fileVersion = DLAppLocalServiceUtil.getFileVersion(classPK); fileEntry = fileVersion.getFileEntry(); } else { fileEntry = DLAppLocalServiceUtil.getFileEntry(classPK); fileVersion = fileEntry.getFileVersion(); } return new DLFileEntryAssetRenderer(fileEntry, fileVersion); }