List of usage examples for com.liferay.portal.kernel.portletfilerepository PortletFileRepositoryUtil getPortletFileEntryURL
public static String getPortletFileEntryURL(ThemeDisplay themeDisplay, FileEntry fileEntry, String queryString)
From source file:com.liferay.adaptive.media.blogs.editor.configuration.internal.stat1c.StaticAdaptiveMediaBlogsEntryAttachmentContentUpdaterTest.java
License:Open Source License
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); PowerMockito.mockStatic(PortletFileRepositoryUtil.class); Mockito.when(PortletFileRepositoryUtil.getPortletFileEntryURL(Mockito.isNull(ThemeDisplay.class), Mockito.eq(_fileEntry), Mockito.eq(StringPool.BLANK))).thenReturn(_FILE_ENTRY_IMAGE_URL); Mockito.when(_fileEntry.getFileEntryId()).thenReturn(_FILE_ENTRY_IMAGE_ID); _staticAdaptiveMediaBlogsEntryAttachmentContentUpdater .setAdaptiveMediaImageHTMLTagFactory(_adaptiveMediaImageHTMLTagFactory); }
From source file:com.liferay.adaptive.media.blogs.web.internal.attachment.AdaptiveMediaBlogsEntryAttachmentContentUpdater.java
License:Open Source License
@Override protected String getBlogsEntryAttachmentFileEntryImgTag(FileEntry blogsEntryAttachmentFileEntry) { String fileEntryURL = PortletFileRepositoryUtil.getPortletFileEntryURL(null, blogsEntryAttachmentFileEntry, StringPool.BLANK);//from w w w . j a v a2 s . c o m return "<img data-fileEntryId=\"" + blogsEntryAttachmentFileEntry.getFileEntryId() + "\" src=\"" + fileEntryURL + "\" />"; }
From source file:com.liferay.adaptive.media.blogs.web.internal.attachment.AdaptiveMediaBlogsEntryAttachmentContentUpdaterTest.java
License:Open Source License
@Before public void setUp() { MockitoAnnotations.initMocks(this); PowerMockito.mockStatic(PortletFileRepositoryUtil.class); Mockito.when(PortletFileRepositoryUtil.getPortletFileEntryURL(Mockito.isNull(ThemeDisplay.class), Mockito.eq(_fileEntry), Mockito.eq(StringPool.BLANK))).thenReturn(_FILE_ENTRY_IMAGE_URL); Mockito.when(_fileEntry.getFileEntryId()).thenReturn(_FILE_ENTRY_IMAGE_ID); }
From source file:com.liferay.blogs.attachments.test.BlogsEntryAttachmentFileEntryHelperTest.java
License:Open Source License
@Test public void testGetTempBlogsEntryAttachmentFileEntries() throws Exception { FileEntry tempFileEntry = TempFileEntryUtil.addTempFileEntry(_group.getGroupId(), _user.getUserId(), _TEMP_FOLDER_NAME, "image.jpg", getInputStream(), ContentTypes.IMAGE_JPEG); String tempFileEntryImgTag = BlogsTestUtil.getTempBlogsEntryAttachmentFileEntryImgTag( tempFileEntry.getFileEntryId(), PortletFileRepositoryUtil.getPortletFileEntryURL(null, tempFileEntry, StringPool.BLANK)); List<FileEntry> tempBlogsEntryAttachmentFileEntries = _blogsEntryAttachmentFileEntryHelper .getTempBlogsEntryAttachmentFileEntries(getContent(tempFileEntryImgTag)); Assert.assertEquals(1, tempBlogsEntryAttachmentFileEntries.size()); for (FileEntry tempBlogsEntryAttachmentFileEntry : tempBlogsEntryAttachmentFileEntries) { Assert.assertEquals(tempFileEntry.getFileEntryId(), tempBlogsEntryAttachmentFileEntry.getFileEntryId()); }// w w w . j ava 2 s . c om }
From source file:com.liferay.blogs.attachments.test.BlogsEntryAttachmentFileEntryHelperTest.java
License:Open Source License
protected String getModifiedTempFileEntryImgTag(FileEntry tempFileEntry) { StringBundler sb = new StringBundler(7); sb.append("<img "); sb.append(EditorConstants.ATTRIBUTE_DATA_IMAGE_ID); sb.append("=\""); sb.append(tempFileEntry.getFileEntryId()); sb.append("\" class=\"test-class\" id=\"test-id\" src=\""); sb.append(PortletFileRepositoryUtil.getPortletFileEntryURL(null, tempFileEntry, StringPool.BLANK)); sb.append("\" title=\"test-title\" />"); return sb.toString(); }
From source file:com.liferay.blogs.util.BlogsEntryAttachmentContentUpdater.java
License:Open Source License
protected String getBlogsEntryAttachmentFileEntryImgTag(FileEntry blogsEntryAttachmentFileEntry) { String fileEntryURL = PortletFileRepositoryUtil.getPortletFileEntryURL(null, blogsEntryAttachmentFileEntry, StringPool.BLANK);/* w w w .j a va 2s . c o m*/ return "<img src=\"" + fileEntryURL + "\" />"; }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {// w w w . ja va 2 s . com BlogsEntry entry = null; List<BlogsEntryAttachmentFileEntryReference> blogsEntryAttachmentFileEntryReferences = null; UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (uploadException.isExceededFileSizeLimit()) { throw new FileSizeException(cause); } if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(cause); } if (uploadException.isExceededUploadRequestSizeLimit()) { throw new UploadRequestSizeException(cause); } throw new PortalException(cause); } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { Callable<Object[]> updateEntryCallable = new UpdateEntryCallable(actionRequest); Object[] returnValue = TransactionInvokerUtil.invoke(_transactionConfig, updateEntryCallable); entry = (BlogsEntry) returnValue[0]; blogsEntryAttachmentFileEntryReferences = (List<BlogsEntryAttachmentFileEntryReference>) returnValue[1]; } else if (cmd.equals(Constants.DELETE)) { deleteEntries(actionRequest, false); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteEntries(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribe(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribe(actionRequest); } String redirect = ParamUtil.getString(actionRequest, "redirect"); String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_SAVE_DRAFT); boolean ajax = ParamUtil.getBoolean(actionRequest, "ajax"); if (ajax) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (BlogsEntryAttachmentFileEntryReference blogsEntryAttachmentFileEntryReference : blogsEntryAttachmentFileEntryReferences) { JSONObject blogsEntryFileEntryReferencesJSONObject = JSONFactoryUtil.createJSONObject(); blogsEntryFileEntryReferencesJSONObject.put("attributeDataImageId", EditorConstants.ATTRIBUTE_DATA_IMAGE_ID); blogsEntryFileEntryReferencesJSONObject.put("fileEntryId", String.valueOf( blogsEntryAttachmentFileEntryReference.getTempBlogsEntryAttachmentFileEntryId())); blogsEntryFileEntryReferencesJSONObject.put("fileEntryUrl", PortletFileRepositoryUtil.getPortletFileEntryURL(null, blogsEntryAttachmentFileEntryReference.getBlogsEntryAttachmentFileEntry(), StringPool.BLANK)); jsonArray.put(blogsEntryFileEntryReferencesJSONObject); } jsonObject.put("blogsEntryAttachmentReferences", jsonArray); jsonObject.put("coverImageFileEntryId", entry.getCoverImageFileEntryId()); jsonObject.put("entryId", entry.getEntryId()); jsonObject.put("redirect", redirect); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); return; } if ((entry != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { redirect = getSaveAndContinueRedirect(actionRequest, entry, redirect); sendRedirect(actionRequest, actionResponse, redirect); } else { WindowState windowState = actionRequest.getWindowState(); if (!windowState.equals(LiferayWindowState.POP_UP)) { sendRedirect(actionRequest, actionResponse, redirect); } else { redirect = PortalUtil.escapeRedirect(redirect); if (Validator.isNotNull(redirect)) { if (cmd.equals(Constants.ADD) && (entry != null)) { String namespace = PortalUtil.getPortletNamespace(portletId); redirect = HttpUtil.addParameter(redirect, namespace + "className", BlogsEntry.class.getName()); redirect = HttpUtil.addParameter(redirect, namespace + "classPK", entry.getEntryId()); } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); } } } } catch (AssetCategoryException | AssetTagException e) { SessionErrors.add(actionRequest, e.getClass(), e); actionResponse.setRenderParameter("mvcRenderCommandName", "/blogs/edit_entry"); hideDefaultSuccessMessage(actionRequest); } catch (EntryContentException | EntryCoverImageCropException | EntryDescriptionException | EntryDisplayDateException | EntrySmallImageNameException | EntrySmallImageScaleException | EntryTitleException | EntryUrlTitleException | FileSizeException | LiferayFileItemException | SanitizerException | UploadRequestSizeException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcRenderCommandName", "/blogs/edit_entry"); hideDefaultSuccessMessage(actionRequest); } catch (NoSuchEntryException | PrincipalException e) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp"); hideDefaultSuccessMessage(actionRequest); } catch (Throwable t) { _log.error(t, t); actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp"); hideDefaultSuccessMessage(actionRequest); } }