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

📄 parambean.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     *     */    public ParamBean (HttpServletRequest request,                      HttpServletResponse response,                      ServletContext context,                      JahiaPrivateSettings jSettings,                      long startTime,                      int httpMethod)            throws JahiaPageNotFoundException,            JahiaSessionExpirationException,            JahiaSiteNotFoundException,            JahiaException {        try {            // default vars            this.engineName = CORE_ENGINE_NAME;            this.opMode = NORMAL;            // objects            theSettings = new SettingsBean (jSettings);            // main vars            mRequest = request;            mRealResponse = response;            mResponse = new ServletIncludeResponseWrapper (response, false, null);            this.context = context;            this.startTime = startTime;            this.httpMethod = httpMethod;            //JahiaConsole.print("ParamBean.constructor","Looking up session...");            // This call can take a lot of time the first time a session is            // created because the servlet container uses random generators            // for Session ID creation that are classes loaded at run-time.            // eg. in Tomcat 4 a java.security.random class is loaded and            // called.            HttpSession session = mRequest.getSession ();            /*            session.setMaxInactiveInterval(60);            JahiaConsole.println("ParamBean.ParamBean",                                 "Session time out value is : " +                                 session.getMaxInactiveInterval() + " seconds" );            */            ///////////////////////////////////////////////////////////////////////////////////////            // FIXME -Fulco-            //            //      IS THE COMMENTED CODE BELOW STILL NEEDED ?????????            //      IF NOT PLEASE REMOVE IT !!            //            ///////////////////////////////////////////////////////////////////////////////////////            // WARNING : Orion's implementation of getParameter ONLY works if no reader or            // inputstream was retrieve before first reads to parameters.            /*            try {                BufferedReader requestReader = mRequest.getReader();                if (requestReader == null) {                    JahiaConsole.println("ParamBean.constructor","ERROR RETRIEVING REQUEST READER !");                } else {                        if (requestReader.markSupported() == true) {                            JahiaConsole.println("ParamBean.constructor","requestReader mark supported.");                            requestReader.mark(10*1024*1024); // FIXME : hardcoded 10MB limit                        } else {                            JahiaConsole.println("ParamBean.constructor","requestReader mark NOT supported.");                        }                    JahiaConsole.println("ParamBean.constructor","REQUEST BODY START ----- ");                    int nc = requestReader.read();                    while (nc != -1) {                        JahiaConsole.print("ParamBean.constructor",(char)nc);                        nc = requestReader.read();                    }                    JahiaConsole.println("ParamBean.constructor","REQUEST BODY END ----- ");                    requestReader.reset();                }            } catch (java.io.IOException ioe) {                JahiaConsole.println("ParamBean.constructor","IOException while reading request body !");            }            */            ///////////////////////////////////////////////////////////////////////////////////////            // build a custom parameter map, from PathInfo            buildCustomParameters (mRequest);            // Get the engine name information            if (getParameter (ENGINE_NAME_PARAMETER) != null) {             //  REPLACE WITH CUSTOM                this.engineName = getParameter (ENGINE_NAME_PARAMETER);         //            }            // retrieve site info            this.getSiteInfos (session);            // Get the current user out of the session. If there is no user            // present, then assign the guest user to this session.            // If the site has changed, switch to user to guest user            if (!"login".equals (this.engineName)) {                theUser = (JahiaUser)session.getAttribute (SESSION_USER);            }            if (theUser == null) {                setUserGuest (this.getSiteID ());            }            Enumeration userAgentValues = mRequest.getHeaders ("user-agent");            if (userAgentValues.hasMoreElements ()) {                // we only take the first value.                userAgent = (String)userAgentValues.nextElement ();            }            if (site != null) {                // Get the field ID information                if (getParameter (FIELD_ID_PARAMETER) != null) {                    this.fieldID = Integer.parseInt (getParameter (FIELD_ID_PARAMETER));                }                if (this.thePage == null) {                    // Get the page information, if no page info is specified, then                    // load the default page.                    String pageIDStr = getParameter (PAGE_ID_PARAMETER);                    if (pageIDStr == null && this.getEngine ().equals (CORE_ENGINE_NAME)) {                        pageIDStr = Integer.toString (this.getSite ().getHomePageID ());                    }                    if (pageIDStr != null) {                        // try to get the page reference.                        try {                            int pid = Integer.parseInt (pageIDStr);                            thePage = ServicesRegistry.getInstance ().getJahiaPageService ().lookupPage (pid, this);                            // if the page is not found, throw the associated exception                            if (thePage == null) {                                throw new JahiaPageNotFoundException (pid);                            }                        } catch (NumberFormatException nfe) {                            JahiaConsole.println ("ParamBean::Constructor", "Number format exception");                            JahiaConsole.println ("ParamBean::Constructor", "Request URI = " + mRequest.getRequestURI ());                            throw new JahiaPageNotFoundException (pageIDStr);                        }                        // Ensure if the requested page is a page of the current site                        if (thePage.getJahiaID () != this.getSiteID ()) {                            thePage = this.site.getHomePage ();                        }                    }                }                // last requested page                Integer lrpID = (Integer)session.getAttribute (SESSION_LAST_REQUESTED_PAGE_ID);                if ((lrpID == null)) {                    lrpID = new Integer (-1);                }                this.newPageRequest = (lrpID.intValue () != this.getPageID ());                this.lastRequestedPageID = lrpID.intValue ();                if (thePage != null) {                    // fires event                    JahiaEvent theEvent = new JahiaEvent (this, this, thePage);                    ServicesRegistry.getInstance ().getJahiaEventService ().                            fireLoadPage (theEvent);                }            }            // handle the case where the site has changed            if (this.siteHasChanged) {                // check if the user has access to the page                if (thePage != null && !thePage.checkReadAccess (this.getUser ())) {                    // switch to guest user                    setUserGuest (this.getSiteID ());                }            }            // operation            if (getParameter (OPERATION_MODE_PARAMETER) != null) {                // for the rest... "mess with the best, die with the rest"                if (NORMAL.equals (getParameter (OPERATION_MODE_PARAMETER))) {                    this.opMode = NORMAL;                }                if (EDIT.equals (getParameter (OPERATION_MODE_PARAMETER))) {                    // User has write rights to edit?                    if (thePage.checkWriteAccess (theUser))                    // Yes -> Edit mode                    {                        this.opMode = EDIT;                    } else                    // No -> Normal mode !                    {                        this.opMode = NORMAL;                    }                }                if (DEBUG.equals (getParameter (OPERATION_MODE_PARAMETER))) {                    if (thePage.checkAdminAccess (theUser)) {                        this.opMode = DEBUG;                    } else {                        this.opMode = NORMAL;                    }                }            }            String oldOpMode = NORMAL;            if (session.getAttribute (OPERATION_MODE_PARAMETER) != null) {                if (session.getAttribute (OPERATION_MODE_PARAMETER) instanceof String) {                    oldOpMode = (String)session.getAttribute (OPERATION_MODE_PARAMETER);                }            }            session.setAttribute (OPERATION_MODE_PARAMETER, this.opMode);            if (!oldOpMode.equals (this.opMode)) {                //JahiaConsole.println("ParamBean", "Mode switch detected.");                // We detected a mode switch, let's flush both the HTML cache and                // the application cache...                JahiaApplicationsDispatchingService dispatcher = ServicesRegistry.getInstance ().getJahiaApplicationsDispatchingService ();                if (dispatcher != null) {                    dispatcher.flushAllSessionsCaches (session);                }                /**                 * We flush all the pages for the current user.                 */                CacheServerService contentCache = ServicesRegistry.getInstance ().getCacheServerService ();                if (contentCache != null) {                    contentCache.removeUserEntries (getUser ().getUsername ());                }            }            // last engine name            this.lastEngineName = (String)session.getAttribute (SESSION_LAST_ENGINE_NAME);            this.engineHasChanged = (this.lastEngineName == null || !this.lastEngineName.equals (getEngine ()));            // read cache status            String newCacheStatus = getParameter (CACHE_MODE_PARAMETER);            if (newCacheStatus != null) {                if (CACHE_ON.equals (newCacheStatus)) {                    this.cacheStatus = this.CACHE_ON;                } else if (CACHE_ONLYUPDATE.equals (newCacheStatus)) {                    this.cacheStatus = this.CACHE_ONLYUPDATE;                } else if (CACHE_OFFONCE.equals (newCacheStatus)) {                    this.cacheStatus = this.CACHE_OFFONCE;                } else if (CACHE_BYPASS.equals (newCacheStatus)) {                    this.cacheStatus = this.CACHE_BYPASS;                } else if (CACHE_OFF.equals (newCacheStatus)) {                    this.cacheStatus = this.CACHE_OFF;                } else {                    this.cacheStatus = this.CACHE_ON;                }            } else {                this.cacheStatus = this.CACHE_ON;            }            originalCacheStatus = cacheStatus;            ///////////////////////////////////////////////////////////////////////////////////////            // FIXME -Fulco-            //            //      hmmmmm, this catch has no reason to be here! This exception should be catched            //      where the numeric convertion takes place, and not here!!!            //            ///////////////////////////////////////////////////////////////////////////////////////        } catch (NumberFormatException nfe) {            String errorMsg = "Error in translating number : " + nfe.getMessage () + " -> BAILING OUT";            JahiaConsole.println ("ParamBean", errorMsg);            throw new JahiaException ("Error in request parameters",                    errorMsg, JahiaException.PAGE_ERROR, JahiaException.ERROR, nfe);        }    } // end constructor    //-------------------------------------------------------------------------    // DJ   08.02.2001    /** Sets the current user to GUEST, in the params and in the session.     *  Also, comes back in NORMAL mode.     */    public void setUserGuest (int siteID)            throws JahiaSessionExpirationException {        HttpSession session = mRequest.getSession (false);        if (session == null) {            throw new JahiaSessionExpirationException ();        }        // get the User Manager service instance.        JahiaUserManagerService userMgr = ServicesRegistry.getInstance ().                getJahiaUserManagerService ();        theUser = userMgr.lookupUser (siteID, userMgr.GUEST_USERNAME);        session.setAttribute (SESSION_USER, theUser);        opMode = NORMAL;    }    /***     * accessor methods     * EV    03.11.2000     *     */    public SettingsBean settings () {        return theSettings;    }    public HttpServletRequest getRequest () {        return mRequest;    }    public HttpServletResponse getResponse () {        return mResponse;    }    public HttpServletResponse getRealResponse () {        return mRealResponse;    }    public ServletContext getContext () {        return context;    }    public int getHttpMethod () {

⌨️ 快捷键说明

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