protected void redirectUpdateAccount( HttpServletRequest request, HttpServletResponse response, User user) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( request, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("saveLastPath", Boolean.FALSE.toString()); portletURL.setParameter("struts_action", "/login/update_account"); PortletURL redirectURL = PortletURLFactoryUtil.create( request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); redirectURL.setParameter("struts_action", "/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()); }
private LiferayPortletURL createLiferayPortletURL( PortletRequest request, String toPage, String portletId) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); // String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); LiferayPortletURL renderURL = null; String localHost = themeDisplay.getPortalURL(); List<Layout> layouts = null; try { layouts = LayoutLocalServiceUtil.getLayouts(themeDisplay.getLayout().getGroupId(), false); for (Layout layout : layouts) { String nodeNameRemoved = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay).replace(localHost, ""); // Viene ricercato l'URL esatto per la pagina successiva if (nodeNameRemoved.indexOf(toPage) > 0) { renderURL = PortletURLFactoryUtil.create( request, portletId, layout.getPlid(), PortletRequest.RENDER_PHASE); renderURL.setWindowState(WindowState.NORMAL); renderURL.setPortletMode(PortletMode.VIEW); break; } } } catch (Exception e) { e.printStackTrace(); } return renderURL; }
@Override public PortletURL getURLAdd( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!AdminPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), ActionKeys.ADD_KB_ARTICLE)) { return null; } PortletURL portletURL = PortletURLFactoryUtil.create( liferayPortletRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, getControlPanelPlid(themeDisplay), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/admin/edit_article.jsp"); return portletURL; }
@Override public String getURLViewInContext( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser(); long portletPlid = PortalUtil.getPlidFromPortletId(user.getGroupId(), true, PortletKeys.TASKS); PortletURL portletURL = PortletURLFactoryUtil.create( liferayPortletRequest, PortletKeys.TASKS, portletPlid, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/tasks/view.jsp"); return portletURL.toString(); } catch (Exception e) { } return null; }
@Override public String getRestoreLink(PortletRequest portletRequest, long classPK) throws PortalException, SystemException { String portletId = PortletKeys.WIKI; WikiPage page = WikiPageLocalServiceUtil.getPage(classPK); long plid = PortalUtil.getPlidFromPortletId(page.getGroupId(), PortletKeys.WIKI); if (plid == LayoutConstants.DEFAULT_PLID) { plid = PortalUtil.getControlPanelPlid(portletRequest); portletId = PortletKeys.WIKI_ADMIN; } PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE); WikiNode node = page.getNode(); portletURL.setParameter("struts_action", "/wiki/view"); portletURL.setParameter("nodeName", node.getName()); portletURL.setParameter("title", HtmlUtil.unescape(page.getTitle())); return portletURL.toString(); }
@Override public String getURL() { try { Portlet portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET); PortletURL basePortletURL = PortletURLFactoryUtil.create( request, PortletKeys.PORTLET_SHARING, themeDisplay.getPlid(), PortletRequest.RESOURCE_PHASE); StringBundler sb = new StringBundler(5); sb.append("javascript:Liferay.PortletSharing.showNetvibesInfo('"); sb.append(PortalUtil.getNetvibesURL(portlet, themeDisplay)); sb.append("', '"); sb.append(basePortletURL); sb.append("');"); return sb.toString(); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } return StringPool.BLANK; } }
protected PortletURL getRestoreURL( PortletRequest portletRequest, long classPK, boolean isContainerModel) throws PortalException, SystemException { String portletId = PortletKeys.MESSAGE_BOARDS; MBThread thread = MBThreadLocalServiceUtil.getThread(classPK); long plid = PortalUtil.getPlidFromPortletId(thread.getGroupId(), PortletKeys.MESSAGE_BOARDS); if (plid == LayoutConstants.DEFAULT_PLID) { portletId = PortletKeys.MESSAGE_BOARDS_ADMIN; plid = PortalUtil.getControlPanelPlid(portletRequest); } PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE); if (isContainerModel) { if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) { portletURL.setParameter("struts_action", "/message_boards/view"); } else { portletURL.setParameter("struts_action", "/message_boards_admin/view"); } } else { if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) { portletURL.setParameter("struts_action", "/message_boards/view_message"); } else { portletURL.setParameter("struts_action", "/message_boards_admin/view_message"); } } return portletURL; }
protected URLMenuItem getPortletTitleMenuItem( PortletRequest portletRequest, ThemeDisplay themeDisplay) { URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setIcon("icon-plus-sign-2"); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, BlogsPortletKeys.BLOGS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/blogs/edit_entry"); String currentURL = PortalUtil.getCurrentURL(portletRequest); portletURL.setParameter("redirect", currentURL); portletURL.setParameter("backURL", currentURL); urlMenuItem.setURL(portletURL.toString()); return urlMenuItem; }
@Override public String getOnClick() { PortletURL baseActionURL = PortletURLFactoryUtil.create( portletRequest, PortletConfigurationCSSPortletKeys.PORTLET_CONFIGURATION_CSS, themeDisplay.getPlid(), PortletRequest.ACTION_PHASE); PortletURL baseRenderURL = PortletURLFactoryUtil.create( portletRequest, PortletConfigurationCSSPortletKeys.PORTLET_CONFIGURATION_CSS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); PortletURL baseResourceURL = PortletURLFactoryUtil.create( portletRequest, PortletConfigurationCSSPortletKeys.PORTLET_CONFIGURATION_CSS, themeDisplay.getPlid(), PortletRequest.RESOURCE_PHASE); StringBundler sb = new StringBundler(9); sb.append("Liferay.Portlet.loadCSSEditor('"); sb.append(portletDisplay.getId()); sb.append("', '"); sb.append(baseActionURL); sb.append("', '"); sb.append(baseRenderURL); sb.append("', '"); sb.append(baseResourceURL); sb.append("'); return false;"); return sb.toString(); }
@ActionMapping(params = "action=dettaglio") public void actionDettaglio( ActionRequest aRequest, ActionResponse aResponse, Model model, @ModelAttribute("navigaProgetti") NavigaProgetti navigaProgetti, @RequestParam(value = "idProgettoDettaglio") String idProgettoDettaglio, @RequestParam(value = "currentAction") String currentAction, @RequestParam(required = false, value = "cercaPerKeyword") String cercaPerKeyword) { navigaProgetti.setIdProgetto(idProgettoDettaglio); LiferayPortletURL renderURL = createLiferayPortletURL(aRequest, paginaDettaglioProgetto, dettaglioProgettoInstanceId); renderURL.setParameter("idPj", idProgettoDettaglio); try { ThemeDisplay themeDisplay = (ThemeDisplay) aRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL returnURL = PortletURLFactoryUtil.create( aRequest, (String) aRequest.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE); returnURL.setWindowState(WindowState.NORMAL); returnURL.setPortletMode(PortletMode.VIEW); // returnURL.setParameter("jsonnavigaprogetti", // createJsonStringFromModelAttribute(navigaProgetti)); returnURL.setParameter("action", currentAction); if (!StringUtils.isEmpty(cercaPerKeyword)) { returnURL.setParameter("cercaPerKeyword", cercaPerKeyword); } renderURL.setParameter("returnUrl", returnURL.toString()); } catch (Exception e) { e.printStackTrace(); } try { aResponse.sendRedirect( HttpUtil.encodeParameters( renderURL.toString())); // + "&idPj="+navigaProgetti.getIdProgetto() ) ); return; } catch (Exception e) { e.printStackTrace(); } }
protected void sendLoginRedirect(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("struts_action", "/login/login_redirect"); response.sendRedirect(portletURL.toString()); }
@Override protected PortletURL getURLEditDetails( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws Exception { PortletURL portletURL = PortletURLFactoryUtil.create( liferayPortletRequest, getPortletId(), getLayout().getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/html/surveyactivity/admin/editquestions.jsp"); portletURL.setParameter("actionEditingDetails", StringPool.TRUE); portletURL.setParameter("resId", Long.toString(getLearningactivity().getActId())); return portletURL; }
protected PortletURL getKBArticleURL( long plid, String portletId, KBArticle kbArticle, HttpServletRequest request) throws Exception { long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey"); String mvcPath = null; String rootPortletId = PortletConstants.getRootPortletId(portletId); if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) { mvcPath = "/article/view_article.jsp"; } else if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) { mvcPath = "/section/view_article.jsp"; } PortletURL portletURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE); if (mvcPath != null) { portletURL.setParameter("mvcPath", mvcPath); } if ((kbArticle == null) || Validator.isNull(kbArticle.getUrlTitle())) { portletURL.setParameter("resourcePrimKey", String.valueOf(resourcePrimKey)); } else { portletURL.setParameter("urlTitle", kbArticle.getUrlTitle()); if (kbArticle.getKbFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbArticle.getKbFolderId()); portletURL.setParameter("kbFolderUrlTitle", String.valueOf(kbFolder.getUrlTitle())); } } portletURL.setPortletMode(PortletMode.VIEW); portletURL.setWindowState(LiferayWindowState.NORMAL); if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) { portletURL.setWindowState(LiferayWindowState.MAXIMIZED); } return portletURL; }
@Override public String getDLFolderControlPanelLink(PortletRequest portletRequest, long folderId) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, PortletKeys.DOCUMENT_LIBRARY, PortalUtil.getControlPanelPlid(themeDisplay.getCompanyId()), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/document_library/view"); portletURL.setParameter("folderId", String.valueOf(folderId)); return portletURL.toString(); }
protected void addPortletTitleAddCategoryMenuItem( List<MenuItem> menuItems, long categoryId, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { if (!containsPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId, ActionKeys.ADD_CATEGORY)) { return; } URLMenuItem urlMenuItem = new URLMenuItem(); String key = "category[message-board]"; if (categoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { key = "subcategory[message-board]"; } urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), key)); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_category"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("parentCategoryId", String.valueOf(categoryId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
public static String getMBControlPanelLink(PortletRequest portletRequest, long mbCategoryId) throws PortalException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, PortletKeys.MESSAGE_BOARDS_ADMIN, PortalUtil.getControlPanelPlid(themeDisplay.getCompanyId()), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/message_boards_admin/view"); portletURL.setParameter("mbCategoryId", String.valueOf(mbCategoryId)); return portletURL.toString(); }
@Override public PortletURL getURLEdit( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) throws Exception { HttpServletRequest request = liferayPortletRequest.getHttpServletRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletURL editPortletURL = PortletURLFactoryUtil.create( request, PortletKeys.MESSAGE_BOARDS, getControlPanelPlid(themeDisplay), PortletRequest.RENDER_PHASE); editPortletURL.setParameter("struts_action", "/message_boards/edit_discussion"); editPortletURL.setParameter("commentId", String.valueOf(_message.getMessageId())); return editPortletURL; }
@Override public String getURLEditWorkflowTask(long workflowTaskId, ServiceContext serviceContext) throws PortalException, SystemException { try { LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create( serviceContext.getRequest(), PortletKeys.MY_WORKFLOW_TASKS, PortalUtil.getControlPanelPlid(serviceContext.getCompanyId()), PortletRequest.RENDER_PHASE); liferayPortletURL.setControlPanelCategory("my"); liferayPortletURL.setParameter("struts_action", "/my_workflow_tasks/edit_workflow_task"); liferayPortletURL.setParameter("workflowTaskId", String.valueOf(workflowTaskId)); liferayPortletURL.setWindowState(WindowState.MAXIMIZED); return liferayPortletURL.toString(); } catch (WindowStateException wse) { throw new PortalException(wse); } }
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { if (!_processed) { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) renderRequest.getAttribute("javax.portlet.config"); _portletName = portletConfig.getPortletName(); PortletURL pURL = PortletURLFactoryUtil.create( renderRequest, _portletName + "_WAR_" + _portletName + "portlet", themeDisplay.getPlid(), PortletRequest.ACTION_PHASE); pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK); _portletURL = pURL.toString(); // read portlet config; PortletPreferences preferences = renderRequest.getPreferences(); String portletResource = ParamUtil.getString(renderRequest, "portletResource"); if (Validator.isNotNull(portletResource)) { try { preferences = PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portletResource); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } _proxyURL = preferences.getValue("url", ""); log.info("proxyurl=" + _proxyURL); defaultProxyRequest(); renderResponse.getWriter().print(_result); } else renderResponse.getWriter().print("processed"); }
@Override public String getURLViewInContext( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser(); long portletPlid = PortalUtil.getPlidFromPortletId(user.getGroupId(), true, "1_WAR_microblogsportlet"); PortletURL portletURL = PortletURLFactoryUtil.create( liferayPortletRequest, "1_WAR_microblogsportlet", portletPlid, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/microblogs/view.jsp"); long microblogsEntryId = _entry.getMicroblogsEntryId(); if (_entry.getReceiverMicroblogsEntryId() > 0) { microblogsEntryId = _entry.getReceiverMicroblogsEntryId(); } portletURL.setParameter("receiverMicroblogsEntryId", String.valueOf(microblogsEntryId)); return portletURL.toString(); } catch (Exception e) { } return null; }
private void getPortletInfo(ActionRequest actionRequest) { log.info("getPortletInfo"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest.getAttribute("javax.portlet.config"); _portletName = portletConfig.getPortletName(); PortletURL pURL = PortletURLFactoryUtil.create( actionRequest, _portletName + "_WAR_" + _portletName + "portlet", themeDisplay.getPlid(), PortletRequest.ACTION_PHASE); /*try { pURL.setWindowState(WindowState.NORMAL ); } catch (WindowStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }*/ pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK); _portletURL = pURL.toString(); // read portlet config; PortletPreferences preferences = actionRequest.getPreferences(); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)) { try { preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } _proxyURL = preferences.getValue("url", ""); } /*
protected void addPortletTitleAddMessageMenuItem( List<MenuItem> menuItems, long categoryId, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { if (!containsPermission( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId, ActionKeys.ADD_MESSAGE)) { return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel( LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "thread")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create( portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_message"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("mbCategoryId", String.valueOf(categoryId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
@Override public String getRestoreLink(PortletRequest portletRequest, long classPK) throws PortalException, SystemException { String portletId = PortletKeys.MESSAGE_BOARDS; MBThread thread = MBThreadLocalServiceUtil.getThread(classPK); long plid = PortalUtil.getPlidFromPortletId(thread.getGroupId(), PortletKeys.MESSAGE_BOARDS); if (plid == LayoutConstants.DEFAULT_PLID) { portletId = PortletKeys.MESSAGE_BOARDS_ADMIN; plid = PortalUtil.getControlPanelPlid(portletRequest); } PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/message_boards_admin/view"); portletURL.setParameter("mbCategoryId", String.valueOf(thread.getCategoryId())); return portletURL.toString(); }
public static String getURL( HttpServletRequest request, ThemeDisplay themeDisplay, AssetRendererFactory assetRendererFactory, AssetRenderer assetRenderer) throws Exception { long classPK = assetRenderer.getClassPK(); String className = assetRendererFactory.getClassName(); String portletId = PortletProviderUtil.getPortletId(className, PortletProvider.Action.VIEW); PortletURL portletURL = null; if (className.equals(BlogsEntry.class.getName())) { portletURL = PortletURLFactoryUtil.create( request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry"); portletURL.setParameter("entryId", String.valueOf(classPK)); } else if (className.equals(JournalArticle.class.getName())) { JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK); portletURL = PortletURLFactoryUtil.create( request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/journal_content/view"); portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId())); portletURL.setParameter("articleId", journalArticle.getArticleId()); } else if (className.equals(KBArticle.class.getName())) { portletURL = PortletURLFactoryUtil.create( request, PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/article/view_article.jsp"); portletURL.setParameter("resourcePrimKey", String.valueOf(classPK)); } else if (className.equals(MBMessage.class.getName())) { portletURL = PortletURLFactoryUtil.create( request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/message_boards/view_message"); portletURL.setParameter("messageId", String.valueOf(classPK)); } else if (className.equals(WikiPage.class.getName())) { WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK); portletURL = PortletURLFactoryUtil.create( request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/wiki/view"); portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId())); portletURL.setParameter("title", wikiPage.getTitle()); } String currentURL = PortalUtil.getCurrentURL(request); if (portletURL == null) { return currentURL; } portletURL.setWindowState(WindowState.MAXIMIZED); portletURL.setPortletMode(PortletMode.VIEW); portletURL.setParameter("returnToFullPageURL", currentURL); return portletURL.toString(); }
@Override public void processAction( ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletName = portletConfig.getPortletName(); if (!portletName.equals(PortletKeys.FAST_LOGIN)) { throw new PrincipalException(); } 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, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/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)) { jsonObject = updateIncompleteUser(actionRequest, actionResponse); writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof DuplicateUserEmailAddressException) { User user = UserLocalServiceUtil.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 CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactFirstNameException || e instanceof ContactFullNameException || e instanceof ContactLastNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof ReservedUserEmailAddressException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); PortalUtil.sendError(e, actionRequest, actionResponse); } } }
@Override public void processAction( ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.DELETE) || cmd.equals(Constants.DELETE_VERSIONS)) { deleteEntries(actionRequest, false); } else if (cmd.equals(Constants.EXPIRE)) { expireEntries(actionRequest); } else if (cmd.equals(Constants.MOVE)) { moveEntries(actionRequest); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteEntries(actionRequest, true); } String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (cmd.equals(Constants.DELETE_VERSIONS) && !ActionUtil.hasArticle(actionRequest)) { String referringPortletResource = ParamUtil.getString(actionRequest, "referringPortletResource"); if (Validator.isNotNull(referringPortletResource)) { setForward(actionRequest, "portlet.journal.asset.add_asset_redirect"); return; } else { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( actionRequest, portletConfig.getPortletName(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); redirect = portletURL.toString(); } } WindowState windowState = actionRequest.getWindowState(); if (!windowState.equals(LiferayWindowState.POP_UP)) { sendRedirect(actionRequest, actionResponse); } else if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } catch (Exception e) { if (e instanceof NoSuchArticleException || e instanceof NoSuchFolderException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.journal.error"); } else if (e instanceof DuplicateArticleIdException || e instanceof DuplicateFolderNameException || e instanceof NoSuchFolderException) { SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } }
public void markNotSpamWikiPages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] wikiPageIds = ParamUtil.getLongValues(actionRequest, "notSpamWikiPageIds"); List<String> wikiPageLinks = new ArrayList<>(); for (long wikiPageId : wikiPageIds) { WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(wikiPageId); WikiPage latestVersionWikiPage = AkismetUtil.getWikiPage( wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), false); String latestContent = null; if (latestVersionWikiPage != null) { latestContent = latestVersionWikiPage.getContent(); } WikiPage previousVersionWikiPage = AkismetUtil.getWikiPage( wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), true); String previousContent = null; if (previousVersionWikiPage != null) { previousContent = previousVersionWikiPage.getContent(); } // Selected version wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED); wikiPage.setSummary(StringPool.BLANK); wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage); // Latest version if ((latestContent != null) && ((previousContent == null) || latestContent.equals(previousContent))) { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); WikiPageLocalServiceUtil.revertPage( themeDisplay.getUserId(), wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), serviceContext); } else { StringBundler sb = new StringBundler(5); sb.append("<a href=\""); long plid = PortalUtil.getPlidFromPortletId(wikiPage.getGroupId(), WikiPortletKeys.WIKI); LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create( actionRequest, WikiPortletKeys.WIKI, plid, PortletRequest.RENDER_PHASE); WikiNode wikiNode = wikiPage.getNode(); liferayPortletURL.setParameter("struts_action", "/wiki/view"); liferayPortletURL.setParameter("nodeName", wikiNode.getName()); liferayPortletURL.setParameter("title", wikiPage.getTitle()); liferayPortletURL.setParameter("version", String.valueOf(wikiPage.getVersion())); sb.append(liferayPortletURL.toString()); sb.append("\" target=\"_blank\">"); sb.append(HtmlUtil.escape(wikiPage.getTitle())); sb.append("</a>"); wikiPageLinks.add(sb.toString()); } // Akismet if (AkismetUtil.isWikiEnabled(wikiPage.getCompanyId())) { AkismetUtil.submitHam(wikiPage); } } if (!wikiPageLinks.isEmpty()) { SessionMessages.add( actionRequest, "anotherUserHasMadeChangesToThesePages", StringUtil.merge(wikiPageLinks, "<br />")); addSuccessMessage(actionRequest, actionResponse); super.sendRedirect(actionRequest, actionResponse); } }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled( company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } 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"); } 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, themeDisplay.getPlid(), 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)) { 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); PortalUtil.sendError(e, actionRequest, actionResponse); } } }
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 = PortalUtil.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); } } 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(), themeDisplay.getPlid(), 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 = PortalUtil.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)); } actionResponse.sendRedirect(redirect); } } } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
private String getAssetViewURL( PortletRequest request, PortletResponse response, AssetEntry assetEntry, String keywords) { try { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletURL returnURL = PortletURLFactoryUtil.create( request, (String) request.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE); returnURL.setWindowState(WindowState.NORMAL); returnURL.setPortletMode(PortletMode.VIEW); returnURL.setParameter("action", "ricercaLibera"); returnURL.setParameter("cercaPerKeyword", keywords); PortletURL viewURL = null; String localHost = themeDisplay.getPortalURL(); List<Layout> layouts = null; layouts = LayoutLocalServiceUtil.getLayouts(themeDisplay.getLayout().getGroupId(), false); for (Layout layout : layouts) { String nodeNameRemoved = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay).replace(localHost, ""); // Viene ricercato l'URL esatto per la pagina successiva if (nodeNameRemoved.indexOf(paginaDettaglioContenuto) > 0) { viewURL = PortletURLFactoryUtil.create( request, assetPublisherPortletId, layout.getPlid(), PortletRequest.RENDER_PHASE); viewURL.setWindowState(WindowState.NORMAL); viewURL.setPortletMode(PortletMode.VIEW); viewURL.setParameter("action", "ricerca"); viewURL.setParameter("struts_action", "/asset_publisher/view_content"); // String currentURL = HttpUtil.addParameter(PortalUtil.getCurrentURL(request), "_" + // request.getAttribute(WebKeys.PORTLET_ID) + "_cercaPerKeyword", keywords); viewURL.setParameter("redirect", returnURL.toString()); viewURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); AssetRendererFactory assetRendererFactory = assetEntry.getAssetRendererFactory(); AssetRenderer assetRenderer = assetEntry.getAssetRenderer(); viewURL.setParameter("type", assetRendererFactory.getType()); if (Validator.isNotNull(assetRenderer.getUrlTitle())) { if (assetRenderer.getGroupId() != themeDisplay.getScopeGroupId()) { viewURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId())); } viewURL.setParameter("urlTitle", assetRenderer.getUrlTitle()); } break; } } return viewURL.toString(); } catch (Exception e) { e.printStackTrace(); } return null; }