List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay setUser
public void setUser(User user)
From source file:com.liferay.alloy.mvc.jsonwebservice.BaseAlloyControllerInvokerImpl.java
License:Open Source License
protected DynamicServletRequest createRequest(String lifecycle, Object... parameters) throws Exception { if ((parameters.length % 2) != 0) { throw new IllegalArgumentException("Parameters length is not an even number"); }//from www . j ava 2 s. com HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper( new AlloyMockUtil.MockHttpServletRequest()); DynamicServletRequest request = new DynamicServletRequest(requestWrapper, false); for (int i = 0; i < parameters.length; i += 2) { request.appendParameter(String.valueOf(parameters[i]), String.valueOf(parameters[i + 1])); } request.appendParameter("controller", _controller); request.appendParameter("format", "json"); ThemeDisplay themeDisplay = (ThemeDisplay) _themeDisplay.clone(); PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); User user = UserLocalServiceUtil.getUser(permissionChecker.getUserId()); themeDisplay.setUser(user); request.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay); request.setAttribute(WebKeys.LAYOUT, themeDisplay.getLayout()); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) PortletConfigFactoryUtil.create(_portlet, null); request.setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, liferayPortletConfig); request.setAttribute(JavaConstants.JAVAX_PORTLET_PORTLET, _alloyPortlet); PortletRequest portletRequest = null; PortletResponse portletResponse = null; if (lifecycle.equals(PortletRequest.ACTION_PHASE)) { portletRequest = createActionRequest(); portletResponse = createActionResponse(); } else { portletRequest = createRenderRequest(); portletResponse = createRenderResponse(request, _portlet.getRootPortletId(), themeDisplay.getPlid(), lifecycle); } request.setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, portletRequest); request.setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse); request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle); request.setAttribute(BaseAlloyControllerImpl.VIEW_PATH, StringPool.BLANK); return request; }
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 a va 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.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);/* ww w .j a va 2 s .com*/ 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 ww . ja va 2 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; }