001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/user/UserModuleProcessor.java,v 1.169 2008/01/24 03:42:36 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.169 $
005: * $Date: 2008/01/24 03:42:36 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: * @author: Mai Nguyen
040: */
041: package com.mvnforum.user;
042:
043: import java.io.IOException;
044: import java.util.Locale;
045:
046: import javax.servlet.ServletContext;
047: import javax.servlet.ServletException;
048: import javax.servlet.http.*;
049:
050: import net.myvietnam.mvncore.MVNCoreConfig;
051: import net.myvietnam.mvncore.exception.*;
052: import net.myvietnam.mvncore.filter.DisableHtmlTagFilter;
053: import net.myvietnam.mvncore.mvnframework.URLMap;
054: import net.myvietnam.mvncore.util.*;
055: import net.myvietnam.mvncore.web.GenericRequest;
056: import net.myvietnam.mvncore.web.GenericResponse;
057: import net.myvietnam.mvncore.web.impl.GenericRequestServletImpl;
058: import net.myvietnam.mvncore.web.impl.GenericResponseServletImpl;
059:
060: import org.apache.commons.logging.Log;
061: import org.apache.commons.logging.LogFactory;
062:
063: import com.mvnforum.*;
064: import com.mvnforum.auth.*;
065: import com.mvnforum.common.MVNCaptchaService;
066: import com.mvnforum.common.OnlineUserUtil;
067: import com.mvnforum.service.ModuleProcessor;
068:
069: public class UserModuleProcessor implements ModuleProcessor {
070:
071: private static Log log = LogFactory
072: .getLog(UserModuleProcessor.class);
073: private static int count;
074:
075: protected final String ORIGINAL_REQUEST = "mvnforum.user.OriginalRequest";
076:
077: private HttpServlet mainServlet = null;
078: protected ServletContext servletContext = null;
079:
080: protected OnlineUserManager onlineUserManager = OnlineUserManager
081: .getInstance();
082: protected UserModuleURLMapHandler urlMapHandler = new UserModuleURLMapHandler();
083:
084: private ForumWebHandler forumWebHandler = new ForumWebHandler();
085: private ThreadWebHandler threadWebHandler = new ThreadWebHandler();
086: private PostWebHandler postWebHandler = new PostWebHandler();
087: protected AttachmentWebHandler attachmentWebHandler = new AttachmentWebHandler();
088: private MemberWebHandler memberWebHandler = new MemberWebHandler();
089: private WatchWebHandler watchWebHandler = new WatchWebHandler();
090: private FavoriteThreadWebHandler favoriteThreadWebHandler = new FavoriteThreadWebHandler();
091: private MessageWebHandler messageWebHandler = new MessageWebHandler();
092: private PmAttachmentWebHandler pmAttachmentWebHandler = new PmAttachmentWebHandler();
093: private MessageFolderWebHandler messageFolderWebHandler = new MessageFolderWebHandler();
094: private MailWebHandler mailWebHandler = new MailWebHandler();
095:
096: public UserModuleProcessor() {
097: count++;
098: AssertionUtil.doAssert(count == 1,
099: "Assertion: Must have only one instance.");
100: }
101:
102: public void setServlet(HttpServlet servlet) {
103: mainServlet = servlet;
104: servletContext = servlet.getServletContext();
105: }
106:
107: public String process(HttpServletRequest request,
108: HttpServletResponse response) throws IOException,
109: ServletException {
110:
111: String requestURI = StringUtil.getEmptyStringIfNull(request
112: .getPathInfo());
113: String responseURI = null;
114: OnlineUser onlineUser = null;
115:
116: //TODO : [POLL] check here
117: if (requestURI == null || requestURI.length() == 0) {
118: requestURI = ParamUtil.getParameter(request, "nameOfURI");
119: }
120:
121: long start = 0;
122: if (log.isDebugEnabled()) {
123: start = System.currentTimeMillis();
124: log.debug("UserModuleProcessor : requestURI = "
125: + requestURI);
126: }
127:
128: GenericRequest genericRequest = new GenericRequestServletImpl(
129: request, servletContext);
130: GenericResponse genericResponse = new GenericResponseServletImpl(
131: response);
132:
133: // step 1: some command need to be processed before we do the URI mapping (of the MODAL)
134: // MODAL processing
135: try {
136: // @todo could throw Exception, so onlineUser will be null, caused NPE later
137: onlineUser = onlineUserManager
138: .getOnlineUser(genericRequest);
139: onlineUser.updateNewMessageCount(false);
140: if (requestURI.equals("/index")) {
141: if (MVNForumConfig.getEnablePortalLikeIndexPage()) {
142: forumWebHandler.prepareListIndex(genericRequest,
143: genericResponse, requestURI);//no permission
144: } else {
145: forumWebHandler.prepareList(genericRequest,
146: genericResponse, requestURI);//no permission
147: }
148: // change this page;
149: } else if (requestURI.equals("/listforums")) {
150: forumWebHandler.prepareList(genericRequest,
151: genericResponse, requestURI);//no permission
152: } else if (requestURI.equals("/listthreads")) {
153: threadWebHandler.prepareList_limit(genericRequest,
154: genericResponse, requestURI);
155: } else if (requestURI.equals("/listunansweredthreads")) {
156: threadWebHandler.prepareListUnansweredThreads(
157: genericRequest, genericResponse);
158: } else if (requestURI.equals("/listrecentthreads")) {
159: threadWebHandler.prepareListRecentThreads_limit(
160: genericRequest, genericResponse);//no permission
161: } else if (requestURI.equals("/viewthread")) {
162: postWebHandler.prepareViewThread(genericRequest,
163: genericResponse, requestURI);
164: } else if (requestURI.equals("/printthread")) {
165: postWebHandler.prepareViewThread(genericRequest,
166: genericResponse, requestURI);
167:
168: } else if (requestURI.equals("/splitthread")) {
169: threadWebHandler.prepareSplit(genericRequest,
170: genericResponse);
171: } else if (requestURI.equals("/splitthreadprocess")) {
172: threadWebHandler.processSplit(genericRequest);
173:
174: } else if (requestURI.equals("/deletethread")) {
175: threadWebHandler.prepareDelete(genericRequest,
176: genericResponse);
177: } else if (requestURI.equals("/deletethreadprocess")) {
178: threadWebHandler.processDelete(genericRequest);
179: threadWebHandler.deleteSuccessForRender(genericRequest,
180: genericResponse);
181: } else if (requestURI.equals("/movethread")) {
182: threadWebHandler.prepareMoveThread(genericRequest,
183: genericResponse);
184: } else if (requestURI.equals("/movethreadprocess")) {
185: threadWebHandler.processMoveThread(genericRequest);
186: } else if (requestURI.equals("/editthreadstatus")) {
187: threadWebHandler.prepareEditThreadStatus(
188: genericRequest, genericResponse);
189: } else if (requestURI.equals("/editthreadstatusprocess")) {
190: threadWebHandler
191: .processEditThreadStatus(genericRequest);
192: } else if (requestURI.equals("/editthreadtype")) {
193: threadWebHandler.prepareEditThreadType(genericRequest,
194: genericResponse);
195: } else if (requestURI.equals("/editthreadtypeprocess")) {
196: threadWebHandler.processEditThreadType(genericRequest);
197:
198: } else if (requestURI.equals("/modcp")) {
199: threadWebHandler.prepareModerationControlPanel(
200: genericRequest, genericResponse);
201: } else if (requestURI.equals("/listrecentpendingthreads")) {
202: threadWebHandler
203: .prepareListRecentDisabledThreads_limit(genericRequest);
204: } else if (requestURI
205: .equals("/listthreadswithpendingposts")) {
206: threadWebHandler
207: .prepareListEnableThreadsWithPendingPosts_inForum_limit(genericRequest);
208: } else if (requestURI
209: .equals("/listrecentthreadswithpendingposts")) {
210: threadWebHandler
211: .prepareListRecentEnableThreadsWithPendingPosts_limit(genericRequest);
212: } else if (requestURI.equals("/moderatependingthreads")) {
213: threadWebHandler
214: .prepareModeratePendingThreads_inForum_limit(genericRequest);
215: } else if (requestURI
216: .equals("/moderatependingthreadsprocess")) {
217: threadWebHandler
218: .processModeratePendingThreads(genericRequest);
219: } else if (requestURI.equals("/moderatependingposts")) {
220: postWebHandler
221: .prepareModeratePendingPosts_limit(genericRequest);
222: } else if (requestURI
223: .equals("/moderatependingpostsprocess")) {
224: postWebHandler
225: .processModeratePendingPosts(genericRequest);
226:
227: } else if (requestURI.equals("/listpendingthreadsxml")) {
228: threadWebHandler
229: .prepareListDisabledThreads_limit_xml(genericRequest);
230:
231: } else if (requestURI.equals("/addpost")) {
232: postWebHandler.prepareAdd(genericRequest,
233: genericResponse);
234: } else if (requestURI.equals("/addpostprocess")) {
235: postWebHandler.processAdd(genericRequest,
236: genericResponse);
237: postWebHandler.addPostSuccessForRender(genericRequest,
238: genericResponse);
239: } else if (requestURI.equals("/editpost")) {
240: postWebHandler.prepareEdit(genericRequest,
241: genericResponse);
242: } else if (requestURI.equals("/updatepost")) {
243: postWebHandler.processUpdate(genericRequest);
244: postWebHandler.updatePostSuccessForRender(
245: genericRequest, genericResponse);
246: } else if (requestURI.equals("/printpost")) {
247: postWebHandler.preparePrintPost(genericRequest);
248: } else if (requestURI.equals("/deletepost")) {
249: postWebHandler.prepareDelete(genericRequest,
250: genericResponse);
251: } else if (requestURI.equals("/deletepostprocess")) {
252: postWebHandler.processDelete(genericRequest);
253: postWebHandler.deleteSuccessForRender(genericRequest,
254: genericResponse);
255: } else if (requestURI.equals("/addattachment")) {
256: attachmentWebHandler.prepareAdd(genericRequest,
257: genericResponse);
258: } else if (requestURI.equals("/addattachmentprocess")) {
259: attachmentWebHandler.processAdd(genericRequest,
260: genericResponse);
261: attachmentWebHandler.addSuccessForRender(
262: genericRequest, genericResponse);
263:
264: } else if (requestURI.equals("/getattachment")) {
265: attachmentWebHandler.downloadAttachment(genericRequest,
266: response);
267: return null;//download attachment, no further process is needed
268: } else if (requestURI.equals("/deleteattachment")) {
269: attachmentWebHandler.prepareDelete(genericRequest,
270: genericResponse);
271: } else if (requestURI.equals("/deleteattachmentprocess")) {
272: attachmentWebHandler.processDelete(genericRequest);
273: attachmentWebHandler.deleteSuccessForRender(
274: genericRequest, genericResponse);
275: } else if (requestURI.equals("/editattachment")) {
276: attachmentWebHandler.prepareEdit(genericRequest,
277: genericResponse);
278: } else if (requestURI.equals("/editattachmentprocess")) {
279: attachmentWebHandler.processEdit(genericRequest);
280: attachmentWebHandler.editSuccessForRender(
281: genericRequest, genericResponse);
282: } else if (requestURI.equals("/listattachments")) {
283: attachmentWebHandler.prepareListAttachments(
284: genericRequest, genericResponse);
285:
286: } else if (requestURI.equals("/myfavoritethread")) {
287: threadWebHandler.prepareList_inFavorite(genericRequest);
288: } else if (requestURI.equals("/addfavoritethreadprocess")) {
289: favoriteThreadWebHandler.processAdd(genericRequest);
290: } else if (requestURI
291: .equals("/deletefavoritethreadprocess")) {
292: favoriteThreadWebHandler.processDelete(genericRequest);
293:
294: } else if (requestURI.equals("/registermember")) {
295: memberWebHandler.prepareAdd(genericRequest);
296: } else if (requestURI.equals("/registermemberprocess")) {
297: memberWebHandler.processAdd(genericRequest,
298: genericResponse);// no permission
299: } else if (requestURI.equals("/viewmember")) {
300: memberWebHandler.prepareView_forPublic(genericRequest);// no permission
301: } else if (requestURI.equals("/listmembers")) {
302: memberWebHandler
303: .prepareListMembers_forPublic(genericRequest);// no permission
304: } else if (requestURI.equals("/editmember")) {
305: memberWebHandler
306: .prepareEdit_forCurrentMember(genericRequest);
307: } else if (requestURI.equals("/updatemember")) {
308: memberWebHandler.processUpdate(genericRequest,
309: genericResponse);
310: } else if (requestURI.equals("/myprofile")) {
311: memberWebHandler
312: .prepareView_forCurrentMember(genericRequest);
313: } else if (requestURI.equals("/changemypassword")) {
314: onlineUser.getPermission().ensureIsAuthenticated();// check if login
315: } else if (requestURI.equals("/changemypasswordprocess")) {
316: memberWebHandler.processUpdatePassword(genericRequest);
317: } else if (requestURI.equals("/changeemail")) {
318: memberWebHandler.prepareEditEmail(genericRequest);
319: } else if (requestURI.equals("/changeemailprocess")) {
320: memberWebHandler.processUpdateEmail(genericRequest);
321: } else if (requestURI.equals("/changesignature")) {
322: memberWebHandler.prepareEditSignature(genericRequest);
323: } else if (requestURI.equals("/changesignatureprocess")) {
324: memberWebHandler.processUpdateSignature(genericRequest,
325: genericResponse);
326: } else if (requestURI.equals("/changeavatar")) {
327: memberWebHandler.prepareEditAvatar(genericRequest);
328: } else if (requestURI.equals("/uploadavatar")) {
329: memberWebHandler.uploadAvatar(mainServlet
330: .getServletConfig(), genericRequest);
331: } else if (requestURI.equals("/updateavatar")) {
332: memberWebHandler.updateMemberAvatar(genericRequest);
333: } else if (requestURI.equals("/mywatch")) {
334: watchWebHandler.prepareList(genericRequest);
335: } else if (requestURI.equals("/addwatch")) {
336: watchWebHandler.prepareAdd(genericRequest,
337: genericResponse);
338: } else if (requestURI.equals("/addwatchprocess")) {
339: watchWebHandler.processAdd(genericRequest);
340: } else if (requestURI.equals("/deletewatchprocess")) {
341: watchWebHandler.processDelete(genericRequest);
342: } else if (requestURI.equals("/editwatch")) {
343: watchWebHandler.prepareEdit(genericRequest);
344: } else if (requestURI.equals("/editwatchprocess")) {
345: watchWebHandler.processEdit(genericRequest);
346:
347: } else if (requestURI.equals("/mymessage")) {
348: messageWebHandler.prepareList(genericRequest);
349: } else if (requestURI.equals("/addmessage")) {
350: messageWebHandler.prepareAdd(genericRequest,
351: genericResponse);
352: } else if (requestURI.equals("/addmessageprocess")) {
353: messageWebHandler.processAdd(genericRequest,
354: genericResponse);
355: } else if (requestURI.equals("/viewmessage")) {
356: messageWebHandler.prepareViewMessage(genericRequest);
357: } else if (requestURI.equals("/sendmessageprocess")) {
358: messageWebHandler.processSendMessage(genericRequest);
359: } else if (requestURI.equals("/deletemessageprocess")) {
360: messageWebHandler.processDelete(genericRequest);
361: } else if (requestURI.equals("/processmessage")) {
362: messageWebHandler.processMessage(genericRequest);
363:
364: } else if (requestURI.equals("/sendmail")) {
365: mailWebHandler.prepareSendMail(genericRequest);
366: } else if (requestURI.equals("/sendmailprocess")) {
367: mailWebHandler.sendEmailProcess(genericRequest);
368:
369: } else if (requestURI.equals("/addmessageattachment")) {
370: pmAttachmentWebHandler.prepareAdd(genericRequest);
371: } else if (requestURI
372: .equals("/addmessageattachmentprocess")) {
373: pmAttachmentWebHandler.processAdd(genericRequest,
374: genericResponse);
375: } else if (requestURI.equals("/getpmattachment")) {
376: pmAttachmentWebHandler.downloadAttachment(request,
377: response);
378: return null;//download attachment, no further process is needed
379:
380: } else if (requestURI.equals("/mymessagefolder")) {
381: messageFolderWebHandler.prepareList(genericRequest);
382: } else if (requestURI.equals("/addmessagefolder")) {
383: messageFolderWebHandler.prepareAdd(genericRequest);
384: } else if (requestURI.equals("/addmessagefolderprocess")) {
385: messageFolderWebHandler.processAdd(genericRequest);
386: } else if (requestURI.equals("/deletemessagefolder")) {
387: messageFolderWebHandler.prepareDelete(genericRequest);
388: } else if (requestURI.equals("/deletemessagefolderprocess")) {
389: messageFolderWebHandler.processDelete(genericRequest);
390: } else if (requestURI.equals("/updatefolderorder")) {
391: messageFolderWebHandler
392: .processUpdateOrder(genericRequest);
393:
394: } else if (requestURI.equals("/search")) {
395: postWebHandler.processSearch(genericRequest,
396: genericResponse);
397: } else if (requestURI.equals("/rsssummary")) {
398: threadWebHandler.prepareRSSSummary(genericRequest,
399: genericResponse);
400: } else if (requestURI.equals("/atom")) {
401: threadWebHandler.prepareListRSS(genericRequest);
402: } else if (requestURI.equals("/rss")) {
403: threadWebHandler.prepareListRSS(genericRequest);
404: } else if (requestURI.equals("/rss2")) {
405: threadWebHandler.prepareListRSS(genericRequest);
406:
407: } else if (requestURI.equals("/searchattachments")) {
408: attachmentWebHandler.processSearchAttachments(
409: genericRequest, genericResponse);
410:
411: } else if (requestURI.equals("/getmvncoreimage")) {
412: MyUtil.writeMvnCoreImage(response);
413: return null;
414: } else if (requestURI.equals("/getmvnforumimage")) {
415: MyUtil.writeMvnForumImage(response);
416: return null;
417:
418: } else if (requestURI.equals("/captchaimage")) {
419: MVNCaptchaService.getInstance().writeCaptchaImage(
420: request, response);
421: return null;
422: } else if (requestURI.equals("/iforgotpasswords")) {
423: memberWebHandler.prepareForgotPassword(genericRequest);//no permission
424: } else if (requestURI.equals("/forgotpasswordprocess")) {
425: memberWebHandler.forgotPassword(genericRequest);//no permission
426: } else if (requestURI.equals("/resetpasswordprocess")) {
427: memberWebHandler.resetPassword(genericRequest);//no permission
428:
429: } else if (requestURI.equals("/sendactivationcodeprocess")) {
430: memberWebHandler.sendActivateCode(genericRequest); // no permission
431: } else if (requestURI.equals("/activatememberprocess")) {
432: memberWebHandler.activateMember(genericRequest); // no permission
433:
434: } else if (requestURI.equals("/listonlineusers")) {
435: //@todo: move to WebHandler
436: Locale locale = I18nUtil.getLocaleInRequest(request);
437: if (MVNForumConfig.getEnableOnlineUsers() == false) {
438: String localizedMessage = MVNForumResourceBundle
439: .getString(locale,
440: "java.lang.IllegalStateException.list_online_users_is_disabled");
441: throw new IllegalStateException(localizedMessage);
442: //throw new IllegalStateException("Cannot list online users because ONLINE_USERS feature is disabled by administrator.");
443: }
444:
445: OnlineUserUtil.updateOnlineUserAction(genericRequest,
446: requestURI);
447:
448: // now set the attribute
449: //request.setAttribute("OnlineUserActions", onlineUserManager.getOnlineUserActions(0/*default*/));// no permission
450: boolean duplicateUsers = MVNForumConfig
451: .getEnableDuplicateOnlineUsers();
452: request.setAttribute("OnlineUserActions",
453: onlineUserManager.getOnlineUserActions(
454: 0/*default*/, duplicateUsers));// no permission
455:
456: } else if (requestURI.equals("/login")) {
457: genericRequest.setSessionAttribute("Referer", "");
458:
459: String host = request.getHeader("Host");
460: host = (host != null) ? host : MVNCoreConfig
461: .getServerPath();
462: String referer = request.getHeader("Referer");
463: referer = StringUtil.getEmptyStringIfNull(referer);
464: int indexOfHost = referer.indexOf("://" + host);
465: // check this again
466: if ((indexOfHost == -1) || (indexOfHost > 10)
467: || (referer.indexOf("/logout") != -1)) {// 10 is the maximum position when search for the host
468: referer = null;
469: }
470: if (referer != null) {
471: genericRequest.setSessionAttribute("Referer",
472: referer);
473: }
474: if (MVNForumConfig.getRedirectLoginURL().equals(
475: "default") == false) {
476: // if not checking, we will have recursive bug
477: responseURI = MVNForumConfig.getRedirectLoginURL();
478: }
479: } else if (requestURI.equals("/loginprocess")) {
480: if (MVNForumConfig.getEnableLogin() == false) {
481: throw new AuthenticationException(
482: NotLoginException.LOGIN_DISABLED);
483: }
484: onlineUserManager.processLogin(request, response);
485:
486: String referer = (String) genericRequest
487: .getSessionAttribute("Referer");
488: referer = StringUtil.getEmptyStringIfNull(referer);
489: if (referer.length() > 0) {
490: responseURI = referer;
491: genericRequest.setSessionAttribute("Referer", "");
492: }
493:
494: String url = ParamUtil.getParameter(request, "url");
495: if (onlineUserManager.getOnlineUser(request)
496: .isPasswordExpired()) {
497: responseURI = UserModuleConfig.getUrlPattern()
498: + "/changemypassword";
499: } else if (url.length() > 0) {
500: responseURI = url;
501: } else {
502: String originalRequest = ParamUtil.getAttribute(
503: request.getSession(), ORIGINAL_REQUEST);
504: if (originalRequest.length() > 0) {
505: genericRequest.setSessionAttribute(
506: ORIGINAL_REQUEST, "");
507: responseURI = originalRequest;
508: }
509: }
510: } else if (requestURI.equals("/logout")) {
511: onlineUserManager.logout(request, response);
512: request.setAttribute("Reason", "Logout successfully.");
513: if (MVNForumConfig.getRedirectLogoutURL().equals(
514: "default") == false) {
515: // if not checking, we will have recursive bug
516: responseURI = MVNForumConfig.getRedirectLogoutURL();
517: }
518: } else if (requestURI.equals("/deletecookieprocess")) {
519: onlineUserManager.deleteCookie(response);
520: } else if (requestURI.equals("/getavatar")) {
521: memberWebHandler.getAvatar(request, response);
522: return null;//download attachment, no further process is needed
523: }
524: } catch (AuthenticationException e) {
525: if (e.getReason() == NotLoginException.NOT_ACTIVATED) {
526: requestURI = "/sendactivationcode";
527: } else {
528: // make sure not from login page, we cannot set original request in this situation
529: // and also make sure the request's method must be GET to set the OriginalRequest
530: boolean shouldSaveOriginalRequest = (e.getReason() == NotLoginException.NOT_LOGIN)
531: || (e.getReason() == NotLoginException.NOT_ENOUGH_RIGHTS);
532: if (shouldSaveOriginalRequest
533: && (request.getMethod().equals("GET"))) {
534: String url = UserModuleConfig.getUrlPattern()
535: + requestURI
536: + "?"
537: + StringUtil.getEmptyStringIfNull(request
538: .getQueryString());
539: request.getSession().setAttribute(ORIGINAL_REQUEST,
540: url);
541: }
542: //requestURI = "/login";
543: responseURI = UserModuleConfig.getUrlPattern()
544: + "/login";
545: request.setAttribute("Reason", e
546: .getReasonExplanation(onlineUser.getLocale()));
547: }
548: } catch (Throwable e) {
549: if (e instanceof BadInputException) {
550: // we log in WARN level if this is the exception from user input
551: log.warn("Exception in UserModuleProcessor e = "
552: + e.getMessage(), e);
553: } else if (e instanceof AssertionError) {
554: // we log in FATAL level if this is the exception from user input
555: log.fatal("Exception in UserModuleProcessor e = "
556: + e.getMessage(), e);
557: } else {
558: log.error("Exception in UserModuleProcessor ["
559: + e.getClass().getName() + "] : "
560: + e.getMessage(), e);
561: }
562: requestURI = "/error";
563: String message = StringUtil.getEmptyStringIfNull(e
564: .getMessage());
565: if (message.length() == 0) {
566: message = e.getClass().getName();
567: }
568: request.getSession().setAttribute("ErrorMessage",
569: DisableHtmlTagFilter.filter(message));
570: }
571:
572: // step 2: map the URI (of the CONTROLLER)
573: try {
574: // NOTE 1: there is one situation when responseURI != null (after login successfully for the first time),
575: // but since it will make a NEW request via sendRedirect, so we dont count
576: // NOTE 2: there are 2 situation when requestURI is different from the original requestURI
577: // that is /login and /error, because of this so we must pass the requestURI
578: /* @todo Could below the MapHandler ??? */
579:
580: Action action = new ActionInUserModule(genericRequest,
581: requestURI);// may throw MissingURLMapEntryException
582: onlineUserManager.updateOnlineUserAction(genericRequest,
583: action);
584:
585: // now updateOnlineUserAction is ok, we go ahead
586: if (responseURI == null) {
587: URLMap map = urlMapHandler.getMap(requestURI,
588: genericRequest, onlineUser.getLocaleName());
589: responseURI = map.getResponse();
590: }// if
591: } catch (MissingURLMapEntryException e) {
592: log
593: .error("Exception: missing urlmap entry in forum module: requestURI = "
594: + requestURI);
595: responseURI = "/mvnplugin/mvnforum/user/error.jsp";
596: request.getSession().setAttribute("ErrorMessage",
597: DisableHtmlTagFilter.filter(e.getMessage()));
598: } catch (Throwable e) {
599: // This will catch AuthenticationException, AssertionError, DatabaseException
600: // in the method onlineUserManager.updateOnlineUserAction(request, action)
601: responseURI = "/mvnplugin/mvnforum/user/error.jsp";
602: request.getSession().setAttribute("ErrorMessage",
603: DisableHtmlTagFilter.filter(e.getMessage()));
604: }
605:
606: // step 3: forward or dispatch to the VIEW
607: if (log.isDebugEnabled()) {
608: long duration = System.currentTimeMillis() - start;
609: log.debug("UserModuleProcessor : responseURI = "
610: + responseURI + ". (" + duration + " ms)");
611: }
612:
613: return responseURI;
614: }
615: }
|