List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay isSignedIn
public boolean isSignedIn()
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected int getStatus(final RenderRequest renderRequest) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return WorkflowConstants.STATUS_APPROVED; }/*from w w w. j a v a 2 s .c o m*/ final String value = renderRequest.getParameter("status"); final int status = GetterUtil.getInteger(value); if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) { return WorkflowConstants.STATUS_APPROVED; } final long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey"); if (resourcePrimKey == 0) { return WorkflowConstants.STATUS_APPROVED; } //final PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); /** * if (KBArticlePermission.contains( permissionChecker, resourcePrimKey, * ActionKeys.UPDATE)) { * * return ParamUtil.getInteger( renderRequest, "status", * WorkflowConstants.STATUS_ANY); } */ return WorkflowConstants.STATUS_APPROVED; }
From source file:com.liferay.comment.taglib.internal.struts.EditDiscussionStrutsAction.java
License:Open Source License
protected long updateComment(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long commentId = ParamUtil.getLong(request, "commentId"); String className = ParamUtil.getString(request, "className"); long classPK = ParamUtil.getLong(request, "classPK"); long parentCommentId = ParamUtil.getLong(request, "parentCommentId"); String subject = ParamUtil.getString(request, "subject"); String body = ParamUtil.getString(request, "body"); Function<String, ServiceContext> serviceContextFunction = new ServiceContextFunction(request); DiscussionPermission discussionPermission = _getDiscussionPermission(themeDisplay); if (commentId <= 0) { // Add message User user = null;/*from www . j a v a 2s .co m*/ if (themeDisplay.isSignedIn()) { user = themeDisplay.getUser(); } else { String emailAddress = ParamUtil.getString(request, "emailAddress"); user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { return 0; } } String name = PrincipalThreadLocal.getName(); PrincipalThreadLocal.setName(user.getUserId()); try { discussionPermission.checkAddPermission(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), className, classPK); commentId = _commentManager.addComment(user.getUserId(), className, classPK, user.getFullName(), parentCommentId, subject, body, serviceContextFunction); } finally { PrincipalThreadLocal.setName(name); } } else { // Update message if (Validator.isNull(className) || (classPK == 0)) { Comment comment = _commentManager.fetchComment(commentId); if (comment != null) { className = comment.getClassName(); classPK = comment.getClassPK(); } } discussionPermission.checkUpdatePermission(commentId); commentId = _commentManager.updateComment(themeDisplay.getUserId(), className, classPK, commentId, subject, body, serviceContextFunction); } // Subscription boolean subscribe = ParamUtil.getBoolean(request, "subscribe"); if (subscribe) { _commentManager.subscribeDiscussion(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK); } return commentId; }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.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;//from ww w . j a v a2 s . c om } try { String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); boolean jsonFormat = ParamUtil.getBoolean(actionRequest, "jsonFormat"); if (jsonFormat) { if (actionName.equals("addSocialRelation")) { addSocialRelation(actionRequest, actionResponse); } else if (actionName.equals("deleteSocialRelation")) { deleteSocialRelation(actionRequest, actionResponse); } else if (actionName.equals("requestSocialRelation")) { requestSocialRelation(actionRequest, actionResponse); } JSONObject jsonObject = getContactsDisplayJSONObject(actionRequest, actionResponse); writeJSON(actionRequest, actionResponse, jsonObject); } else if (actionName.equals("deleteEntry")) { deleteEntry(actionRequest, actionResponse); } else if (actionName.equals("updateEntry")) { updateEntry(actionRequest, actionResponse); } else if (actionName.equals("updateFieldGroup")) { updateFieldGroup(actionRequest, actionResponse); } else if (actionName.equals("updateSocialRequest")) { updateSocialRequest(actionRequest, actionResponse); } else { super.processAction(actionRequest, actionResponse); } } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.dynamic.data.lists.web.internal.display.context.DDLDisplayContext.java
License:Open Source License
public boolean isShowIconsActions() throws PortalException { if (isSpreadsheet()) { return false; }//from w ww . ja v a 2 s . c o m if (_hasShowIconsActionPermission != null) { return _hasShowIconsActionPermission; } _hasShowIconsActionPermission = Boolean.FALSE; ThemeDisplay themeDisplay = getThemeDisplay(); if (!themeDisplay.isSignedIn()) { return _hasShowIconsActionPermission; } Layout layout = themeDisplay.getLayout(); if (layout.isLayoutPrototypeLinkActive()) { return _hasShowIconsActionPermission; } if (isShowConfigurationIcon() || isShowAddDDMDisplayTemplateIcon() || isShowAddDDMFormTemplateIcon() || isShowEditDisplayDDMTemplateIcon() || isShowEditFormDDMTemplateIcon()) { _hasShowIconsActionPermission = Boolean.TRUE; } return _hasShowIconsActionPermission; }
From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java
License:Open Source License
@Override public int doStartTag() { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String randomNamespace = StringUtil.randomId() + StringPool.UNDERLINE; try {/*w ww .ja va2s .c om*/ Map<String, Object> context = getContext(); boolean enabled = GetterUtil.getBoolean(context.get("enabled"), true); Company company = themeDisplay.getCompany(); putValue("companyName", company.getName()); putValue("flagsEnabled", _isFlagsEnabled(themeDisplay)); putValue("formData", _getDataJSONObject(context)); putValue("id", randomNamespace + "id"); putValue("enabled", enabled); boolean label = GetterUtil.getBoolean(context.get("label"), true); putValue("label", label); String message = GetterUtil.getString(context.get("message"), LanguageUtil.get(request, "flag")); putValue("message", message); putValue("pathTermsOfUse", themeDisplay.getPathMain() + "/portal/terms_of_use"); putValue("pathThemeImages", themeDisplay.getPathThemeImages()); putValue("portletNamespace", PortalUtil.getPortletNamespace(PortletKeys.FLAGS)); boolean signedIn = themeDisplay.isSignedIn(); putValue("signedIn", signedIn); if (signedIn) { User user = themeDisplay.getUser(); putValue("reporterEmailAddress", user.getEmailAddress()); } String title = message; if (!enabled) { title = LanguageUtil.get(request, "flags-are-disabled-because-this-entry-is-in-the-recycle-" + "bin"); } putValue("title", title); putValue("uri", _getURI()); putValue("reasons", _getReasons(themeDisplay.getCompanyId())); } catch (Exception e) { _log.error(e, e); } setTemplateNamespace("Flags.render"); return super.doStartTag(); }
From source file:com.liferay.flags.taglib.servlet.taglib.soy.FlagsTag.java
License:Open Source License
private boolean _isFlagsEnabled(ThemeDisplay themeDisplay) throws PortalException { FlagsGroupServiceConfiguration flagsGroupServiceConfiguration = ConfigurationProviderUtil .getCompanyConfiguration(FlagsGroupServiceConfiguration.class, themeDisplay.getCompanyId()); boolean flagsEnabled = false; if (flagsGroupServiceConfiguration.guestUsersEnabled() || themeDisplay.isSignedIn()) { flagsEnabled = true;/*from ww w.j a va2 s . c om*/ } return flagsEnabled; }
From source file:com.liferay.grow.linkedpages.LinkedPagesPortletControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }//from ww w .java2s. c o m if (themeDisplay.isImpersonated()) { return true; } User user = themeDisplay.getUser(); if (themeDisplay.isSignedIn() && user.isSetupComplete()) { return true; } return false; }
From source file:com.liferay.layout.admin.web.internal.theme.contributor.ToggleControlsTemplateContextContributor.java
License:Open Source License
@Override public void prepare(Map<String, Object> contextObjects, HttpServletRequest request) { String liferayToggleControls = SessionClicks.get(request, "com.liferay.frontend.js.web_toggleControls", "visible"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { liferayToggleControls = "visible"; }// ww w . j av a 2 s.c o m String cssClass = GetterUtil.getString(contextObjects.get("bodyCssClass")); if (Objects.equals(liferayToggleControls, "visible")) { cssClass += " controls-visible"; } else { cssClass += " controls-hidden"; } contextObjects.put("bodyCssClass", cssClass); contextObjects.put("liferay_toggle_controls", liferayToggleControls); contextObjects.put("show_toggle_controls", themeDisplay.isSignedIn()); if (themeDisplay.isSignedIn()) { ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", themeDisplay.getLocale(), getClass()); contextObjects.put("toggle_controls_text", LanguageUtil.get(resourceBundle, "toggle-controls")); contextObjects.put("toggle_controls_url", "javascript:;"); } }
From source file:com.liferay.login.authentication.openid.connect.web.internal.portlet.action.OpenIdConnectLoginRequestMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { HttpServletRequest httpServletRequest = _portal.getHttpServletRequest(renderRequest); HttpServletResponse httpServletResponse = _portal.getHttpServletResponse(renderResponse); ThemeDisplay themeDisplay = (ThemeDisplay) httpServletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!_openIdConnect.isEnabled(themeDisplay.getCompanyId()) || themeDisplay.isSignedIn()) { return "/login.jsp"; }//from w w w. jav a 2 s .c o m Collection<String> openIdConnectProviderNames = _openIdConnectProviderRegistry .getOpenIdConnectProviderNames(); httpServletRequest.setAttribute(OpenIdConnectWebKeys.OPEN_ID_CONNECT_PROVIDER_NAMES, openIdConnectProviderNames); RequestDispatcher requestDispatcher = _servletContext.getRequestDispatcher(_JSP_PATH); try { requestDispatcher.include(httpServletRequest, httpServletResponse); } catch (Exception e) { _log.error("Unable to include JSP " + _JSP_PATH, e); throw new PortletException("Unable to include JSP " + _JSP_PATH, e); } return "/navigation.jsp"; }
From source file:com.liferay.login.authentication.openid.web.internal.portlet.action.OpenIdLoginMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { HttpServletRequest httpServletRequest = _portal.getHttpServletRequest(renderRequest); HttpServletResponse httpServletResponse = _portal.getHttpServletResponse(renderResponse); ThemeDisplay themeDisplay = (ThemeDisplay) httpServletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!_openId.isEnabled(themeDisplay.getCompanyId()) || themeDisplay.isSignedIn()) { return "/login.jsp"; }// ww w. j av a 2 s. c o m RequestDispatcher requestDispatcher = _servletContext.getRequestDispatcher(_JSP_PATH); try { requestDispatcher.include(httpServletRequest, httpServletResponse); } catch (Exception e) { _log.error("Unable to include JSP " + _JSP_PATH, e); throw new PortletException("Unable to include JSP " + _JSP_PATH, e); } return "/navigation.jsp"; }