List of usage examples for com.liferay.portal.kernel.portletfilerepository PortletFileRepositoryUtil getUniqueFileName
public static String getUniqueFileName(long groupId, long folderId, String fileName)
From source file:com.liferay.blogs.web.internal.upload.ImageBlogsUploadFileEntryHandler.java
License:Open Source License
protected FileEntry addFileEntry(String fileName, String contentType, InputStream inputStream, ThemeDisplay themeDisplay) throws PortalException { Folder folder = blogsLocalService.addAttachmentsFolder(themeDisplay.getUserId(), themeDisplay.getScopeGroupId()); String uniqueFileName = PortletFileRepositoryUtil.getUniqueFileName(themeDisplay.getScopeGroupId(), folder.getFolderId(), fileName); return PortletFileRepositoryUtil.addPortletFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), BlogsEntry.class.getName(), 0, BlogsConstants.SERVICE_NAME, folder.getFolderId(), inputStream, uniqueFileName, contentType, true); }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
@Override public FileEntry addPageAttachment(long userId, long nodeId, String title, String fileName, File file, String mimeType) throws PortalException { WikiPage page = getPage(nodeId, title); Folder folder = page.addAttachmentsFolder(); fileName = PortletFileRepositoryUtil.getUniqueFileName(page.getGroupId(), folder.getFolderId(), fileName); FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(page.getGroupId(), userId, WikiPage.class.getName(), page.getResourcePrimKey(), WikiConstants.SERVICE_NAME, folder.getFolderId(), file, fileName, mimeType, true); if (userId == 0) { userId = page.getUserId();/*from ww w . j ava 2 s . c om*/ } JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("fileEntryId", fileEntry.getFileEntryId()); extraDataJSONObject.put("fileEntryTitle", fileEntry.getTitle()); extraDataJSONObject.put("title", page.getTitle()); extraDataJSONObject.put("version", page.getVersion()); SocialActivityManagerUtil.addActivity(userId, page, SocialActivityConstants.TYPE_ADD_ATTACHMENT, extraDataJSONObject.toString(), 0); return fileEntry; }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
@Override public FileEntry addPageAttachment(long userId, long nodeId, String title, String fileName, InputStream inputStream, String mimeType) throws PortalException { WikiPage page = getPage(nodeId, title); Folder folder = page.addAttachmentsFolder(); fileName = PortletFileRepositoryUtil.getUniqueFileName(page.getGroupId(), folder.getFolderId(), fileName); FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(page.getGroupId(), userId, WikiPage.class.getName(), page.getResourcePrimKey(), WikiConstants.SERVICE_NAME, folder.getFolderId(), inputStream, fileName, mimeType, true); if (userId == 0) { userId = page.getUserId();//from w w w. ja va 2 s. c om } JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("fileEntryId", fileEntry.getFileEntryId()); extraDataJSONObject.put("fileEntryTitle", fileEntry.getTitle()); extraDataJSONObject.put("title", page.getTitle()); extraDataJSONObject.put("version", page.getVersion()); SocialActivityManagerUtil.addActivity(userId, page, SocialActivityConstants.TYPE_ADD_ATTACHMENT, extraDataJSONObject.toString(), 0); return fileEntry; }