001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.events;
022:
023: import com.liferay.portal.kernel.events.Action;
024: import com.liferay.portal.kernel.events.ActionException;
025: import com.liferay.portal.model.Group;
026: import com.liferay.portal.model.Layout;
027: import com.liferay.portal.model.LayoutTypePortlet;
028: import com.liferay.portal.model.ReverseAjax;
029: import com.liferay.portal.service.GroupLocalServiceUtil;
030: import com.liferay.portal.service.LayoutLocalServiceUtil;
031: import com.liferay.portal.util.LiveUsers;
032: import com.liferay.portal.util.PortalUtil;
033: import com.liferay.portal.util.PropsValues;
034: import com.liferay.portal.util.WebKeys;
035: import com.liferay.portlet.messaging.util.MessagingUtil;
036:
037: import java.util.Iterator;
038:
039: import javax.servlet.http.HttpServletRequest;
040: import javax.servlet.http.HttpServletResponse;
041: import javax.servlet.http.HttpSession;
042:
043: import org.apache.commons.logging.Log;
044: import org.apache.commons.logging.LogFactory;
045: import org.apache.struts.Globals;
046:
047: /**
048: * <a href="LoginPostAction.java.html"><b><i>View Source</i></b></a>
049: *
050: * @author Brian Wing Shun Chan
051: *
052: */
053: public class LoginPostAction extends Action {
054:
055: public void run(HttpServletRequest req, HttpServletResponse res)
056: throws ActionException {
057:
058: try {
059: if (_log.isDebugEnabled()) {
060: _log.debug("Running " + req.getRemoteUser());
061: }
062:
063: HttpSession ses = req.getSession();
064:
065: long companyId = PortalUtil.getCompanyId(req);
066: long userId = PortalUtil.getUserId(req);
067:
068: if (PropsValues.REVERSE_AJAX_ENABLED) {
069: ses.setAttribute(WebKeys.REVERSE_AJAX,
070: new ReverseAjax());
071: }
072:
073: MessagingUtil.createXMPPConnection(ses, userId);
074:
075: LiveUsers.signIn(req);
076:
077: if (!PropsValues.LAYOUT_REMEMBER_SESSION_WINDOW_STATE_MAXIMIZED) {
078: Group group = GroupLocalServiceUtil.getUserGroup(
079: companyId, userId);
080:
081: Iterator itr = LayoutLocalServiceUtil.getLayouts(
082: group.getGroupId(), true).iterator();
083:
084: while (itr.hasNext()) {
085: Layout layout = (Layout) itr.next();
086:
087: LayoutTypePortlet layoutType = (LayoutTypePortlet) layout
088: .getLayoutType();
089:
090: if (layoutType.hasStateMax()) {
091:
092: // Set the window state to normal for the maximized
093: // portlet
094:
095: layoutType.resetStates();
096:
097: // Set the portlet mode to view because other modes may
098: // require a maximized window state
099:
100: layoutType.resetModes();
101:
102: LayoutLocalServiceUtil.updateLayout(layout
103: .getGroupId(),
104: layout.isPrivateLayout(), layout
105: .getLayoutId(), layout
106: .getTypeSettings());
107: }
108: }
109: }
110:
111: // Reset the locale
112:
113: ses.removeAttribute(Globals.LOCALE_KEY);
114: } catch (Exception e) {
115: throw new ActionException(e);
116: }
117: }
118:
119: private static Log _log = LogFactory.getLog(LoginPostAction.class);
120:
121: }
|