List of usage examples for com.liferay.portal.kernel.struts LastPath LastPath
public LastPath(String contextPath, String path)
From source file:com.liferay.so.hook.events.SOUserDefaultLandingPageAction.java
License:Open Source License
protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception { String path = PortletPropsValues.SO_USER_DEFAULT_LANDING_PAGE_PATH; if (Validator.isNull(path)) { return;// w ww . j a va2s. c om } HttpSession session = request.getSession(); User user = (User) session.getAttribute(WebKeys.USER); if ((user == null) || !SocialOfficeServiceUtil.isSocialOfficeGroup(user.getGroupId())) { return; } if (path.contains("${liferay:screenName}") || path.contains("${liferay:userId}")) { path = StringUtil.replace(path, new String[] { "${liferay:screenName}", "${liferay:userId}" }, new String[] { HtmlUtil.escapeURL(user.getScreenName()), String.valueOf(user.getUserId()) }); } LastPath lastPath = new LastPath(StringPool.BLANK, path); session.setAttribute(WebKeys.LAST_PATH, lastPath); }
From source file:com.stoxx.logout.post.action.LogoutPostAction.java
License:Open Source License
@Override public void run(HttpServletRequest request, HttpServletResponse response) { HttpSession session = null;//from w w w .j a v a 2 s . com LastPath lastPathnew = null; try { session = request.getSession(); String contextPath = "/web"; lastPathnew = new LastPath(contextPath, "/stoxxcom/home"); User _user = PortalUtil.getUser(request); if (Validator.isNotNull(_user)) { List<UserGroup> userGroups = UserGroupLocalServiceUtil.getUserUserGroups(_user.getUserId()); _log.info( ">>>>>>>>> logout url " + request.getRequestURL() + " user is " + _user.getEmailAddress()); String lastPathAction = (String) request.getSession().getAttribute("lasPathString"); _log.info("custom last path" + lastPathAction); Object lastPath = request.getSession().getAttribute("LAST_PATH"); if (Validator.isNotNull(lastPath)) { _log.info("The last path is " + lastPath.toString()); } else { _log.info("Last Path is null"); } for (UserGroup userGroup : userGroups) { _log.info("the usergroup names is " + userGroup.getName()); if (userGroup.getName() .equalsIgnoreCase(PrefsPropsUtil.getString("stoxx.usergroup.customer"))) { lastPathnew = new LastPath(contextPath, "/stoxxcom/home"); break; } else if (userGroup.getName() .equalsIgnoreCase(PrefsPropsUtil.getString("stoxx.usergroup.translator")) || userGroup.getName() .equalsIgnoreCase(PrefsPropsUtil.getString("stoxx.usergroup.staff.user"))) { lastPathnew = new LastPath(contextPath, "/stoxxnet/login"); break; } else if (userGroup.getName() .equalsIgnoreCase(PrefsPropsUtil.getString("dax.usergroup.user"))) { lastPathnew = new LastPath(contextPath, "/dax/login"); break; } else { lastPathnew = new LastPath(contextPath, "/stoxxcom/home"); } } } session.setAttribute(WebKeys.LAST_PATH, lastPathnew); } catch (Exception e) { _log.info(e.getMessage(), e); } }
From source file:org.corak.liferay.portal.events.CustomLoginPostAction.java
License:Open Source License
/** * Will be fired for each Login Event and redirects the user to her or his landing page. *///from w ww . j a va 2 s.c o m public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { try { debug("CustomLoginPostAction for User: " + request.getRemoteUser()); HttpSession session = request.getSession(); User user = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request)); LastPath lastPath = null; Group firstUserGroup = null; Long companyId = PortalUtil.getCompanyId(request); //Role roleUser = RoleLocalServiceUtil.getRole(companyId, "User"); Role rolePowerUser = RoleLocalServiceUtil.getRole(companyId, "Power User"); Role roleAdministrator = RoleLocalServiceUtil.getRole(companyId, "Administrator"); // First look for User's Private Pages if (!(UserLocalServiceUtil.hasRoleUser(rolePowerUser.getRoleId(), user.getUserId()) || UserLocalServiceUtil.hasRoleUser(roleAdministrator.getRoleId(), user.getUserId()))) { // Redirect to User's Private Pages lastPath = new LastPath(request.getContextPath(), "/web/guest/registration"); } else { lastPath = null; if (lastPath == null) { // Look for Organizations debug("Looking for associated Organizations"); List<Organization> organizations = user.getOrganizations(); for (Organization organization : organizations) { Group group = organization.getGroup(); debug("Organization: " + group.getName() + ", friendlyUrl: " + group.getFriendlyURL()); if (firstUserGroup == null) firstUserGroup = group; if (group.hasPrivateLayouts()) lastPath = new LastPath(request.getContextPath(), PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING) + group.getFriendlyURL()); if (lastPath != null) break; } } if (lastPath == null) { // Look for Communities debug("Looking for associated Communities"); List<Group> groups = user.getGroups(); for (Group group : groups) { debug("Community: " + group.getName() + ", friendlyUrl: " + group.getFriendlyURL()); //if(group.getName().equals("Guest")){ //lastPath = new LastPath(request.getContextPath(), "/web/guest/workflow"); // break; //} //if(firstUserGroup == null) firstUserGroup = group; if (group.hasPrivateLayouts() && (!group.getName().equals("Guest"))) lastPath = new LastPath(request.getContextPath(), PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING) + group.getFriendlyURL()); if (lastPath != null) break; } if (firstUserGroup.getName().equals("Guest")) { lastPath = new LastPath(request.getContextPath(), "/web/guest/workflow"); } } if (lastPath == null && firstUserGroup != null) { // Redirect to the Public Pages of the first found // Community/Organization lastPath = new LastPath(request.getContextPath(), PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING) + firstUserGroup.getFriendlyURL()); } /*if((lastPath == null)&&(UserLocalServiceUtil.hasRoleUser(rolePowerUser.getRoleId(), user.getUserId()) || UserLocalServiceUtil.hasRoleUser(roleAdministrator.getRoleId(), user.getUserId()))) { // Redirect to User's Private Pages lastPath = new LastPath(request.getContextPath(), "/web/guest/workflow"); }*/ } if (lastPath != null) { debug("lastPath = " + lastPath.toString()); session.setAttribute(WebKeys.LAST_PATH, lastPath); } } catch (Exception e) { throw new ActionException(e); } }
From source file:org.lsp.liferay.portlet.advertising.events.AdvertisingLandingPageAction.java
License:Open Source License
public void run(HttpServletRequest request, HttpServletResponse response) { long userId = PortalUtil.getUserId(request); long companyId = PortalUtil.getCompanyId(request); String path;//from www . j a va 2 s . co m try { path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH); if (_log.isDebugEnabled()) { _log.debug(PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path); } long campaignIdToDisplay = CampaignLocalServiceUtil.getCampaignIdToDisplay(companyId, userId); _log.debug("Redirecting User to: " + path); LastPath lastPath = new LastPath(request.getContextPath(), path); if (_log.isDebugEnabled()) { _log.debug("lastPath = " + lastPath.toString()); } HttpSession session = request.getSession(); session.setAttribute(WebKeys.LAST_PATH, lastPath); if (campaignIdToDisplay > 0) { session.setAttribute(CampaignConstants.CAMPAIGN_HEADER, CampaignLocalServiceUtil.getCampaign(campaignIdToDisplay).getJournalArticlePrimaryKey()); CampaignLogLocalServiceUtil.markDisplayed(campaignIdToDisplay, userId); } } catch (SystemException e) { _log.error(e.getMessage(), e); } catch (PortalException e) { _log.error(e.getMessage(), e); } }
From source file:org.opencps.hook.events.DefaultLandingPageAction.java
License:Open Source License
protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); User user = (User) session.getAttribute(org.opencps.util.WebKeys.USER); long companyId = PortalUtil.getCompanyId(request); String path = StringPool.BLANK; for (UserGroup userGroup : user.getUserGroups()) { if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_CITIZEN)) { path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId, "default.landing.page.path.citizen"); } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_BUSINESS)) { path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId, "default.landing.page.path.business"); } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_EMPLOYEE)) { path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId, "default.landing.page.path.employee"); } else {/* w w w .j a v a 2 s . c o m*/ path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH); } } if (_log.isInfoEnabled()) { _log.info("Pathhh" + PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path); } if (Validator.isNull(path)) { return; } if (path.contains("${liferay:screenName}") || path.contains("${liferay:userId}")) { if (user == null) { return; } path = StringUtil.replace(path, new String[] { "${liferay:screenName}", "${liferay:userId}" }, new String[] { HtmlUtil.escapeURL(user.getScreenName()), String.valueOf(user.getUserId()) }); } LastPath lastPath = new LastPath(StringPool.BLANK, path); session.setAttribute(org.opencps.util.WebKeys.LAST_PATH, lastPath); }
From source file:se.vgregion.userassociations.hook.UserCommunityAction.java
License:Open Source License
private LastPath computeLastPath(String contextPath, User user) throws PortalException, SystemException { List<Group> groups = user.getGroups(); Group vgregion = lookupVgregion(groups); if (vgregion != null) { if (vgregion.hasPrivateLayouts()) { return new LastPath(contextPath, PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING) + vgregion.getFriendlyURL()); }/*from ww w .ja v a 2 s .co m*/ } else { for (Group group : groups) { if (group.hasPrivateLayouts()) { return new LastPath(contextPath, PropsUtil.get(PropsKeys.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING) + group.getFriendlyURL()); } } } return null; }