2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
23 package com.liferay.portal.events;
\r
25 import java.util.HashMap;
\r
26 import java.util.Map;
\r
28 import javax.servlet.http.HttpServletRequest;
\r
29 import javax.servlet.http.HttpServletResponse;
\r
30 import javax.servlet.http.HttpSession;
\r
32 import com.liferay.portal.kernel.events.Action;
\r
33 import com.liferay.portal.kernel.log.Log;
\r
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
\r
35 import com.liferay.portal.kernel.struts.LastPath;
\r
36 import com.liferay.portal.kernel.util.PropsKeys;
\r
37 import com.liferay.portal.kernel.util.StringPool;
\r
38 import com.liferay.portal.kernel.util.Validator;
\r
39 import com.liferay.portal.model.User;
\r
40 import com.liferay.portal.util.PortalUtil;
\r
41 import com.liferay.portal.util.PropsValues;
\r
42 import com.liferay.portal.util.WebKeys;
\r
43 import com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil;
\r
46 * <a href="DefaultLandingPageAction.java.html"><b><i>View Source</i></b></a>
\r
48 * @author Michael Young
\r
51 public class ENTLandingPageAction extends Action {
\r
53 public void run(HttpServletRequest request, HttpServletResponse response) {
\r
54 String path = PropsValues.DEFAULT_LANDING_PAGE_PATH;
\r
56 if (_log.isInfoEnabled()) {
\r
58 PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
\r
61 if (Validator.isNotNull(path)) {
\r
62 LastPath lastPath = new LastPath(
\r
63 StringPool.BLANK, path, new HashMap<String, String[]>());
\r
65 HttpSession session = request.getSession();
\r
66 session.setAttribute(WebKeys.LAST_PATH, lastPath);
\r
69 // The commented code shows how you can programmaticaly set the user's
\r
70 // landing page. You can modify this class to utilize a custom algorithm
\r
71 // for forwarding a user to his landing page. See the references to this
\r
72 // class in portal.properties.
\r
74 Map<String, String[]> params = new HashMap<String, String[]>();
\r
77 HttpSession session = request.getSession();
\r
80 user = PortalUtil.getUser(request);
\r
81 } catch (Exception e) {
\r
82 e.printStackTrace();
\r
84 LastPath lastPath = null;
\r
85 if (user.isAgreedToTermsOfUse() && !user.isPasswordReset()){
\r
86 String defaultPageLanding = ENTMainUtilsLocalServiceUtil.getLoginDefaultPageLanding(user.getCompanyId());
\r
87 lastPath = new LastPath(StringPool.BLANK, "/user/"+ user.getScreenName() + defaultPageLanding, params);
\r
89 session.setAttribute(WebKeys.LAST_PATH, lastPath);
\r
94 private static Log _log =
\r
95 LogFactoryUtil.getLog(ENTLandingPageAction.class);
\r