List of usage examples for com.liferay.portal.kernel.repository.model FileEntry getFileVersion
public FileVersion getFileVersion() throws PortalException;
From source file:ca.efendi.datafeeds.model.impl.CJProductImpl.java
License:Open Source License
@Override public String getCoverImageURL(ThemeDisplay themeDisplay) throws PortalException { long coverImageFileEntryId = getCoverImageFileEntryId(); if (coverImageFileEntryId == 0) { return null; }//from w w w .j a va 2 s .c o m FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(coverImageFileEntryId); return DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), themeDisplay, StringPool.BLANK); }
From source file:ca.efendi.datafeeds.model.impl.CJProductImpl.java
License:Open Source License
@Override public String getSmallImageURL(ThemeDisplay themeDisplay) throws PortalException { if (Validator.isNotNull(getSmallImageURL())) { return getSmallImageURL(); }/*w w w.j a v a 2s. com*/ long smallImageFileEntryId = getSmallImageFileEntryId(); if (smallImageFileEntryId != 0) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(smallImageFileEntryId); return DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), themeDisplay, StringPool.BLANK); } long smallImageId = getSmallImageId(); if (smallImageId != 0) { return themeDisplay.getPathImage() + "/cjproduct/entry?img_id=" + getSmallImageId() + "&t=" + WebServerServletTokenUtil.getToken(getSmallImageId()); } return getCoverImageURL(themeDisplay); }
From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderLocalServiceImpl.java
License:Open Source License
/** * Uploads the file into the destination folder * If the file does not exist, adds the file. If exists, updates the existing file * Adds tags and categories to documents * * @param file/*w ww .j av a 2s. c om*/ * @param fileDescription * @param fileName * @param changeLog * @param serviceContext * @return FileEntry * @throws PortalException */ public FileEntry uploadFile(File file, String fileDescription, String fileName, String changeLog, ServiceContext serviceContext) throws PortalException { if (_log.isDebugEnabled()) { _log.debug("Invoking uploadFile...."); } long companyId = serviceContext.getCompanyId(); long groupId = serviceContext.getScopeGroupId(); long userId = serviceContext.getUserId(); // see https://issues.liferay.com/browse/LPS-66607 User user = userLocalService.getUser(userId); // Check permissions _fileUploadHelper.checkPermission(companyId, groupId, userId); String title = FilenameUtils.removeExtension(fileName); long folderId = GetterUtil.getLong(serviceContext.getAttribute(DESTINATION_FOLDER_ID)); fileName = file.getName(); String mimeType = MimeTypesUtil.getContentType(fileName); boolean majorVersion = true; DLFileEntry dlFileEntry = _dlFileEntryLocalService.fetchFileEntry(groupId, folderId, title); FileEntry fileEntry = null; if (Validator.isNull(dlFileEntry)) { fileEntry = addFileEntry(userId, groupId, folderId, fileName, mimeType, title, fileDescription, changeLog, file, serviceContext); } else { fileEntry = updateFileEntry(userId, dlFileEntry, fileName, mimeType, title, fileDescription, changeLog, majorVersion, file, serviceContext); } FileVersion fileVersion = fileEntry.getFileVersion(); long[] assetCategoryIds = _fileUploadHelper.getAssetCategoryIds(groupId, title, serviceContext); String[] assetTagNames = serviceContext.getAssetTagNames(); if (_log.isDebugEnabled()) { _log.debug(">>> Updating FileEntry with tags and categories"); } _dlAppLocalService.updateAsset(userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames, null); // Post processing uploaded file _fileUploadHelper.postProcessUpload(file, fileEntry.getFileEntryId(), serviceContext); return fileEntry; }
From source file:com.custom.portal.verify.CustomVerifyDynamicDataMapping.java
License:Open Source License
protected void updateDLFileUploadReferences(long dlFileEntryMetadataId) throws Exception { DLFileEntryMetadata dlFileEntryMetadata = DLFileEntryMetadataLocalServiceUtil .getFileEntryMetadata(dlFileEntryMetadataId); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(dlFileEntryMetadata.getFileEntryId()); FileVersion fileVersion = fileEntry.getFileVersion(); updateFileUploadReferences(fileEntry.getCompanyId(), dlFileEntryMetadata.getDDMStorageId(), fileEntry.getUserId(), fileEntry.getGroupId(), dlFileEntryMetadata, fileVersion.getStatus()); }
From source file:com.custom.portal.verify.CustomVerifyDynamicDataMapping.java
License:Open Source License
protected void updateFileEntryStatus(FileEntry fileEntry, int status, ServiceContext serviceContext) throws Exception { FileVersion fileVersion = fileEntry.getFileVersion(); Map<String, Serializable> workflowContext = new HashMap<String, Serializable>(); workflowContext.put("event", DLSyncConstants.EVENT_ADD); DLFileEntryLocalServiceUtil.updateStatus(fileVersion.getUserId(), fileVersion.getFileVersionId(), status, workflowContext, serviceContext); }
From source file:com.liferay.adaptive.media.blogs.internal.exportimport.content.processor.AdaptiveMediaTagFactory.java
License:Open Source License
public String createDynamicTag(FileEntry fileEntry) throws PortalException { String previewURL = DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, StringPool.BLANK); return String.format("<img data-fileentryid=\"%d\" src=\"%s\" />", fileEntry.getFileEntryId(), previewURL); }
From source file:com.liferay.adaptive.media.blogs.internal.exportimport.content.processor.AdaptiveMediaTagFactory.java
License:Open Source License
public String createStaticTag(FileEntry fileEntry) throws PortalException { try {// w ww . java 2 s .c o m String previewURL = DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), null, null); String fallbackTag = String.format("<img src=\"%s\" />", previewURL); return _htmlTagFactory.create(fallbackTag, fileEntry); } catch (AdaptiveMediaException ame) { throw new PortalException(ame); } }
From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAdaptiveMediaImageOptimizer.java
License:Open Source License
private void _optimize(long companyId, String configurationEntryUuid, int total, AtomicInteger atomicCounter) { ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery(); long classNameId = _classNameLocalService.getClassNameId(BlogsEntry.class.getName()); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override//from w ww.j av a2s . c om public void addCriteria(DynamicQuery dynamicQuery) { Property companyIdProperty = PropertyFactoryUtil.forName("companyId"); dynamicQuery.add(companyIdProperty.eq(companyId)); Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId"); dynamicQuery.add(classNameIdProperty.eq(classNameId)); Property mimeTypeProperty = PropertyFactoryUtil.forName("mimeType"); dynamicQuery.add(mimeTypeProperty.in(AdaptiveMediaImageConstants.getSupportedMimeTypes())); } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileEntry>() { @Override public void performAction(DLFileEntry dlFileEntry) throws PortalException { FileEntry fileEntry = new LiferayFileEntry(dlFileEntry); try { _adaptiveMediaImageProcessor.process(fileEntry.getFileVersion(), configurationEntryUuid); _sendStatusMessage(atomicCounter.incrementAndGet(), total); } catch (PortalException pe) { _log.error("Unable to process file entry id " + fileEntry.getFileEntryId(), pe); } } }); try { actionableDynamicQuery.performActions(); } catch (PortalException pe) { _log.error(pe, pe); } }
From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAMImageOptimizer.java
License:Open Source License
private void _optimize(long companyId, String configurationEntryUuid, int total, AtomicInteger atomicCounter) { ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/* ww w .j a v a2 s . c om*/ public void addCriteria(DynamicQuery dynamicQuery) { Property companyIdProperty = PropertyFactoryUtil.forName("companyId"); dynamicQuery.add(companyIdProperty.eq(companyId)); Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId"); long classNameId = _classNameLocalService.getClassNameId(BlogsEntry.class.getName()); dynamicQuery.add(classNameIdProperty.eq(classNameId)); Property mimeTypeProperty = PropertyFactoryUtil.forName("mimeType"); dynamicQuery.add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes())); } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileEntry>() { @Override public void performAction(DLFileEntry dlFileEntry) throws PortalException { FileEntry fileEntry = new LiferayFileEntry(dlFileEntry); try { _amImageProcessor.process(fileEntry.getFileVersion(), configurationEntryUuid); _sendStatusMessage(atomicCounter.incrementAndGet(), total); } catch (PortalException pe) { _log.error("Unable to process file entry " + fileEntry.getFileEntryId(), pe); } } }); try { actionableDynamicQuery.performActions(); } catch (PortalException pe) { _log.error(pe, pe); } }
From source file:com.liferay.adaptive.media.document.library.internal.document.library.exportimport.data.handler.AMImageDLPluggableContentDataHandler.java
License:Open Source License
private void _exportMedia(PortletDataContext portletDataContext, FileEntry fileEntry) throws IOException, PortalException { FileVersion fileVersion = fileEntry.getFileVersion(); Stream<AdaptiveMedia<AMImageProcessor>> adaptiveMediaStream = _amImageFinder.getAdaptiveMediaStream( amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(fileVersion).done()); List<AdaptiveMedia<AMImageProcessor>> adaptiveMediaList = adaptiveMediaStream.collect(Collectors.toList()); for (AdaptiveMedia<AMImageProcessor> adaptiveMedia : adaptiveMediaList) { _exportMedia(portletDataContext, fileEntry, adaptiveMedia); }/* w w w.j a va 2s.c o m*/ }