List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay ThemeDisplay
public ThemeDisplay()
From source file:com.liferay.blogs.portlet.test.PortletLayoutFinderTest.java
License:Open Source License
protected ThemeDisplay getThemeDisplay() throws Exception { ThemeDisplay themeDisplay = new ThemeDisplay(); themeDisplay.setScopeGroupId(_group.getGroupId()); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(TestPropsValues.getUser()); themeDisplay.setPermissionChecker(permissionChecker); themeDisplay.setPlid(_assetLayout.getPlid()); return themeDisplay; }
From source file:com.liferay.blogs.trackback.test.TrackbackImplTest.java
License:Open Source License
@Test public void testAddTrackback() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); _blogsEntry = BlogsEntryLocalServiceUtil.addEntry(TestPropsValues.getUserId(), StringUtil.randomString(), StringUtil.randomString(), new Date(), serviceContext); IdentityServiceContextFunction serviceContextFunction = new IdentityServiceContextFunction(serviceContext); CommentManagerUtil.addComment(TestPropsValues.getUserId(), TestPropsValues.getGroupId(), BlogsEntry.class.getName(), _blogsEntry.getEntryId(), StringUtil.randomString(), serviceContextFunction);/* w ww . ja v a 2s. c o m*/ int initialCommentsCount = CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), _blogsEntry.getEntryId()); Trackback trackback = new TrackbackImpl(); ThemeDisplay themeDisplay = new ThemeDisplay(); Company company = CompanyLocalServiceUtil.getCompany(TestPropsValues.getCompanyId()); themeDisplay.setCompany(company); trackback.addTrackback(_blogsEntry, themeDisplay, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), serviceContextFunction); Assert.assertEquals(initialCommentsCount + 1, CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), _blogsEntry.getEntryId())); LinkbackConsumerUtil.verifyNewTrackbacks(); }
From source file:com.liferay.calendar.util.test.CalendarUtilTest.java
License:Open Source License
protected ThemeDisplay createThemeDisplay() throws PortalException { ThemeDisplay themeDisplay = new ThemeDisplay(); Company company = CompanyLocalServiceUtil.getCompany(_group.getCompanyId()); themeDisplay.setCompany(company);//from w w w . j ava 2 s . c o m themeDisplay.setLocale(LocaleUtil.getDefault()); themeDisplay.setScopeGroupId(_group.getGroupId()); themeDisplay.setPermissionChecker(PermissionThreadLocal.getPermissionChecker()); themeDisplay.setUser(_user); return themeDisplay; }
From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormDisplayContextTest.java
License:Open Source License
protected RenderRequest mockRenderRequest() { RenderRequest renderRequest = new MockRenderRequest(); renderRequest.setAttribute(WebKeys.THEME_DISPLAY, new ThemeDisplay()); return renderRequest; }
From source file:com.liferay.dynamic.data.mapping.form.web.internal.display.context.DDLFormDisplayContextTest.java
License:Open Source License
protected RenderRequest mockRenderRequest() { RenderRequest renderRequest = new MockRenderRequest(); ThemeDisplay themeDisplay = new ThemeDisplay(); themeDisplay.setLocale(LocaleUtil.SPAIN); renderRequest.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay); return renderRequest; }
From source file:com.liferay.journal.search.test.JournalArticleIndexerSummaryTest.java
License:Open Source License
protected ThemeDisplay createThemeDisplay(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { ThemeDisplay themeDisplay = new ThemeDisplay(); themeDisplay.setCompany(CompanyLocalServiceUtil.getCompany(_group.getCompanyId())); themeDisplay.setLayout(LayoutTestUtil.addLayout(_group)); LayoutSet layoutSet = _group.getPublicLayoutSet(); themeDisplay.setLayoutSet(layoutSet); Theme theme = ThemeLocalServiceUtil.getTheme(_group.getCompanyId(), layoutSet.getThemeId()); themeDisplay.setLookAndFeel(theme, null); themeDisplay.setRealUser(_user);//from w w w . ja v a 2 s .c o m themeDisplay.setRequest(httpServletRequest); themeDisplay.setResponse(httpServletResponse); themeDisplay.setTimeZone(TimeZoneUtil.getDefault()); themeDisplay.setUser(_user); return themeDisplay; }
From source file:com.liferay.layout.type.controller.test.LayoutTypeURLTest.java
License:Open Source License
private ThemeDisplay _initThemeDisplay() throws Exception { _company.setVirtualHostname(_VIRTUAL_HOSTNAME); ThemeDisplay themeDisplay = new ThemeDisplay(); themeDisplay.setCompany(_company);// w w w .j a va2 s . c o m themeDisplay.setI18nLanguageId(StringPool.BLANK); themeDisplay.setLayout(_publicLayout); themeDisplay.setLayoutSet(_publicLayout.getLayoutSet()); themeDisplay.setSecure(false); themeDisplay.setServerName(_VIRTUAL_HOSTNAME); themeDisplay.setServerPort(8080); themeDisplay.setSiteGroupId(_group.getGroupId()); themeDisplay.setUser(TestPropsValues.getUser()); themeDisplay.setWidget(false); return themeDisplay; }
From source file:com.liferay.recommend.service.impl.RecommendEntityLocalServiceImpl.java
License:Open Source License
/** * NOTE FOR DEVELOPERS:// w w w .j a va2 s. com * * Never reference this class directly. Always use {@link com.liferay.recommend.service.RecommendEntityLocalServiceUtil} to access the recommend entity local service. */ private JSONArray _createJsonArrayFromWikiPageAssetEntries(ServiceContext serviceContext, List<AssetEntry> topViewedEntries) { JSONArray recommendationsJSONArray = JSONFactoryUtil.createJSONArray(); WikiTextExtractor wikiTextExtractor = new WikiTextExtractor(); wikiTextExtractor.setTitleSeparator("|"); for (AssetEntry assetEntry : topViewedEntries) { if (_log.isDebugEnabled()) { _log.debug("Top Entry: " + assetEntry); } AssetRenderer<?> assetRenderer = assetEntry.getAssetRenderer(); if ((assetRenderer != null) && (assetRenderer.getAssetObject() instanceof WikiPage)) { WikiPage wikiPage = (WikiPage) assetRenderer.getAssetObject(); String userPortraitUrl = null; try { ThemeDisplay themeDisplay = new ThemeDisplay(); User user = _userLocalService.fetchUser(assetEntry.getUserId()); userPortraitUrl = user.getPortraitURL(themeDisplay); } catch (PortalException pe) { _log.error("Error while retrieving user portrait URL", pe); } String url = serviceContext.getPortalURL() + "/share/" + _getNormalizedTitle(assetEntry.getTitle()); JSONObject entryJSONObject = JSONFactoryUtil.createJSONObject(); entryJSONObject.put("id", assetEntry.getClassPK()); entryJSONObject.put("userName", assetEntry.getUserName()); entryJSONObject.put("viewCount", assetEntry.getViewCount()); entryJSONObject.put("title", assetEntry.getTitle()); entryJSONObject.put("contentSample", wikiTextExtractor.truncateWikiContent(wikiPage.getContent(), wikiPage.getFormat(), 1000)); entryJSONObject.put("url", url); entryJSONObject.put("userPortraitUrl", userPortraitUrl); recommendationsJSONArray.put(entryJSONObject); } } return recommendationsJSONArray; }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testGroupHasCurrentPageScopeDescriptiveName() throws Exception { ThemeDisplay themeDisplay = new ThemeDisplay(); Group group = GroupTestUtil.addGroup(); Group scopeGroup = addScopeGroup(group); themeDisplay.setPlid(scopeGroup.getClassPK()); themeDisplay.setScopeGroupId(_group.getGroupId()); String scopeDescriptiveName = scopeGroup.getScopeDescriptiveName(themeDisplay); Assert.assertTrue(scopeDescriptiveName, scopeDescriptiveName.contains("current-page")); GroupLocalServiceUtil.deleteGroup(scopeGroup); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testGroupHasCurrentSiteScopeDescriptiveName() throws Exception { ThemeDisplay themeDisplay = new ThemeDisplay(); Group group = GroupTestUtil.addGroup(); themeDisplay.setScopeGroupId(group.getGroupId()); String scopeDescriptiveName = group.getScopeDescriptiveName(themeDisplay); Assert.assertTrue(scopeDescriptiveName, scopeDescriptiveName.contains("current-site")); GroupLocalServiceUtil.deleteGroup(group); }