Example usage for com.liferay.portal.kernel.util PropsKeys LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING

List of usage examples for com.liferay.portal.kernel.util PropsKeys LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING.

Prototype

String LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING

To view the source code for com.liferay.portal.kernel.util PropsKeys LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING.

Click Source Link

Usage

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.
 *//* ww w  .j ava  2s  .  com*/
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: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());
        }/* w  ww  .j a va2 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;
}