⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usermoduleprocessor.java

📁 java servlet著名论坛源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

            } else if (requestURI.equals("/myfavoritethread")) {
                threadWebHandler.prepareList_inFavorite(request);
            } else if (requestURI.equals("/addfavoritethreadprocess")) {
                favoriteThreadWebHandler.processAdd(request);
            } else if (requestURI.equals("/deletefavoritethreadprocess")) {
                favoriteThreadWebHandler.processDelete(request);

            } else if (requestURI.equals("/registermember")) {
                memberWebHandler.prepareAdd(request);
            } else if (requestURI.equals("/registermemberprocess")) {
                memberWebHandler.processAdd(request);// no permission
            } else if (requestURI.equals("/viewmember")) {
                memberWebHandler.prepareView_forPublic(request);// no permission
            } else if (requestURI.equals("/listmembers")) {
                memberWebHandler.prepareListMembers_forPublic(request);// no permission
            } else if (requestURI.equals("/editmember")) {
                memberWebHandler.prepareEdit_forCurrentMember(request);
            } else if (requestURI.equals("/updatemember")) {
                memberWebHandler.processUpdate(request);
            } else if (requestURI.equals("/myprofile")) {
                memberWebHandler.prepareView_forCurrentMember(request);
            } else if (requestURI.equals("/changepassword")) {
                onlineUser.getPermission().ensureIsAuthenticated();// check if login
            } else if (requestURI.equals("/changepasswordprocess")) {
                memberWebHandler.processUpdatePassword(request);
            } else if (requestURI.equals("/changeemail")) {
                memberWebHandler.prepareEditEmail(request);
            } else if (requestURI.equals("/changeemailprocess")) {
                memberWebHandler.processUpdateEmail(request);
            } else if (requestURI.equals("/changesignature")) {
                memberWebHandler.prepareEditSignature(request);
            } else if (requestURI.equals("/changesignatureprocess")) {
                memberWebHandler.processUpdateSignature(request);
            } else if (requestURI.equals("/changeavatar")) {
                memberWebHandler.prepareEditAvatar(request);
            } else if (requestURI.equals("/uploadavatar")) {
                memberWebHandler.uploadAvatar(mainServlet.getServletConfig(), request);
            } else if (requestURI.equals("/updateavatar")) {
                memberWebHandler.updateMemberAvatar(servletContext, request);
            } else if (requestURI.equals("/mywatch")) {
                watchWebHandler.prepareList(request);
            } else if (requestURI.equals("/addwatch")) {
                watchWebHandler.prepareAdd(request);
            } else if (requestURI.equals("/addwatchprocess")) {
                watchWebHandler.processAdd(request);
            } else if (requestURI.equals("/deletewatchprocess")) {
                watchWebHandler.processDelete(request);

            } else if (requestURI.equals("/searchprocess")) {
                postWebHandler.processSearch(request);
            } else if (requestURI.equals("/rss")) {
                threadWebHandler.prepareListRSS(request);

            } else if (requestURI.equals("/getmvncoreimage")) {
                MyUtil.writeMvnCoreImage(request, response);
                return null;
            } else if (requestURI.equals("/getmvnforumimage")) {
                MyUtil.writeMvnForumImage(request, response);
                return null;

            } else if (requestURI.equals("/captchaimage")) {
                MVNCaptchaService.getInstance().writeCaptchaImage(request, response);
                return null;
            } else if (requestURI.equals("/iforgotpasswords")) {
                memberWebHandler.prepareForgotPassword(request);//no permission
            } else if (requestURI.equals("/forgotpasswordprocess")) {
                memberWebHandler.forgotPassword(request);//no permission
            } else if (requestURI.equals("/resetpasswordprocess")) {
                memberWebHandler.resetPassword(request);//no permission

            } else if (requestURI.equals("/sendactivationcodeprocess")) {
                memberWebHandler.sendActivateCode(request);//no permission
            } else if (requestURI.equals("/activatememberprocess")) {
                memberWebHandler.activateMember(request);//no permission

            } else if (requestURI.equals("/listonlineusers")) {
                // This will ensure removing all time-out users (if there is)
                onlineUserManager.getOnlineUser(request);

                // the following 2 lines fix the bug that no online user found in the first time request
                Action action = new ActionInUserModule(request, requestURI);// may throw MissingURLMapEntryException
                onlineUserManager.updateOnlineUserAction(request, action);

                // now set the attribute
                request.setAttribute("OnlineUserActions", onlineUserManager.getOnlineUserActions(0/*default*/));// no permission

            } else if (requestURI.equals("/loginprocess")) {
                if (MVNForumConfig.getEnableLogin() == false) {
                    throw new AuthenticationException(NotLoginException.LOGIN_DISABLED);
                }
                onlineUserManager.processLogin(request, response);
                String originalRequest = ParamUtil.getAttribute(request.getSession(), ORIGINAL_REQUEST);
                if (originalRequest.length() > 0) {
                    request.getSession().setAttribute(ORIGINAL_REQUEST, "");
                    responseURI = originalRequest;
                }
            } else if (requestURI.equals("/logout")) {
                onlineUserManager.logout(request, response);
                request.setAttribute("Reason", "Logout successfully.");
            } else if (requestURI.equals("/deletecookieprocess")) {
                onlineUserManager.deleteCookie(request, response);
            }
        } catch (AuthenticationException e) {
            // make sure not from login page, we cannot set original request in this situation
            // and also make sure the request's method must be GET to set the OriginalRequest
            boolean shouldSaveOriginalRequest = (e.getReason()==NotLoginException.NOT_LOGIN) || (e.getReason()==NotLoginException.NOT_ENOUGH_RIGHTS);
            if (shouldSaveOriginalRequest && (request.getMethod().equals("GET"))) {
                String url = UserModuleConfig.getUrlPattern() + requestURI + "?" + StringUtil.getEmptyStringIfNull(request.getQueryString());
                request.getSession().setAttribute(ORIGINAL_REQUEST, url);
            }
            requestURI = "/login";
            request.setAttribute("Reason", e.getReasonExplanation());
        } catch (Exception e) {
            if (e instanceof BadInputException) {
                // we log in WARN level if this is the exception from user input
                log.warn("Exception in UserModuleProcessor e = " + e.getMessage(), e);
            } else if (e instanceof AssertionException) {
                // we log in FATAL level if this is the exception from user input
                log.fatal("Exception in UserModuleProcessor e = " + e.getMessage(), e);
            } else {
                log.error("Exception in UserModuleProcessor [" + e.getClass().getName() + "] : " + e.getMessage(), e);
            }
            requestURI = "/error";
            String message = StringUtil.getEmptyStringIfNull(e.getMessage());
            if (message.length() == 0) {
                message = e.getClass().getName();
            }
            request.getSession().setAttribute("ErrorMessage", message);
        }

        // step 2: map the URI (of the CONTROLLER)
        try {
            // NOTE 1:  there is one situation when responseURI != null (after login successfully for the first time),
            //          but since it will make a NEW request via sendRedirect, so we dont count
            // NOTE 2:  there are 2 situation when requestURI is different from the original requestURI
            //          that is /login and /error, because of this so we must pass the requestURI
            /* @todo Could below the MapHandler ??? */
            Action action = new ActionInUserModule(request, requestURI);// may throw MissingURLMapEntryException
            onlineUserManager.updateOnlineUserAction(request, action);

            // now updateOnlineUserAction is ok, we go ahead
            if (responseURI == null) {
                URLMap map = urlMapHandler.getMap(requestURI, request, onlineUser.getLocaleName());
                responseURI = map.getResponse();
            }// if
        } catch (MissingURLMapEntryException e) {
            log.error("Exception: missing urlmap entry in forum module: requestURI = " + requestURI);
            responseURI = "/mvnplugin/mvnforum/user/error.jsp";
            request.getSession().setAttribute("ErrorMessage", e.getMessage());
        } catch (Exception e) {
            // This will catch AuthenticationException, AssertionException, DatabaseException
            // in the method onlineUserManager.updateOnlineUserAction(request, action)
            responseURI = "/mvnplugin/mvnforum/user/error.jsp";
            request.getSession().setAttribute("ErrorMessage", e.getMessage());
        }

        // step 3: forward or dispatch to the VIEW
        if (log.isDebugEnabled()) {
            long duration = System.currentTimeMillis() - start;
            log.debug("UserModuleProcessor : responseURI = " + responseURI + ". (" + duration + " ms)\n");
        }

        return responseURI;
/*
        if (responseURI.endsWith(".jsp")) {
            servletContext.getRequestDispatcher(responseURI).forward(request, response);
        } else {
            response.sendRedirect(ParamUtil.getContextPath() + responseURI);
        }*/
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -