List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay isSignedIn
public boolean isSignedIn()
From source file:com.liferay.login.web.internal.portlet.action.LoginMVCActionCommand.java
License:Open Source License
protected void login(ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal .getOriginalServletRequest(_portal.getHttpServletRequest(actionRequest)); HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); String login = ParamUtil.getString(actionRequest, "login"); String password = actionRequest.getParameter("password"); boolean rememberMe = ParamUtil.getBoolean(actionRequest, "rememberMe"); if (!themeDisplay.isSignedIn()) { String portletId = _portal.getPortletId(actionRequest); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil .getStrictPortletSetup(themeDisplay.getLayout(), portletId); String authType = portletPreferences.getValue("authType", null); _authenticatedSessionManager.login(request, response, login, password, rememberMe, authType); }/*from w ww.j av a2 s.c om*/ String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { redirect = _portal.escapeRedirect(redirect); if (Validator.isNotNull(redirect) && !redirect.startsWith(Http.HTTP)) { redirect = getCompleteRedirectURL(request, redirect); } } String mainPath = themeDisplay.getPathMain(); if (PropsValues.PORTAL_JAAS_ENABLE) { if (Validator.isNotNull(redirect)) { redirect = mainPath.concat("/portal/protected?redirect=").concat(URLCodec.encodeURL(redirect)); } else { redirect = mainPath.concat("/portal/protected"); } actionResponse.sendRedirect(redirect); } else { if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } else { boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin"); if (doActionAfterLogin) { return; } else { actionResponse.sendRedirect(mainPath); } } } }
From source file:com.liferay.message.boards.web.internal.display.context.DefaultMBListDisplayContext.java
License:Open Source License
@Override public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (isShowSearch()) { long searchCategoryId = ParamUtil.getLong(_request, "searchCategoryId"); long[] categoryIdsArray = null; List categoryIds = new ArrayList(); categoryIds.add(Long.valueOf(searchCategoryId)); MBCategoryServiceUtil.getSubcategoryIds(categoryIds, themeDisplay.getScopeGroupId(), searchCategoryId); categoryIdsArray = StringUtil.split(StringUtil.merge(categoryIds), 0L); Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class); SearchContext searchContext = SearchContextFactory.getInstance(_request); searchContext.setAttribute("paginationType", "more"); searchContext.setCategoryIds(categoryIdsArray); searchContext.setEnd(searchContainer.getEnd()); searchContext.setIncludeAttachments(true); String keywords = ParamUtil.getString(_request, "keywords"); searchContext.setKeywords(keywords); searchContext.setStart(searchContainer.getStart()); Hits hits = indexer.search(searchContext); searchContainer.setResults(SearchResultUtil.getSearchResults(hits, _request.getLocale())); searchContainer.setSearch(true); searchContainer.setTotal(hits.getLength()); } else if (isShowRecentPosts()) { searchContainer.setEmptyResultsMessage("there-are-no-recent-posts"); long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId"); Calendar calendar = Calendar.getInstance(); MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings .getInstance(themeDisplay.getSiteGroupId()); int offset = GetterUtil.getInteger(mbGroupServiceSettings.getRecentPostsDateOffset()); calendar.add(Calendar.DATE, -offset); searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(), groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED)); searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(), groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd())); } else if (isShowMyPosts()) { long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId"); if (themeDisplay.isSignedIn()) { groupThreadsUserId = themeDisplay.getUserId(); }/*from w ww. ja v a 2s . c om*/ int status = WorkflowConstants.STATUS_ANY; searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(), groupThreadsUserId, status)); searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(), groupThreadsUserId, status, searchContainer.getStart(), searchContainer.getEnd())); searchContainer.setEmptyResultsMessage("you-do-not-have-any-posts"); } else { int status = WorkflowConstants.STATUS_APPROVED; PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) { status = WorkflowConstants.STATUS_ANY; } searchContainer.setTotal(MBCategoryLocalServiceUtil .getCategoriesAndThreadsCount(themeDisplay.getScopeGroupId(), _categoryId, status)); searchContainer.setResults(MBCategoryServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(), _categoryId, status, searchContainer.getStart(), searchContainer.getEnd())); } }
From source file:com.liferay.notifications.web.internal.portlet.NotificationsPortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return;// www . j a v a 2 s . com } try { String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); if (actionName.equals("deleteAllNotifications")) { deleteAllNotifications(actionRequest, actionResponse); } else if (actionName.equals("deleteUserNotificationEvent")) { deleteUserNotificationEvent(actionRequest, actionResponse); } else if (actionName.equals("markNotificationsAsRead")) { markNotificationsAsRead(actionRequest, actionResponse); } else if (actionName.equals("markNotificationAsRead")) { markNotificationAsRead(actionRequest, actionResponse); } else if (actionName.equals("markNotificationsAsUnread")) { markNotificationsAsUnread(actionRequest, actionResponse); } else if (actionName.equals("markNotificationAsUnread")) { markNotificationAsUnread(actionRequest, actionResponse); } else if (actionName.equals("unsubscribe")) { unsubscribe(actionRequest, actionResponse); } else if (actionName.equals("updateUserNotificationDelivery")) { updateUserNotificationDelivery(actionRequest, actionResponse); } else { super.processAction(actionRequest, actionResponse); } } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.polls.web.internal.portlet.util.PollsUtil.java
License:Open Source License
public static boolean hasVoted(HttpServletRequest request, long questionId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isSignedIn()) { PollsVote vote = PollsVoteLocalServiceUtil.fetchQuestionUserVote(questionId, themeDisplay.getUserId()); if (vote == null) { return false; }// www. j a v a 2 s. c om return true; } String cookie = CookieKeys.getCookie(request, _getCookieName(questionId)); return GetterUtil.getBoolean(cookie); }
From source file:com.liferay.portlet.configuration.icon.maximize.internal.MaximizePortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!GetterUtil.getBoolean(themeDisplay.getThemeSetting("show-maximize-minimize-application-links"))) { return false; }/*from ww w. j a v a 2 s.c o m*/ Layout layout = themeDisplay.getLayout(); if (!layout.isTypePortlet()) { return false; } LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); LayoutTypeController layoutTypeController = layoutTypePortlet.getLayoutTypeController(); if (layoutTypeController.isFullPageDisplayable()) { return false; } Portlet portlet = (Portlet) portletRequest.getAttribute(WebKeys.RENDER_PORTLET); if (!portlet.hasWindowState(portletRequest.getResponseContentType(), WindowState.MAXIMIZED)) { return false; } Group group = themeDisplay.getScopeGroup(); if (!themeDisplay.isSignedIn() || (group.hasStagingGroup() && !group.isStagingGroup()) || !hasUpdateLayoutPermission(themeDisplay)) { if (!PropsValues.LAYOUT_GUEST_SHOW_MAX_ICON) { return false; } } return true; }
From source file:com.liferay.portlet.configuration.icon.minimize.internal.MinimizePortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!GetterUtil.getBoolean(themeDisplay.getThemeSetting("show-maximize-minimize-application-links"))) { return false; }//from w w w . j a v a 2s . c om Layout layout = themeDisplay.getLayout(); if (!layout.isTypePortlet()) { return false; } LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); LayoutTypeController layoutTypeController = layoutTypePortlet.getLayoutTypeController(); if (layoutTypeController.isFullPageDisplayable()) { return false; } Portlet portlet = (Portlet) portletRequest.getAttribute(WebKeys.RENDER_PORTLET); if (!portlet.hasWindowState(portletRequest.getResponseContentType(), WindowState.MINIMIZED)) { return false; } Group group = themeDisplay.getScopeGroup(); if (!themeDisplay.isSignedIn() || (group.hasStagingGroup() && !group.isStagingGroup()) || !hasUpdateLayoutPermission(themeDisplay)) { if (!PropsValues.LAYOUT_GUEST_SHOW_MIN_ICON) { return false; } } return true; }
From source file:com.liferay.product.navigation.control.menu.theme.contributor.internal.ProductNavigationControlMenuTemplateContextContributor.java
License:Open Source License
protected boolean isShowControlMenu(HttpServletRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isImpersonated()) { return true; }//from ww w . j av a 2 s. com if (!themeDisplay.isSignedIn()) { return false; } User user = themeDisplay.getUser(); if (!user.isSetupComplete()) { return false; } return true; }
From source file:com.liferay.product.navigation.product.menu.theme.contributor.internal.ProductMenuTemplateContextContributor.java
License:Open Source License
protected boolean isShowProductMenu(HttpServletRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isImpersonated()) { return true; }/*from ww w .j a v a 2 s .c o m*/ if (!themeDisplay.isSignedIn()) { return false; } User user = themeDisplay.getUser(); if (!user.isSetupComplete()) { return false; } return true; }
From source file:com.liferay.product.navigation.product.menu.web.internal.product.navigation.control.menu.ProductMenuProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isImpersonated()) { return true; }/*from w ww. ja v a 2 s . c o m*/ User user = themeDisplay.getUser(); if (themeDisplay.isSignedIn() && user.isSetupComplete()) { return true; } return false; }
From source file:com.liferay.salesforce.portlet.SalesforceContactsPortlet.java
License:Apache License
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(resourceResponse); ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); httpServletResponse.setContentType(ContentTypes.TEXT); String requestMethod = ParamUtil.getString(resourceRequest, "type"); resourceResponse.setContentType(ContentTypes.TEXT_JAVASCRIPT); String username = getUsername(resourceRequest); try {/* w w w. ja va2 s . c o m*/ if (themeDisplay.isSignedIn() && (requestMethod != null) && requestMethod.equals(_CONTACTS) && username != null) { MessageBatch messageBatch = SalesforceContactLocalServiceUtil.getContactsByUserName( PortalUtil.getDefaultCompanyId(), username, Arrays.asList(FIELD_NAMES), PortalUtil.getUserId(resourceRequest)); httpServletResponse.getWriter().print(MessageBatchConverter.getJSONString(messageBatch)); httpServletResponse.flushBuffer(); } else if (themeDisplay.isSignedIn() && (requestMethod != null) && requestMethod.equals(_CONTACTS_FOR_ACCOUNT) && username != null) { String accountId = resourceRequest.getParameter("accId"); MessageBatch messageBatch = SalesforceContactLocalServiceUtil.getContactsByAccountId( PortalUtil.getDefaultCompanyId(), accountId, Arrays.asList(FIELD_NAMES), PortalUtil.getUserId(resourceRequest)); httpServletResponse.getWriter().print(MessageBatchConverter.getJSONString(messageBatch)); httpServletResponse.flushBuffer(); } else { httpServletResponse.getWriter().print(""); httpServletResponse.flushBuffer(); } } catch (SystemException e) { throw new PortletException("Unable to process request", e); } }