List of usage examples for com.liferay.portal.kernel.repository.model FileEntry isRepositoryCapabilityProvided
public <T extends Capability> boolean isRepositoryCapabilityProvided(Class<T> capabilityClass);
From source file:com.liferay.blogs.util.BlogsEntryImageSelectorHelper.java
License:Open Source License
public ImageSelector getImageSelector() throws Exception { if (_imageFileEntryId != _oldImageFileEntryId) { if (_imageFileEntryId != 0) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(_imageFileEntryId); _fileEntryTempFile = fileEntry.isRepositoryCapabilityProvided(TemporaryFileEntriesCapability.class); return new ImageSelector(FileUtil.getBytes(fileEntry.getContentStream()), fileEntry.getFileName(), fileEntry.getMimeType(), _imageCropRegion); } else {/*from w w w. j av a 2 s.co m*/ return new ImageSelector(); } } else if (!_imageURL.equals(_oldImageURL)) { return new ImageSelector(_imageURL); } return null; }
From source file:com.liferay.blogs.util.BlogsEntryImageSelectorHelper.java
License:Open Source License
public boolean isFileEntryTempFile() { if (_fileEntryTempFile == null) { if ((_imageFileEntryId == 0) || (_imageFileEntryId == _oldImageFileEntryId)) { _fileEntryTempFile = false;//w w w . j a v a 2s . c o m } else { try { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(_imageFileEntryId); _fileEntryTempFile = fileEntry .isRepositoryCapabilityProvided(TemporaryFileEntriesCapability.class); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return false; } } } return _fileEntryTempFile; }
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
protected void deleteFileEntry(ActionRequest actionRequest, boolean moveToTrash) throws Exception { long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId"); if (fileEntryId == 0) { return;//from w w w . j av a2 s . c o m } String version = ParamUtil.getString(actionRequest, "version"); if (Validator.isNotNull(version)) { _dlAppService.deleteFileVersion(fileEntryId, version); return; } if (!moveToTrash) { _dlAppService.deleteFileEntry(fileEntryId); return; } FileEntry fileEntry = _dlAppService.getFileEntry(fileEntryId); if (fileEntry.isRepositoryCapabilityProvided(TrashCapability.class)) { fileEntry = _dlTrashService.moveFileEntryToTrash(fileEntryId); TrashUtil.addTrashSessionMessages(actionRequest, (TrashedModel) fileEntry.getModel()); } hideDefaultSuccessMessage(actionRequest); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void addImageFileEntries(JournalArticle article, Element dynamicElementElement) throws PortalException { if (ExportImportThreadLocal.isImportInProcess()) { return;//from w ww .ja va 2 s. com } for (Element dynamicContentElement : dynamicElementElement.elements("dynamic-content")) { String value = dynamicContentElement.getText(); if (Validator.isNull(value)) { continue; } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(value); String uuid = jsonObject.getString("uuid"); long groupId = jsonObject.getLong("groupId"); FileEntry fileEntry = dlAppLocalService.getFileEntryByUuidAndGroupId(uuid, groupId); boolean tempFile = fileEntry.isRepositoryCapabilityProvided(TemporaryFileEntriesCapability.class); if (tempFile) { FileEntry tempFileEntry = fileEntry; Folder folder = article.addImagesFolder(); String fileEntryName = DLUtil.getUniqueFileName(fileEntry.getGroupId(), folder.getFolderId(), fileEntry.getFileName()); fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, fileEntry.getUserId(), JournalArticle.class.getName(), article.getResourcePrimKey(), JournalConstants.SERVICE_NAME, folder.getFolderId(), fileEntry.getContentStream(), fileEntryName, fileEntry.getMimeType(), false); dlAppLocalService.deleteFileEntry(tempFileEntry.getFileEntryId()); } JSONObject cdata = JSONFactoryUtil.createJSONObject(dynamicContentElement.getText()); cdata.put("resourcePrimKey", article.getResourcePrimKey()); cdata.put("uuid", fileEntry.getUuid()); dynamicContentElement.clearContent(); dynamicContentElement.addCDATA(cdata.toString()); } }