Custom Default Landing Page for UMP 2.5.2 liferay 6 Using Communities

Discussion created by Jarrod on Dec 15, 2011
Latest reply on Oct 31, 2014 by DCAlmeida


I have created a custom .class file for use with auto redirecting user to their respective Community instead of web/guest as defaulted. There is a setting for this by default but it is system wide. This will take each user and get the communities they are part of (post login) and the class file will then change the default landing page for the session to their community. I used this method instead of private/public pages per user to keep our UMP clean and have minimal LARs.


Attached "NimsoftUmpLandingPage.class" file goes in this directory on the UMP server “C:\Program Files (x86)\Nimsoft\probes\service\wasp\webapps\ROOT\WEB-INF\classes”. Also Edit the login.events.post= section in the portal-ext.properties file and make it look like the below: “login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.DefaultLandingPageAction,NimsoftUmpLandingPage,com.firehunter.ump.auth.LoginAction”. 


Restart Wasp.


Java Code for the Class, if modification is needed use NetBeans:




* @author jhinson



import com.liferay.portal.SystemException;

import com.liferay.portal.kernel.events.Action;

import com.liferay.portal.kernel.exception.PortalException;

import com.liferay.portal.kernel.log.Log;

import com.liferay.portal.model.GroupConstants;

import com.liferay.portal.kernel.log.LogFactoryUtil;

import com.liferay.portal.kernel.util.StringPool;

import com.liferay.portal.model.Group;

import com.liferay.portal.util.WebKeys;

import com.liferay.portal.model.User;

import com.liferay.portal.service.GroupLocalServiceUtil;

import com.liferay.portal.struts.LastPath;

import com.liferay.portal.util.PortalUtil;

import com.liferay.portal.util.PropsKeys;

import com.liferay.portal.util.PropsValues;

import java.util.HashMap;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;




public class NimsoftUmpLandingPage extends Action {


//This Runs the Community Loop and changes the landing Page


        public void run(HttpServletRequest request, HttpServletResponse response) {

        String path = PropsValues.DEFAULT_LANDING_PAGE_PATH;


        if (_log.isInfoEnabled()) {


                PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);



        HttpSession session = request.getSession();

        Long userId = null;

        User user = null;

        String forwardURL = null;

        Group group = null;

        if( session != null ){

            userId = PortalUtil.getUserId(request);



            //Get list of all groups to check for community

            for (Group g : GroupLocalServiceUtil.getGroups(0, GroupLocalServiceUtil.getGroupsCount())) {

            boolean ismycommunity = false;

            ismycommunity = isMember(userId.longValue(), g);

               if (ismycommunity) {

                    forwardURL = "/group" + g.getFriendlyURL();



            user = PortalUtil.getUser(request);

        }catch(Exception e){


        Map<String, String[]> params = new HashMap<String, String[]>();

        params.put("p_l_id", new String[] {"1806"});

        LastPath lastPath = new LastPath(StringPool.BLANK, forwardURL, params);

        session.setAttribute(WebKeys.LAST_PATH, lastPath);




// This Function Returns True If the Community is valid for user

public static boolean isMember(final long userId, final Group group) throws PortalException, com.liferay.portal.kernel.exception.SystemException {

    try {

        if (group.isCommunity() && ! group.getName().equals("Control Panel") && ! group.getName().equals("Guest")) {

            if (group.getType() != GroupConstants.TYPE_COMMUNITY_OPEN) {

                for (Group g : GroupLocalServiceUtil.getUserGroups(userId)) {

                    if (g.getGroupId() == group.getGroupId()) {

                        return true;





    } catch (SystemException e) {




    return false;



    private static Log _log =