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

📄 jahia.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    jParams = new ParamBean( request, response, context, jSettings, startTime, intRequestMethod);                    if (jParams != null) {                        paramBeanThreadLocal.set (jParams);                        exitAdminMode = ( (I!=null) && (I.intValue()==ADMIN_MODE) && jParams.getEngine().equals(ParamBean.CORE_ENGINE_NAME) );                        // tell we are in Jahia Core mode                        if ( exitAdminMode ){                            session.setAttribute(ParamBean.SESSION_JAHIA_RUNNING_MODE,new Integer(Jahia.CORE_MODE));                            JahiaConsole.println("Jahia.service","Switch to Jahia.CORE_MODE");                        }                        // NK : flush the page in cache if we were previously in ADMIN MODE                        if ( exitAdminMode && jParams.getUser()!= null){                            CacheServerService contentCache = ServicesRegistry.getInstance().getCacheServerService();                            if (contentCache != null) {                                try {                                    contentCache.removeEntry(String.valueOf(jParams.getPageID()),jParams.getUser().getUsername());                                } catch ( Throwable t ){                                    t.printStackTrace();                                }                            }                        }                        if(request.getAttribute(JahiaConfigurationWizard.CLASS_NAME + ".directAdministration") != null) {                            jahiaLaunch( request, response, this.jahiaInitAdminServletPath );                        } else {                            operations.handleOperations (jParams, jSettings);                        }                    }                    // display time                    if (jParams.getUser()!=null)                    {                        JahiaConsole.finalPrintln("Jahia.service",                                  "Served " + jParams.getEngine() + " engine for user " +jParams.getUser().getUsername()+ " from ["+                                  jParams.getRequest().getRemoteAddr() + "] in ["+JahiaChrono.getInstance().read( jParams.getStartTime() )+"ms]");                    }                    jParams = null;                // PAGE NOT FOUND EXCEPTION                } catch (JahiaPageNotFoundException ex) {                    JahiaConsole.finalPrintln (JAHIA_STR, ex.getJahiaErrorMsg());                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, ex);                }                // SECURITY EXCEPTION                catch (JahiaSecurityException ex) {                    JahiaConsole.finalPrintln (JAHIA_STR, "A Security error occured -> request ignored.");                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, ex);                }                // SESSION EXPIRATION                catch (JahiaSessionExpirationException ex) {                    JahiaConsole.finalPrintln (JAHIA_STR, "Null session -> session expiration -> request ignored.");                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, ex);                }                // OPERATION NOT ALLOWED                catch (JahiaOperationNotAllowedException ex) {                    JahiaConsole.finalPrintln (JAHIA_STR, ex.getJahiaErrorMsg());                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, ex);                }                // SERVICE EXCEPTIONS                catch (ServiceNotFoundException ex) {                    JahiaConsole.finalPrintln (JAHIA_STR, ex.getJahiaErrorMsg());                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, ex);                }                // VIRTUAL SITE NOT FOUND                catch (JahiaSiteNotFoundException snfex) {                    JahiaConsole.finalPrintln (JAHIA_STR, snfex.getJahiaErrorMsg());                    JahiaErrorDisplay.DisplayException (request, response, getServletContext(), jSettings, snfex);                }                // ALL OTHER JAHIA EXCEPTIONS                catch (JahiaException je) {                    JahiaConsole.println(JAHIA_STR, "Error in " + requestMethod + " method -> BAILING OUT" );                    // should redirect to an error page here                    JahiaErrorDisplay.DisplayException(request, response, getServletContext(), jSettings, je);                }            }        } catch (Throwable t) {            JahiaConsole.finalPrintln(JAHIA_STR, "Throwable Exception caught in Jahia servlet : " + t);            JahiaErrorDisplay.DisplayException(request, response, getServletContext(), jSettings, t);        }    }    /**     * Helper method to copy JSESSION cookies from a non null context to a root     * context. Warning this MIGHT disrupt normal functioning of the servlet     * container.     * @param request the request object containing the cookies to read     * @param response the response object in which to copy the session cookie     * to the root context.     */    public static void copySessionCookieToRootContext(HttpServletRequest request,                                                HttpServletResponse response) {        Cookie[] cookies = request.getCookies();        if (cookies != null) {            for (int i = 0; i < cookies.length; i++) {                Cookie curCookie = cookies[i];                if ("JSESSIONID".equals(curCookie.getName())) {                    String curPath = curCookie.getPath();                    if ( (curPath != null) && (!("".equals(curPath))) ) {                        // we found a session cookie that has a non null path,                        // let's copy it to a null path.                        JahiaConsole.println(CLASS_NAME + ".copySessionCookieToRootContext",                                             "Copying non-root context cookie to root context");                        Cookie rootCookie = (Cookie) curCookie.clone();                        rootCookie.setPath("");                        response.addCookie(rootCookie);                    }                }                JahiaConsole.println(CLASS_NAME + ".copySessionCookieToRootContext",                                     "Cookie domain=[" + curCookie.getDomain() +                                     "] path=[" + curCookie.getPath() +                                     "] name=[" + curCookie.getName() +                                     "] value=[" + curCookie.getValue() + "]");            }        } else {            JahiaConsole.println(CLASS_NAME + ".copySessionCookieToRootContext", "No cookies found.");        }    }    /**     * Call the initialization of the services registry.     *     * @return  Return <code>true</code> on success or <code>false</code> on any failure.     */    protected boolean initServicesRegistry()    throws  JahiaException {        JahiaConsole.println (JAHIA_STR, "Start the Services Registry ...");        try {            ServicesRegistry registry = ServicesRegistry.getInstance();            if (registry != null)            {                registry.init (this.jSettings);                JahiaConsole.println (JAHIA_STR, "Services Registry is running ;)");                return true;            }            JahiaConsole.println (JAHIA_STR, "  -> ERROR : Could not get the Services Registry instance.");            return false;        } catch (JahiaException je) {            throw new JahiaException( je.getJahiaErrorMsg(),                                      "Service Registry Initialization Exception",                                      je.INITIALIZATION_ERROR,                                      je.KISS_YOUR_ASS_GOODBYE,                                      je );        }    }    /**     * Forward the flow to an another servlet. The name of the destination servlet     * is defined on the <code>destination</code> parameter.     *     * @param   request       Servlet request.     * @param   response      Servlet response.     * @param   destination   Destination for requestDispatcher.forward().     */    private void jahiaLaunch( HttpServletRequest   request,                              HttpServletResponse  response,                              String               destination )        throws  IOException,                ServletException    {        try {            getServletContext().getRequestDispatcher( destination ).forward( request, response );        } catch (IOException ie) {            JahiaConsole.println(JAHIA_STR, "IOException on method jahiaLaunch.");        } catch (ServletException se) {            se.printStackTrace();            se.getRootCause().printStackTrace();            JahiaConsole.println(JAHIA_STR, "ServletException on method jahiaLaunch.");        }    } // end jahiaLaunch    //-------------------------------------------------------------------------    private final boolean checkLicense ()    {        if ( mLicenseKey == null ){            try {                mLicenseKey = new LicenseKey (mLicenseFilename);            }            catch (LicenseException ex) {                mLicenseKey = null;                JahiaConsole.finalPrintln (JAHIA_STR + ".checkLicense", ex.getMessage());                return false;            }        }        try {            //System.out.println (key.toString());            // check the build number            if ((mLicenseKey.getBuildNumber() != -1) &&                (BUILD_NUMBER != mLicenseKey.getBuildNumber()))            {                throw new InvalidBuildNumberException ();            }            // check the release number            if ((mLicenseKey.getReleaseNumber() != -1.0) &&                (RELEASE_NUMBER != mLicenseKey.getReleaseNumber()))            {                throw new InvalidReleaseNumberException ();            }            // check that the license id with the host name            mLicenseKey.checkLicenseID ();        }        catch (LicenseException ex) {            mLicenseKey = null;            JahiaConsole.finalPrintln (JAHIA_STR, ex.getMessage());            return false;        }        catch (InvalidLicenseException ile) {            mLicenseKey = null;            JahiaConsole.finalPrintln (JAHIA_STR, ile.getMessage());            return false;        }        return true;    }    //-------------------------------------------------------------------------    private final boolean checkLicenseLimit()    {        if ( mLicenseKey == null ){            try {                mLicenseKey = new LicenseKey (mLicenseFilename);            }            catch (LicenseException ex) {                mLicenseKey = null;                JahiaConsole.finalPrintln (JAHIA_STR + ".checkLicense", ex.getMessage());                return false;            }        }        try {            // check that the number of users in the database does not            // exceed the limit            mLicenseKey.checkUserLimit ();            // check that the number of pages in the database does not            // exceed the limit            // mLicenseKey.checkPageLimit ();            // check that the number of sitess in the database does not            // exceed the limit            mLicenseKey.checkSiteLimit ();            // check that the number of page templates in the database does not            // exceed the limit            mLicenseKey.checkPageTemplateLimit ();        }        catch (LicenseException ex) {            mLicenseKey = null;            JahiaConsole.finalPrintln (JAHIA_STR, ex.getMessage());            return false;        }        return true;    }    //-------------------------------------------------------------------------    /**     * Return the private settings     *     * @return JahiaPrivateSettings     */

⌨️ 快捷键说明

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