| 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.events.ActionException;
19 import com.liferay.portal.kernel.log.Log;
20 import com.liferay.portal.kernel.log.LogFactoryUtil;
21 import com.liferay.portal.kernel.util.PropsKeys;
22 import com.liferay.portal.kernel.util.StringPool;
23 import com.liferay.portal.kernel.util.Validator;
24 import com.liferay.portal.struts.LastPath;
25 import com.liferay.portal.util.PortalUtil;
26 import com.liferay.portal.util.PrefsPropsUtil;
27 import com.liferay.portal.util.WebKeys;
28
29 import java.util.HashMap;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import javax.servlet.http.HttpSession;
34
35 /**
36 * <a href="DefaultLogoutPageAction.java.html"><b><i>View Source</i></b></a>
37 *
38 * @author Jerry Niu
39 */
40 public class DefaultLogoutPageAction extends Action {
41
42 public void run(HttpServletRequest request, HttpServletResponse response)
43 throws ActionException {
44
45 try {
46 doRun(request, response);
47 }
48 catch (Exception e) {
49 throw new ActionException(e);
50 }
51 }
52
53 protected void doRun(
54 HttpServletRequest request, HttpServletResponse response)
55 throws Exception {
56
57 long companyId = PortalUtil.getCompanyId(request);
58
59 String path = PrefsPropsUtil.getString(
60 companyId, PropsKeys.DEFAULT_LOGOUT_PAGE_PATH);
61
62 if (_log.isInfoEnabled()) {
63 _log.info(
64 PropsKeys.DEFAULT_LOGOUT_PAGE_PATH + StringPool.EQUAL + path);
65 }
66
67 if (Validator.isNotNull(path)) {
68 LastPath lastPath = new LastPath(
69 StringPool.BLANK, path, new HashMap<String, String[]>());
70
71 HttpSession session = request.getSession();
72
73 session.setAttribute(WebKeys.LAST_PATH, lastPath);
74 }
75
76 // The commented code shows how you can programmaticaly set the user's
77 // logout page. You can modify this class to utilize a custom algorithm
78 // for forwarding a user to his logout page. See the references to this
79 // class in portal.properties.
80
81 /*Map<String, String[]> params = new HashMap<String, String[]>();
82
83 params.put("p_l_id", new String[] {"1806"});
84
85 LastPath lastPath = new LastPath("/c", "/portal/layout", params);
86
87 session.setAttribute(WebKeys.LAST_PATH, lastPath);*/
88 }
89
90 private static Log _log = LogFactoryUtil.getLog(
91 DefaultLogoutPageAction.class);
92
93 }