List of usage examples for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG
String JAVAX_PORTLET_CONFIG
To view the source code for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG.
Click Source Link
From source file:com.liferay.journal.web.internal.search.ArticleSearch.java
License:Open Source License
public ArticleSearch(PortletRequest portletRequest, int cur, int delta, PortletURL iteratorURL) { super(portletRequest, new ArticleDisplayTerms(portletRequest), new ArticleSearchTerms(portletRequest), "curEntry", cur, delta, iteratorURL, headerNames, null); PortletConfig portletConfig = (PortletConfig) portletRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); ArticleDisplayTerms displayTerms = (ArticleDisplayTerms) getDisplayTerms(); ArticleSearchTerms searchTerms = (ArticleSearchTerms) getSearchTerms(); String portletName = portletConfig.getPortletName(); if (!portletName.equals(JournalPortletKeys.JOURNAL)) { displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED); searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED); }//from w w w . j av a 2s .c o m iteratorURL.setParameter(ArticleDisplayTerms.ARTICLE_ID, displayTerms.getArticleId()); iteratorURL.setParameter(ArticleDisplayTerms.CONTENT, displayTerms.getContent()); iteratorURL.setParameter(ArticleDisplayTerms.DESCRIPTION, displayTerms.getDescription()); iteratorURL.setParameter(ArticleDisplayTerms.DDM_STRUCTURE_KEY, displayTerms.getDDMStructureKey()); iteratorURL.setParameter(ArticleDisplayTerms.DDM_TEMPLATE_KEY, displayTerms.getDDMTemplateKey()); iteratorURL.setParameter(ArticleDisplayTerms.FOLDER_ID, String.valueOf(displayTerms.getFolderId())); iteratorURL.setParameter(ArticleDisplayTerms.GROUP_ID, String.valueOf(displayTerms.getGroupId())); iteratorURL.setParameter(ArticleDisplayTerms.NAVIGATION, displayTerms.getNavigation()); iteratorURL.setParameter(ArticleDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus())); iteratorURL.setParameter(ArticleDisplayTerms.TITLE, displayTerms.getTitle()); iteratorURL.setParameter(ArticleDisplayTerms.VERSION, String.valueOf(displayTerms.getVersion())); try { PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest); String orderByCol = ParamUtil.getString(portletRequest, "orderByCol"); String orderByType = ParamUtil.getString(portletRequest, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { preferences.setValue(JournalPortletKeys.JOURNAL, "articles-order-by-col", orderByCol); preferences.setValue(JournalPortletKeys.JOURNAL, "articles-order-by-type", orderByType); } else { orderByCol = preferences.getValue(JournalPortletKeys.JOURNAL, "articles-order-by-col", "id"); orderByType = preferences.getValue(JournalPortletKeys.JOURNAL, "articles-order-by-type", "asc"); } OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil .getArticleOrderByComparator(orderByCol, orderByType); setOrderableHeaders(orderableHeaders); setOrderByCol(orderByCol); setOrderByType(orderByType); setOrderByComparator(orderByComparator); } catch (Exception e) { _log.error(e); } }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { throw new PrincipalException("Unable to create anonymous account"); }//from w ww . jav a 2 s.co m if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, LoginPortletKeys.FAST_LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } jsonObject = updateIncompleteUser(actionRequest, actionResponse); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { User user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); _portal.sendError(e, actionRequest, actionResponse); } } }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCRenderCommand.java
License:Open Source License
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) renderRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { return "/login.jsp"; }/*from w w w . j a v a2s .c o m*/ renderResponse.setTitle(themeDisplay.translate("anonymous-account")); return "/create_anonymous_account.jsp"; }
From source file:com.liferay.login.web.internal.servlet.taglib.include.AnonymousNavigationPrePageInclude.java
License:Open Source License
@Override public void include(PageContext pageContext) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String mvcRenderCommandName = request.getParameter("mvcRenderCommandName"); if ((mvcRenderCommandName != null) && mvcRenderCommandName.startsWith("/login/create_anonymous_account")) { return;// ww w.j a v a 2s .c o m } PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(PortletKeys.FAST_LOGIN)) { return; } RenderURLTag renderURLTag = new RenderURLTag(); renderURLTag.setPageContext(pageContext); renderURLTag.addParam("mvcRenderCommandName", "/login/create_anonymous_account"); renderURLTag.setVar("anonymousURL"); renderURLTag.setWindowState(WindowState.MAXIMIZED.toString()); renderURLTag.doTag(pageContext); String anonymousURL = (String) pageContext.getAttribute("anonymousURL"); IconTag iconTag = new IconTag(); iconTag.setIconCssClass("icon-user"); iconTag.setMessage("guest"); iconTag.setUrl(anonymousURL); iconTag.doTag(pageContext); }
From source file:com.liferay.login.web.internal.servlet.taglib.include.CreateAccountNavigationPostPageInclude.java
License:Open Source License
@Override public void include(PageContext pageContext) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String mvcRenderCommandName = request.getParameter("mvcRenderCommandName"); if ("/login/create_account".equals(mvcRenderCommandName)) { return;/*www.j a va 2s . c om*/ } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { return; } PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (portletName.equals(PortletKeys.FAST_LOGIN)) { return; } IconTag iconTag = new IconTag(); iconTag.setIconCssClass("icon-plus"); iconTag.setMessage("create-account"); try { iconTag.setUrl(_portal.getCreateAccountURL(request, themeDisplay)); } catch (Exception e) { throw new JspException(e); } iconTag.doTag(pageContext); }
From source file:com.liferay.login.web.internal.servlet.taglib.include.SignInNavigationPrePageInclude.java
License:Open Source License
@Override public void include(PageContext pageContext) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String mvcRenderCommandName = request.getParameter("mvcRenderCommandName"); if (Validator.isNull(mvcRenderCommandName) || "/login/login".equals(mvcRenderCommandName)) { return;//from ww w. ja va 2 s. c o m } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String signInURL = themeDisplay.getURLSignIn(); PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (portletName.equals(PortletKeys.FAST_LOGIN)) { PortletURL fastLoginURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN, PortletRequest.RENDER_PHASE); fastLoginURL.setParameter("saveLastPath", Boolean.FALSE.toString()); fastLoginURL.setParameter("mvcRenderCommandName", "/login/login"); try { fastLoginURL.setPortletMode(PortletMode.VIEW); fastLoginURL.setWindowState(LiferayWindowState.POP_UP); } catch (PortletException pe) { throw new JspException(pe); } signInURL = fastLoginURL.toString(); } IconTag iconTag = new IconTag(); iconTag.setIconCssClass("icon-signin"); iconTag.setMessage("sign-in"); iconTag.setUrl(signInURL); iconTag.doTag(pageContext); }
From source file:com.liferay.mail.util.MailManager.java
License:Open Source License
public static MailManager getInstance(HttpServletRequest request) throws PortalException { User user = PortalUtil.getUser(request); if (user == null) { return null; }//from w w w .j a v a 2s . c o m PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); return new MailManager(user, new PasswordRetriever(request), portletConfig); }
From source file:com.liferay.mail.vaadin.Controller.java
License:Open Source License
/** * Sets the current user based on the request and initializes any other * request-specific classes such as MailManager. *///from ww w . j a va2s . c om public void setRequest(PortletRequest request) { user = null; try { user = PortalUtil.getUser(request); } catch (PortalException e) { _log.debug(e); } catch (SystemException e) { _log.debug(e); } // get HTTP request from the portlet request HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request); // get PortletConfig config = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); // create MailManager passwordRetriever = new PasswordRetriever(httpRequest); mailMgr = new MailManager(user, passwordRetriever, config); }
From source file:com.liferay.polls.web.internal.portlet.action.EditQuestionMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try {/*from w w w . j a v a 2s. co m*/ if (Validator.isNull(cmd)) { return; } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE) || cmd.equals(Constants.VOTE)) { updateQuestion(portletConfig, actionRequest, actionResponse); } else if (cmd.equals(Constants.DELETE)) { deleteQuestion(actionRequest); } WindowState windowState = actionRequest.getWindowState(); if (windowState.equals(LiferayWindowState.POP_UP)) { String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } else { sendRedirect(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof NoSuchQuestionException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); actionResponse.setRenderParameter("mvcPath", "/polls/error.jsp"); } else if (e instanceof DuplicateVoteException || e instanceof NoSuchChoiceException || e instanceof QuestionChoiceException || e instanceof QuestionDescriptionException || e instanceof QuestionExpirationDateException || e instanceof QuestionTitleException) { SessionErrors.add(actionRequest, e.getClass()); hideDefaultErrorMessage(actionRequest); } else if (e instanceof QuestionExpiredException) { } else { throw e; } } }
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void editConfiguration(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String settingsScope = ParamUtil.getString(actionRequest, "settingsScope"); PortletPreferences portletPreferences = getPortletPreferences(themeDisplay, portlet.getPortletId(), settingsScope);//from w w w.ja va 2 s . com actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); ConfigurationAction configurationAction = getConfigurationAction(portlet); if (configurationAction == null) { return; } configurationAction.processAction(portletConfig, actionRequest, actionResponse); Layout layout = themeDisplay.getLayout(); PortletLayoutListener portletLayoutListener = portlet.getPortletLayoutListenerInstance(); if (portletLayoutListener != null) { portletLayoutListener.onSetup(portlet.getPortletId(), layout.getPlid()); } }