1
22
23 package com.liferay.portal.events;
24
25 import com.liferay.portal.kernel.events.Action;
26 import com.liferay.portal.kernel.events.ActionException;
27 import com.liferay.portal.model.Group;
28 import com.liferay.portal.model.Layout;
29 import com.liferay.portal.model.LayoutTypePortlet;
30 import com.liferay.portal.model.ReverseAjax;
31 import com.liferay.portal.service.GroupLocalServiceUtil;
32 import com.liferay.portal.service.LayoutLocalServiceUtil;
33 import com.liferay.portal.util.LiveUsers;
34 import com.liferay.portal.util.PortalUtil;
35 import com.liferay.portal.util.PropsValues;
36 import com.liferay.portal.util.WebKeys;
37 import com.liferay.portlet.messaging.util.MessagingUtil;
38
39 import java.util.Iterator;
40
41 import javax.servlet.http.HttpServletRequest;
42 import javax.servlet.http.HttpServletResponse;
43 import javax.servlet.http.HttpSession;
44
45 import org.apache.commons.logging.Log;
46 import org.apache.commons.logging.LogFactory;
47 import org.apache.struts.Globals;
48
49
55 public class LoginPostAction extends Action {
56
57 public void run(HttpServletRequest req, HttpServletResponse res)
58 throws ActionException {
59
60 try {
61 if (_log.isDebugEnabled()) {
62 _log.debug("Running " + req.getRemoteUser());
63 }
64
65 HttpSession ses = req.getSession();
66
67 long companyId = PortalUtil.getCompanyId(req);
68 long userId = PortalUtil.getUserId(req);
69
70 if (PropsValues.REVERSE_AJAX_ENABLED) {
71 ses.setAttribute(WebKeys.REVERSE_AJAX, new ReverseAjax());
72 }
73
74 MessagingUtil.createXMPPConnection(ses, userId);
75
76 LiveUsers.signIn(req);
77
78 if (!PropsValues.LAYOUT_REMEMBER_SESSION_WINDOW_STATE_MAXIMIZED) {
79 Group group = GroupLocalServiceUtil.getUserGroup(
80 companyId, userId);
81
82 Iterator itr = LayoutLocalServiceUtil.getLayouts(
83 group.getGroupId(), true).iterator();
84
85 while (itr.hasNext()) {
86 Layout layout = (Layout)itr.next();
87
88 LayoutTypePortlet layoutType =
89 (LayoutTypePortlet)layout.getLayoutType();
90
91 if (layoutType.hasStateMax()) {
92
93
96 layoutType.resetStates();
97
98
101 layoutType.resetModes();
102
103 LayoutLocalServiceUtil.updateLayout(
104 layout.getGroupId(), layout.isPrivateLayout(),
105 layout.getLayoutId(), layout.getTypeSettings());
106 }
107 }
108 }
109
110
112 ses.removeAttribute(Globals.LOCALE_KEY);
113 }
114 catch (Exception e) {
115 throw new ActionException(e);
116 }
117 }
118
119 private static Log _log = LogFactory.getLog(LoginPostAction.class);
120
121 }