DefaultLandingPageAction.java |
1 /** 2 * Copyright (c) 2000-2009 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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 * SOFTWARE. 18 */ 19 20 package com.liferay.portal.events; 21 22 import com.liferay.portal.kernel.events.Action; 23 import com.liferay.portal.kernel.log.Log; 24 import com.liferay.portal.kernel.log.LogFactoryUtil; 25 import com.liferay.portal.kernel.util.StringPool; 26 import com.liferay.portal.kernel.util.Validator; 27 import com.liferay.portal.struts.LastPath; 28 import com.liferay.portal.util.PropsKeys; 29 import com.liferay.portal.util.PropsValues; 30 import com.liferay.portal.util.WebKeys; 31 32 import java.util.HashMap; 33 34 import javax.servlet.http.HttpServletRequest; 35 import javax.servlet.http.HttpServletResponse; 36 import javax.servlet.http.HttpSession; 37 38 /** 39 * <a href="DefaultLandingPageAction.java.html"><b><i>View Source</i></b></a> 40 * 41 * @author Michael Young 42 * 43 */ 44 public class DefaultLandingPageAction extends Action { 45 46 public void run(HttpServletRequest request, HttpServletResponse response) { 47 String path = PropsValues.DEFAULT_LANDING_PAGE_PATH; 48 49 if (_log.isInfoEnabled()) { 50 _log.info( 51 PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path); 52 } 53 54 if (Validator.isNotNull(path)) { 55 LastPath lastPath = new LastPath( 56 StringPool.BLANK, path, new HashMap<String, String[]>()); 57 58 HttpSession session = request.getSession(); 59 60 session.setAttribute(WebKeys.LAST_PATH, lastPath); 61 } 62 63 // The commented code shows how you can programmaticaly set the user's 64 // landing page. You can modify this class to utilize a custom algorithm 65 // for forwarding a user to his landing page. See the references to this 66 // class in portal.properties. 67 68 /*Map<String, String[]> params = new HashMap<String, String[]>(); 69 70 params.put("p_l_id", new String[] {"1806"}); 71 72 LastPath lastPath = new LastPath("/c", "/portal/layout", params); 73 74 ses.setAttribute(WebKeys.LAST_PATH, lastPath);*/ 75 } 76 77 private static Log _log = 78 LogFactoryUtil.getLog(DefaultLandingPageAction.class); 79 80 }