List of usage examples for com.liferay.portal.kernel.repository.model FileEntry getRepositoryCapability
public <T extends Capability> T getRepositoryCapability(Class<T> capabilityClass);
From source file:com.liferay.exportimport.test.ExportImportHelperUtilTest.java
License:Open Source License
protected FileEntry getFileEntry() throws PortalException { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_stagingGroup.getGroupId(), TestPropsValues.getUserId()); FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _stagingGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".txt", ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext); ThumbnailCapability thumbnailCapability = fileEntry.getRepositoryCapability(ThumbnailCapability.class); fileEntry = thumbnailCapability.setLargeImageId(fileEntry, fileEntry.getFileEntryId()); return fileEntry; }
From source file:com.liferay.message.boards.service.test.MBMessageLocalServiceTest.java
License:Open Source License
@Test public void testDeleteAttachmentsWhenUpdatingMessageAndTrashEnabled() throws Exception { MBMessage message = addMessage(null, true); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); MBMessageLocalServiceUtil.updateMessage(TestPropsValues.getUserId(), message.getMessageId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), Collections.<ObjectValuePair<String, InputStream>>emptyList(), Collections.<String>emptyList(), 0, false, serviceContext);//w w w . j a va 2 s .c o m List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(message.getGroupId(), message.getAttachmentsFolderId()); Assert.assertEquals(fileEntries.toString(), 1, fileEntries.size()); FileEntry fileEntry = fileEntries.get(0); WorkflowCapability workflowCapability = fileEntry.getRepositoryCapability(WorkflowCapability.class); Assert.assertEquals(WorkflowConstants.STATUS_IN_TRASH, workflowCapability.getStatus(fileEntry)); }
From source file:com.liferay.wiki.search.WikiPageIndexer.java
License:Open Source License
@Override public void addRelatedEntryFields(Document document, Object obj) throws Exception { long classPK = 0; if (obj instanceof Comment) { Comment comment = (Comment) obj; classPK = comment.getClassPK();/*w ww.j ava2s . c o m*/ } else if (obj instanceof FileEntry) { FileEntry fileEntry = (FileEntry) obj; RelatedModelCapability relatedModelCapability = fileEntry .getRepositoryCapability(RelatedModelCapability.class); classPK = relatedModelCapability.getClassPK(fileEntry); } WikiPage page = null; try { page = _wikiPageLocalService.getPage(classPK); } catch (Exception e) { return; } document.addKeyword(Field.NODE_ID, page.getNodeId()); }