1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.events;
16  
17  import com.liferay.portal.kernel.events.Action;
18  import com.liferay.portal.kernel.log.Log;
19  import com.liferay.portal.kernel.log.LogFactoryUtil;
20  import com.liferay.portal.kernel.util.PropsKeys;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.kernel.util.Validator;
23  import com.liferay.portal.struts.LastPath;
24  import com.liferay.portal.util.PropsValues;
25  import com.liferay.portal.util.WebKeys;
26  
27  import java.util.HashMap;
28  
29  import javax.servlet.http.HttpServletRequest;
30  import javax.servlet.http.HttpServletResponse;
31  import javax.servlet.http.HttpSession;
32  
33  /**
34   * <a href="DefaultLandingPageAction.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Michael Young
37   */
38  public class DefaultLandingPageAction extends Action {
39  
40      public void run(HttpServletRequest request, HttpServletResponse response) {
41          String path = PropsValues.DEFAULT_LANDING_PAGE_PATH;
42  
43          if (_log.isInfoEnabled()) {
44              _log.info(
45                  PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
46          }
47  
48          if (Validator.isNotNull(path)) {
49              LastPath lastPath = new LastPath(
50                  StringPool.BLANK, path, new HashMap<String, String[]>());
51  
52              HttpSession session = request.getSession();
53  
54              session.setAttribute(WebKeys.LAST_PATH, lastPath);
55          }
56  
57          // The commented code shows how you can programmaticaly set the user's
58          // landing page. You can modify this class to utilize a custom algorithm
59          // for forwarding a user to his landing page. See the references to this
60          // class in portal.properties.
61  
62          /*Map<String, String[]> params = new HashMap<String, String[]>();
63  
64          params.put("p_l_id", new String[] {"1806"});
65  
66          LastPath lastPath = new LastPath("/c", "/portal/layout", params);
67  
68          ses.setAttribute(WebKeys.LAST_PATH, lastPath);*/
69      }
70  
71      private static Log _log = LogFactoryUtil.getLog(
72          DefaultLandingPageAction.class);
73  
74  }