List of usage examples for com.liferay.portal.kernel.portletfilerepository PortletFileRepositoryUtil getPortletFileEntry
public static FileEntry getPortletFileEntry(long fileEntryId) 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 v a 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 2 s. co m*/ 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.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test public void testAddImage() throws Exception { BlogsEntry blogsEntry = addBlogsEntry((ImageSelector) null); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(), user.getUserId());// w w w. j a v a 2 s .c o m FileEntry fileEntry = getTempFileEntry(user.getUserId(), "image1.jpg", serviceContext); ImageSelector imageSelector = new ImageSelector(FileUtil.getBytes(fileEntry.getContentStream()), fileEntry.getTitle(), fileEntry.getMimeType(), IMAGE_CROP_REGION); addImage(blogsEntry.getEntryId(), imageSelector); blogsEntry = BlogsEntryLocalServiceUtil.getEntry(blogsEntry.getEntryId()); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); Assert.assertEquals("image1.jpg", imageFileEntry.getTitle()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test public void testAddImageWhenAddingEntry() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); Assert.assertEquals("image1.jpg", imageFileEntry.getTitle()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test(expected = NoSuchFileEntryException.class) public void testImageDeletedWhenDeletingBlogsEntry() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); BlogsEntryLocalServiceUtil.deleteEntry(blogsEntry); PortletFileRepositoryUtil.getPortletFileEntry(imageFileEntry.getFileEntryId()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test(expected = NoSuchFileEntryException.class) public void testImageDeletedWhenUpdatingBlogsEntryWithEmptyImageSelector() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); ImageSelector imageSelector = new ImageSelector(null, StringPool.BLANK, StringPool.BLANK, StringPool.BLANK); blogsEntry = updateBlogsEntry(blogsEntry.getEntryId(), imageSelector); Assert.assertEquals(0, getImageFileEntryId(blogsEntry)); PortletFileRepositoryUtil.getPortletFileEntry(imageFileEntry.getFileEntryId()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test public void testImageNotUpdatedWhenUpdatingBlogsEntryWithNullImageSelector() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); ImageSelector imageSelector = null;/*from ww w . j a va 2s.c om*/ blogsEntry = updateBlogsEntry(blogsEntry.getEntryId(), imageSelector); Assert.assertEquals(imageFileEntry.getFileEntryId(), getImageFileEntryId(blogsEntry)); PortletFileRepositoryUtil.getPortletFileEntry(imageFileEntry.getFileEntryId()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test public void testImageStoredInBlogsRepository() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); Repository repository = RepositoryLocalServiceUtil.getRepository(imageFileEntry.getRepositoryId()); Assert.assertEquals(BlogsConstants.SERVICE_NAME, repository.getName()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test public void testImageStoredInInvisibleImageFolder() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); Folder imageFolder = imageFileEntry.getFolder(); Assert.assertNotEquals(BlogsConstants.SERVICE_NAME, imageFolder.getName()); }
From source file:com.liferay.blogs.attachments.test.BaseBlogsEntryImageTestCase.java
License:Open Source License
@Test(expected = NoSuchFileEntryException.class) public void testPreviousImageDeletedWhenUpdatingImage() throws Exception { BlogsEntry blogsEntry = addBlogsEntry("image1.jpg"); FileEntry imageFileEntry = PortletFileRepositoryUtil.getPortletFileEntry(getImageFileEntryId(blogsEntry)); updateBlogsEntry(blogsEntry.getEntryId(), "image2.jpg"); PortletFileRepositoryUtil.getPortletFileEntry(imageFileEntry.getFileEntryId()); }