| DefaultLogoutPageAction.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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="DefaultLogoutPageAction.java.html"><b><i>View Source</i></b></a>
35 *
36 * @author Jerry Niu
37 */
38 public class DefaultLogoutPageAction extends Action {
39
40 public void run(HttpServletRequest request, HttpServletResponse response) {
41 String path = PropsValues.DEFAULT_LOGOUT_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 // logout page. You can modify this class to utilize a custom algorithm
59 // for forwarding a user to his logout 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 DefaultLogoutPageAction.class);
73
74 }