List of usage examples for com.liferay.portal.kernel.repository.model FileVersion getGroupId
@Override
public long getGroupId();
From source file:com.liferay.adaptive.media.image.internal.storage.ImageStorage.java
License:Open Source License
protected String getFileVersionPath(FileVersion fileVersion, String configurationUuid) { return String.format("adaptive/%s/%d/%d/%d/%d/", configurationUuid, fileVersion.getGroupId(), fileVersion.getRepositoryId(), fileVersion.getFileEntryId(), fileVersion.getFileVersionId()); }
From source file:com.liferay.adaptive.media.image.internal.storage.ImageStorageTest.java
License:Open Source License
@Test public void testGetFileVersionPath() { FileVersion fileVersion = Mockito.mock(FileVersion.class); Mockito.when(fileVersion.getGroupId()).thenReturn(1L); Mockito.when(fileVersion.getRepositoryId()).thenReturn(2L); Mockito.when(fileVersion.getFileEntryId()).thenReturn(3L); Mockito.when(fileVersion.getFileVersionId()).thenReturn(4L); String configurationUuid = StringUtil.randomString(); String fileVersionPath = _imageStorage.getFileVersionPath(fileVersion, configurationUuid); Assert.assertEquals("adaptive/" + configurationUuid + "/1/2/3/4/", fileVersionPath); }
From source file:com.liferay.adaptive.media.image.internal.util.ImageStorage.java
License:Open Source License
protected Path getFileVersionPath(FileVersion fileVersion) { return Paths.get(String.format("adaptive/%d/%d/%d/%d/", fileVersion.getGroupId(), fileVersion.getRepositoryId(), fileVersion.getFileEntryId(), fileVersion.getFileVersionId())); }
From source file:com.liferay.adaptive.media.image.internal.util.ImageStorageTest.java
License:Open Source License
@Test public void testGetFileVersionPath() { FileVersion fileVersion = Mockito.mock(FileVersion.class); Mockito.when(fileVersion.getGroupId()).thenReturn(1L); Mockito.when(fileVersion.getRepositoryId()).thenReturn(2L); Mockito.when(fileVersion.getFileEntryId()).thenReturn(3L); Mockito.when(fileVersion.getFileVersionId()).thenReturn(4L); Path fileVersionPath = _imageStorage.getFileVersionPath(fileVersion); Assert.assertEquals("adaptive/1/2/3/4", fileVersionPath.toString()); }
From source file:com.liferay.adaptive.media.image.internal.util.ImageStorageTest.java
License:Open Source License
@Test public void testGetFileVersionVariantPath() { FileVersion fileVersion = Mockito.mock(FileVersion.class); Mockito.when(fileVersion.getGroupId()).thenReturn(1L); Mockito.when(fileVersion.getRepositoryId()).thenReturn(2L); Mockito.when(fileVersion.getFileEntryId()).thenReturn(3L); Mockito.when(fileVersion.getFileVersionId()).thenReturn(4L); ImageAdaptiveMediaConfigurationEntry configurationEntry = new ImageAdaptiveMediaConfigurationEntry( StringUtil.randomString(), "xyz", Collections.emptyMap()); Path fileVersionVariantPath = _imageStorage.getFileVersionVariantPath(fileVersion, configurationEntry); Assert.assertEquals("adaptive/1/2/3/4/xyz", fileVersionVariantPath.toString()); }
From source file:com.liferay.adaptive.media.image.service.impl.AdaptiveMediaImageEntryLocalServiceImpl.java
License:Open Source License
/** * Adds an adaptive media image entry in the database and store the image * bytes in the file store.//from w ww . ja v a 2 s . c o m * * @param configurationEntry the configuration used to create the adaptive * media image * @param fileVersion the file version used to create the adaptive media * image * @param width the width of the adaptive media image * @param height the height of the adaptive media image * @param inputStream the input stream of the adaptive media image that * will be stored in the file store * @param size the size of the adaptive media image * @return the adaptive media image * @throws PortalException if an adaptive media image already exists for the * file version and configuration * * @review */ @Override public AdaptiveMediaImageEntry addAdaptiveMediaImageEntry( AdaptiveMediaImageConfigurationEntry configurationEntry, FileVersion fileVersion, int width, int height, InputStream inputStream, int size) throws PortalException { _checkDuplicates(configurationEntry.getUUID(), fileVersion.getFileVersionId()); long imageEntryId = counterLocalService.increment(); AdaptiveMediaImageEntry adaptiveMediaImageEntry = adaptiveMediaImageEntryPersistence.create(imageEntryId); adaptiveMediaImageEntry.setCompanyId(fileVersion.getCompanyId()); adaptiveMediaImageEntry.setGroupId(fileVersion.getGroupId()); adaptiveMediaImageEntry.setCreateDate(new Date()); adaptiveMediaImageEntry.setFileVersionId(fileVersion.getFileVersionId()); adaptiveMediaImageEntry.setMimeType(fileVersion.getMimeType()); adaptiveMediaImageEntry.setHeight(height); adaptiveMediaImageEntry.setWidth(width); adaptiveMediaImageEntry.setSize(size); adaptiveMediaImageEntry.setConfigurationUuid(configurationEntry.getUUID()); imageStorage.save(fileVersion, configurationEntry.getUUID(), inputStream); return adaptiveMediaImageEntryPersistence.update(adaptiveMediaImageEntry); }
From source file:com.liferay.adaptive.media.image.service.impl.AMImageEntryLocalServiceImpl.java
License:Open Source License
/** * Adds an adaptive media image entry in the database and stores the image * bytes in the file store./*from w ww . j av a 2 s. co m*/ * * @param amImageConfigurationEntry the configuration used to create the * adaptive media image * @param fileVersion the file version used to create the adaptive media * image * @param height the adaptive media image's height * @param width the adaptive media image's width * @param inputStream the adaptive media image's input stream to store in * the file store * @param size the adaptive media image's size * @return the adaptive media image * @throws PortalException if an adaptive media image already exists for the * file version and configuration */ @Override public AMImageEntry addAMImageEntry(AMImageConfigurationEntry amImageConfigurationEntry, FileVersion fileVersion, int height, int width, InputStream inputStream, long size) throws PortalException { _checkDuplicateAMImageEntry(amImageConfigurationEntry.getUUID(), fileVersion.getFileVersionId()); long imageEntryId = counterLocalService.increment(); AMImageEntry amImageEntry = amImageEntryPersistence.create(imageEntryId); amImageEntry.setGroupId(fileVersion.getGroupId()); amImageEntry.setCompanyId(fileVersion.getCompanyId()); amImageEntry.setCreateDate(new Date()); amImageEntry.setConfigurationUuid(amImageConfigurationEntry.getUUID()); amImageEntry.setFileVersionId(fileVersion.getFileVersionId()); amImageEntry.setMimeType(fileVersion.getMimeType()); amImageEntry.setHeight(height); amImageEntry.setWidth(width); amImageEntry.setSize(size); imageStorage.save(fileVersion, amImageConfigurationEntry.getUUID(), inputStream); return amImageEntryPersistence.update(amImageEntry); }
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;// w ww . ja v a 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.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 a2s . c o m for (long folderId : folderIds) { subscribersOVPs.add(new ObjectValuePair<String, Long>(_FOLDER_CLASS_NAME, folderId)); } return subscribersOVPs; }
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
public void deleteFiles(FileVersion fileVersion, String thumbnailType) { deleteFiles(fileVersion.getCompanyId(), fileVersion.getGroupId(), fileVersion.getFileEntryId(), fileVersion.getFileVersionId(), thumbnailType); }