List of usage examples for com.liferay.portal.kernel.portlet PortletURLFactoryUtil create
public static LiferayPortletURL create(PortletRequest portletRequest, String portletId, String lifecycle)
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
protected String getSaveAndContinueRedirect(ActionRequest actionRequest, JournalArticle article, String redirect) throws Exception { String referringPortletResource = ParamUtil.getString(actionRequest, "referringPortletResource"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, JournalPortletKeys.JOURNAL, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/edit_article.jsp"); portletURL.setParameter("redirect", redirect); portletURL.setParameter("referringPortletResource", referringPortletResource); portletURL.setParameter("resourcePrimKey", String.valueOf(article.getResourcePrimKey())); portletURL.setParameter("groupId", String.valueOf(article.getGroupId())); portletURL.setParameter("folderId", String.valueOf(article.getFolderId())); portletURL.setParameter("articleId", article.getArticleId()); portletURL.setParameter("version", String.valueOf(article.getVersion())); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
protected void sendEditArticleRedirect(ActionRequest actionRequest, ActionResponse actionResponse, JournalArticle article, String oldUrlTitle) throws Exception { String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); String redirect = ParamUtil.getString(actionRequest, "redirect"); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_PUBLISH); String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); String namespace = _portal.getPortletNamespace(portletId); if (Validator.isNotNull(oldUrlTitle)) { String oldRedirectParam = namespace + "redirect"; String oldRedirect = HttpUtil.getParameter(redirect, oldRedirectParam, false); if (Validator.isNotNull(oldRedirect)) { String newRedirect = HttpUtil.decodeURL(oldRedirect); newRedirect = StringUtil.replace(newRedirect, oldUrlTitle, article.getUrlTitle()); newRedirect = StringUtil.replace(newRedirect, oldRedirectParam, "redirect"); redirect = StringUtil.replace(redirect, oldRedirect, newRedirect); }/*from w w w . ja v a 2 s.c om*/ } if ((actionName.equals("deleteArticle") || actionName.equals("deleteArticles")) && !ActionUtil.hasArticle(actionRequest)) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPpid(), PortletRequest.RENDER_PHASE); redirect = portletURL.toString(); } if ((article != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { redirect = getSaveAndContinueRedirect(actionRequest, article, redirect); if (actionName.equals("previewArticle")) { SessionMessages.add(actionRequest, "previewRequested"); hideDefaultSuccessMessage(actionRequest); } } else { WindowState windowState = actionRequest.getWindowState(); if (windowState.equals(LiferayWindowState.POP_UP)) { redirect = _portal.escapeRedirect(redirect); if (Validator.isNotNull(redirect)) { if (actionName.equals("addArticle") && (article != null)) { redirect = HttpUtil.addParameter(redirect, namespace + "className", JournalArticle.class.getName()); redirect = HttpUtil.addParameter(redirect, namespace + "classPK", JournalArticleAssetRenderer.getClassPK(article)); } } } } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
protected void redirectUpdateAccount(HttpServletRequest request, HttpServletResponse response, User user) throws Exception { PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("saveLastPath", Boolean.FALSE.toString()); portletURL.setParameter("mvcRenderCommandName", "/login/associate_facebook_user"); portletURL.setParameter("redirect", ParamUtil.getString(request, "redirect")); portletURL.setParameter("userId", String.valueOf(user.getUserId())); portletURL.setParameter("emailAddress", user.getEmailAddress()); portletURL.setParameter("firstName", user.getFirstName()); portletURL.setParameter("lastName", user.getLastName()); portletURL.setPortletMode(PortletMode.VIEW); portletURL.setWindowState(LiferayWindowState.POP_UP); response.sendRedirect(portletURL.toString()); }
From source file:com.liferay.login.authentication.google.web.internal.portlet.action.GoogleLoginAction.java
License:Open Source License
protected void sendLoginRedirect(HttpServletRequest request, HttpServletResponse response) throws Exception { PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setWindowState(LiferayWindowState.POP_UP); response.sendRedirect(portletURL.toString()); }
From source file:com.liferay.login.authentication.google.web.internal.portlet.action.GoogleLoginAction.java
License:Open Source License
protected void sendUpdateAccountRedirect(HttpServletRequest request, HttpServletResponse response, User user) throws Exception { PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("saveLastPath", Boolean.FALSE.toString()); portletURL.setParameter("mvcRenderCommandName", "/login/associate_google_user"); PortletURL redirectURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, PortletRequest.RENDER_PHASE); redirectURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); redirectURL.setParameter("emailAddress", user.getEmailAddress()); redirectURL.setParameter("anonymousUser", Boolean.FALSE.toString()); redirectURL.setPortletMode(PortletMode.VIEW); redirectURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("redirect", redirectURL.toString()); portletURL.setParameter("userId", String.valueOf(user.getUserId())); portletURL.setParameter("emailAddress", user.getEmailAddress()); portletURL.setParameter("firstName", user.getFirstName()); portletURL.setParameter("lastName", user.getLastName()); portletURL.setPortletMode(PortletMode.VIEW); portletURL.setWindowState(LiferayWindowState.POP_UP); response.sendRedirect(portletURL.toString()); }
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 w w . j a va2 s .c o 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.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;/* ww w . j ava2 s . c om*/ } 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.message.boards.web.internal.portlet.configuration.icon.DeleteThreadPortletConfigurationIcon.java
License:Open Source License
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { PortletURL deleteURL = PortalUtil.getControlPanelPortletURL(portletRequest, MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE); deleteURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/delete_thread"); String cmd = Constants.DELETE; ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (isTrashEnabled(themeDisplay.getScopeGroupId())) { cmd = Constants.MOVE_TO_TRASH;//from w ww . java 2 s . c o m } deleteURL.setParameter(Constants.CMD, cmd); try { MBCategory category = ActionUtil.getCategory(portletRequest); PortletURL parentCategoryURL = PortletURLFactoryUtil.create(portletRequest, MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.RENDER_PHASE); long categoryId = getCategoryId(category); if (categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view"); } else { parentCategoryURL.setParameter("mvcRenderCommandName", "/message_boards/view_category"); parentCategoryURL.setParameter("mbCategoryId", String.valueOf(categoryId)); } deleteURL.setParameter("redirect", parentCategoryURL.toString()); MBMessage message = ActionUtil.getMessage(portletRequest); deleteURL.setParameter("threadId", String.valueOf(message.getThreadId())); } catch (Exception e) { return null; } return deleteURL.toString(); }
From source file:com.liferay.notifications.web.internal.portlet.configuration.icon.DeliveryPortletConfigurationIcon.java
License:Open Source License
protected PortletURL getDeliveryURL(PortletRequest portletRequest) { PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, NotificationsPortletKeys.NOTIFICATIONS, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/notifications/configuration.jsp"); try {/* w w w . j a v a2s.c o m*/ portletURL.setWindowState(LiferayWindowState.POP_UP); } catch (WindowStateException wse) { } return portletURL; }
From source file:com.liferay.notifications.web.internal.portlet.configuration.icon.MarkAllNotificationsAsReadPortletConfigurationIcon.java
License:Open Source License
@Override public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) { PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, NotificationsPortletKeys.NOTIFICATIONS, PortletRequest.ACTION_PHASE); portletURL.setParameter(ActionRequest.ACTION_NAME, "markAllNotificationsAsRead"); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); return portletURL.toString(); }