📄 jahia.java
字号:
jahiaInitAdminServletPath = "/administration/"; } if (this.jahiaInitConfigServletPath == null) { JahiaConsole.println("Jahia.init", "Error in web.xml for init parameter " + INIT_PARAM_CONFIG_SERVLET_PATH + ". Make sure it's set...Trying to use hardcoded /installation/ dispatching ..."); jahiaInitConfigServletPath = "/installation/"; } if (this.jahiaInitConfigServletPath == null) { } jahiaEtcFilesPath = this.context.getRealPath( webinf_path + "/etc" ); jahiaVarFilesPath = this.context.getRealPath( webinf_path + "/var" ); // set default paths... jahiaPropertiesPath = this.context.getRealPath( webinf_path + "/etc/config/" ); jahiaPropertiesFileName = jahiaPropertiesPath + File.separator + PROPERTIES_FILENAME; jahiaBasicFileName = jahiaPropertiesPath + File.separator + PROPERTIES_BASIC; mLicenseFilename = jahiaPropertiesPath + File.separator + LICENSE_FILENAME; jahiaBaseFilesPath = this.context.getRealPath( webinf_path + "/var" ); jahiaTemplatesScriptsPath = jahiaBaseFilesPath + File.separator + "templates"; jahiaDatabaseScriptsPath = jahiaBaseFilesPath + File.separator + "db"; // create the jSettings object... this.jSettings = new JahiaPrivateSettings (this.config, jahiaPropertiesFileName, mLicenseFilename, BUILD_NUMBER); // Check if the license file exists. File licenseFile = new File (mLicenseFilename); if (licenseFile.exists()) { // Check the license file mInitError = (checkLicense () == false); if (mInitError) { initException = new JahiaException("Invalid License", "Environement Initialization Exception", JahiaException.INITIALIZATION_ERROR, JahiaException.KISS_YOUR_ASS_GOODBYE); return; } // we don't need the license file anymore, it was just to know if // it existed. licenseFile = null; // check if there is a jahia.properties file... File jahiaProperties = new File( jahiaPropertiesFileName ); boolean jahiaPropertiesExists = jahiaProperties.exists(); /* init the listener registry */ //JahiaListenersRegistry.getInstance().init( this.config ); // if the jahia properties file exists try to init... if (jahiaPropertiesExists) { try { this.jSettings.load(); } catch (NullPointerException npe) { this.runInstaller = true; // error while reading jahia.properties, launch JahiaConfigurationWizard... } catch (NumberFormatException nfe) { this.runInstaller = true; // error while reading jahia.properties, launch JahiaConfigurationWizard... } // check server type... and if it's tomcat, check the tomcat-users.xml file... tomcatXMLRestart = TomcatUsersModifier.ensureValidity( jahiaPropertiesFileName ); // Initialize all the registered services. try { if (initServicesRegistry ()) { try { EnginesRegistry.getInstance().init(); JahiaFieldDefinitionsRegistry.getInstance().init(); JahiaContainerDefinitionsRegistry.getInstance().init(); JahiaListenersRegistry.getInstance().init( this.config ); SharedTemplatePackagesRegistry.getInstance().init( this.jSettings.jahiaSharedTemplatesDiskPath, this.jSettings.jahiaJspDiskPath ); operations = new OperationManager(); // only called by Jahia servlet... } catch (NullPointerException ex) { JahiaConsole.finalPrintln(JAHIA_STR, "CRITICAL : Could not initialize one of the needed services!"); // init error, stop Jahia! mInitError = true; return; } // 30.01.2002 NK : Patch for old database with templates without ACL ServicesRegistry.getInstance().getJahiaPageTemplateService().patchTemplateWithoutACL(); } } catch (JahiaException je) { // init error, stop Jahia! mInitError = true; initException = je; return; } // Check the license file mInitError = (checkLicenseLimit () == false); if (mInitError) { initException = new JahiaException("License Limit Violation", "Environement Initialization Exception", JahiaException.INITIALIZATION_ERROR, JahiaException.KISS_YOUR_ASS_GOODBYE); return; } mInitiated = true; } else { // jahia.properties don't exists, launch JahiaConfigurationWizard... this.runInstaller = true; } } else { JahiaConsole.finalPrintln (JAHIA_STR, "Could not find jahia.license file (was looking for it at " + licenseFile.toString() + ")"); mInitError = true; return; } } /** * Default service inherited from HttpServlet. * * @param request Servlet request (inherited). * @param response Servlet response (inherited). */ public void service (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { /////////////////////////////////////////////////////////////////////////////////////////// // PROFILER OPTIMIZEIT // // The following lines start the OptimizeIt profiler. // Comment this lines if profiling is not needed. // /////////////////////////////////////////////////////////////////////////////////////////// //if (!isProfilerStarted) { // // // Start OptimizeIt profiler // Audit.start (1470, Audit.PROFILERS_ALWAYS_ENABLED); // isProfilerStarted = true; // // //} /////////////////////////////////////////////////////////////////////////////////////////// JahiaConsole.println("Jahia.service", "New request, URL=[" + request.getRequestURI() + "], serverName=[" + request.getServerName() + "]"); /** @todo Can we put this someplace else, and furthermore can be only * do this if we have a session variable set or something ? */ // The following part is the most important part of the servlet, which makes sure // we read all the encodings in UTF-8. This is documented in the Servlet API 2.3 // specification, under the SRV 4.9 section, page 37 // JahiaConsole.println("Jahia", "Character encoding passed: " + request.getCharacterEncoding() ); if (jSettings.isUtf8Encoding()) { // bad browser, doesn't send character encoding :( // we can force the encoding ONLY if we do this call before any // getParameter() call is done ! request.setCharacterEncoding("UTF-8"); } org.jahia.services.database.JahiaDBPoolBaseService.count =0; jahiaServletPath = request.getServletPath(); JahiaConsole.println(CLASS_NAME + ".service", "Character encoding set as: " + request.getCharacterEncoding() ); copySessionCookieToRootContext(request, response); HttpSession session = request.getSession(false); if (session == null) { // Session could be false because of new user, or missing JSESSIONID // id for a non-cookie browser, or a false cookie maybe ? JahiaConsole.println(CLASS_NAME + ".service", "Session is null"); session = request.getSession(true); JahiaConsole.println(CLASS_NAME + ".service", "New session id=[" + session.getId() + "]"); } if ( Jahia.isInitiated() && !checkLockAccess(session) ){ JahiaConsole.println(CLASS_NAME,"Jahia is locked by the super admin !\n"); config.getServletContext().getRequestDispatcher( "/jsp/jahia/errors/locked.jsp" ).forward( request, response ); return; } try { if (jahiaContextPath == null) { jahiaContextPath = request.getContextPath(); } if (this.relativeServletURI == null) { String pathInfo = request.getPathInfo(); if ( pathInfo == null ){ this.relativeServletURI = request.getRequestURI(); } else { this.relativeServletURI = request.getRequestURI().substring(0,request.getRequestURI().indexOf(pathInfo)); } } // please restart tomcat... config has been modified... if (tomcatXMLRestart) { session = request.getSession(); if(session!= null) { session.setAttribute(JahiaAdministration.CLASS_NAME + "jahiaDisplayMessage", "<b>Web applications are being deployed...<br>" + "Please wait a few moments until it is done<br>" + "and then shutdown and restart Jahia</b>"); } } // check witch action to do... if (mInitWarning) { // init error, stop Jahia... if(initException!=null){ JahiaErrorDisplay.DisplayException(request, response, getServletContext(), jSettings, initWarningException); } // we only display warnings once. initWarningException = null; mInitWarning = false; } else if (mInitError) { // init error, stop Jahia... JahiaConsole.finalPrintln (JAHIA_STR, "INIT ERROR. Jahia is not started."); if(initException!=null){ JahiaErrorDisplay.DisplayException(request, response, getServletContext(), jSettings, initException); } } else if (this.runInstaller) { // run the installer... this.runInstaller = false; this.reInit = true; jahiaLaunch (request, response, this.jahiaInitConfigServletPath); } else if (request.getAttribute(JAHIA_LAUNCH) != null) { // redirect on an another servlet... if (request.getAttribute (JAHIA_LAUNCH).equals ("installation")) { jahiaLaunch( request, response, this.jahiaInitConfigServletPath ); } else if (request.getAttribute(JAHIA_LAUNCH).equals("administration")) { jahiaLaunch( request, response, this.jahiaInitAdminServletPath ); } } else if (reInit) { // re-init Jahia... this.reInit = false; init (config); service (request, response); } else { // all is okay, simple continue... boolean exitAdminMode = false; Integer I = (Integer)session.getAttribute(ParamBean.SESSION_JAHIA_RUNNING_MODE); // start the chrono... long startTime = JahiaChrono.getInstance().start(); // get the main http method... String requestMethod = request.getMethod(); int intRequestMethod = 0; if (requestMethod.equals(GET_REQUEST)) { intRequestMethod = ParamBean.GET_METHOD; } else if(requestMethod.equals (POST_REQUEST)) { intRequestMethod = ParamBean.POST_METHOD; } JahiaConsole.println("Jahia.service", "--------------------------------------------- NEW "+requestMethod+" REQUEST ---"); // create the parambean (jParams)... ParamBean jParams = null; try { //////////////////////////////////////////////////////////////////////////// // FIXME -Fulco- : Optimization & Performance issue // // The page access should be checked before creating all the page content, // in order to defer the full cost of the page content creation and // initialization until we actually need to use it. // We should redesign this (even if currently all the pages are loaded // into memory) by using the Proxy design pattern, which does exactly // what we need (page 207-217). // // Maybe we should redesign the ParamBean and/or JahiaData to have a // better control of the creation process of the objects and security // integration. ////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -