List of usage examples for com.liferay.portal.kernel.struts LastPath toString
@Override
public String toString()
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 . java2 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;/* w w w . jav a2 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); } }