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

📄 jahiaadministration.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
// $Id: JahiaAdministration.java,v 1.25 2002/06/06 12:45:29 shuber Exp $////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  JahiaAdministration////  27.01.2001  AK  added in jahia.//  29.01.2001  AK  fix a bug when check the database.//  06.02.2001  AK  add server settings methods.//  07.02.2001  AK  replace context attributes by session and request attributes.//  10.01.2001  AK  include design, add base for templates and components.//  13.01.2001  MJ  added user&group management.//  31.03.2001  AK  completely change the properties system.//  01.04.2001  AK  cut the servlet into some beans.//  17.04.2001  AK  change methods processLogin() and isValidLoginSession() to//                  check if the user is member of the "admin" or "superadmin"//                  elitists groups.//  18.04.2001  AK  change method displayMenu() to get all administrator access//                  granted website(s).//  20.04.2001  AK  fix mammouth in userRequestDispatcher() method.//  21.04.2001  AK  set an attribute if the super admin is logged to administrate//                  the server and not an hosted site.//  30.04.2001  AK  administrative log settings are now only available on server//                  mode, because they are not sites-specific.//  16.05.2001  NK  DisplayMenu handle default site created at install.//  12.06.2001  NK  added jef files management////package org.jahia.bin;import java.io.*;                                   // IOException, File, FileWriterimport java.util.*;                                 // Enumerationimport javax.servlet.*;			                    // ServletExceptionimport javax.servlet.http.*;			            // HttpServletRequest, HttpServletResponseimport org.jahia.bin.*;                         // Jahiaimport org.jahia.admin.database.*;              // Database tester, Scripts managerimport org.jahia.admin.server.*;                // Server settingsimport org.jahia.admin.users.*;                 // Manage users, Manage groupsimport org.jahia.admin.pages.*;                 // Pages settingsimport org.jahia.admin.components.*;            // Manage componentsimport org.jahia.admin.templates.*;             // Manage templatesimport org.jahia.admin.audit.*;                 // Manage audit logsimport org.jahia.admin.sites.*;                 // Manage sitesimport org.jahia.admin.jeffiles.*;              // Manage jef filesimport org.jahia.admin.info.*;                  // About Jahiaimport org.jahia.admin.access.*;                // Users Accessimport org.jahia.admin.homepages.*;             // Manage Hompagesimport org.jahia.admin.search.*;             	// Manage Search Engineimport org.jahia.admin.status.*;                 // Manage Server Statisticsimport org.jahia.utils.*;                       // JahiaConsole, DataValidatorimport org.jahia.utils.properties.*;            // PropertiesManagerimport org.jahia.settings.*;                    // JahiaPrivateSettingsimport org.jahia.operations.*;                  // OperationManagerimport org.jahia.params.*;                      // ParamBeanimport org.jahia.registries.*;                  // ServicesRegistryimport org.jahia.exceptions.*;                  // JahiaExceptionimport org.jahia.exceptions.services.ServiceNotFoundException;import org.jahia.services.usermanager.*;        // JahiaUserManagerimport org.jahia.services.sites.*;              // Sites Servicesimport org.jahia.services.pages.*;              // Page Servicesimport org.jahia.data.*;import org.jahia.tools.*;/** * desc:  This servlet handles all general administration tasks. * it requires authentication as a member of the "admin" group (for the * site currently used... or "superadmin" group on the site 0), and provides * a management interface for general context property settings, database * settings, sites, pages, users, user groups, application roles, components, * templates and audit log settings. * * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * * @author Alexandre Kraft * @version 1.0 */public class JahiaAdministration extends HttpServlet implements JahiaInterface{    private static ServletConfig                config;    private static ServletContext               context;    public  static final String                 CLASS_NAME          =  "org.jahia.bin.JahiaAdministration";    public  static final String                 JSP_PATH            =  "/jsp/jahia/administration/";    private static final int                    SUPERADMIN_SITE_ID  =  0;    private static ServicesRegistry             sReg;    private static JahiaUserManagerService      uMgr;    private static JahiaGroupManagerService     gMgr;    static private String                       servletPath     =  null;    private String 								servletURI 		=  null;    public  static String                       installerURL        =  "";    private static JahiaPrivateSettings			jSettings;    private static String                       contentServletPath = null;    static private final String GET_REQUEST 	= "GET";    static private final String POST_REQUEST 	= "POST";    static private final String CONFIG_PATH 	= "config_path";    static private final String INIT_PARAM_CONTENT_SERVLET_PATH = "content_servlet_path";    /** properties filename */    static private final String PROPERTIES_FILENAME = "jahia.properties";    //-------------------------------------------------------------------------    /**     * Default init inherited from HttpServlet. This method set config and     * context static variables.     * @author  Alexandre Kraft     *     * @param   config  Servlet configuration (inherited).     */    public void init( ServletConfig config )    throws ServletException    {        // get servlet config and context...        this.config   = config;        this.context  = config.getServletContext();        this.contentServletPath = config.getInitParameter(INIT_PARAM_CONTENT_SERVLET_PATH);        if (contentServletPath == null) {            JahiaConsole.println("JahiaAdministration.init",                                 "Web app initialization parameter " +                                 INIT_PARAM_CONTENT_SERVLET_PATH +                                 " missing in web.xml deployment descriptor file, use default /Jahia/... ");            contentServletPath = "/Jahia/";        }    } // end init    //-------------------------------------------------------------------------    /**     * Default service inherited from HttpServlet.     * @author  Alexandre Kraft     *     * @param   request     Servlet request (inherited).     * @param   response    Servlet response (inherited).     */    public void service( HttpServletRequest   request,                         HttpServletResponse  response )    throws IOException, ServletException    {        Jahia.copySessionCookieToRootContext(request, response);        // get the current user session...        HttpSession session =  request.getSession(true);        if (this.servletPath == null) {            servletPath = request.getServletPath();        }        if ( Jahia.isInitiated() && !Jahia.checkLockAccess(session) ){            session.setAttribute(CLASS_NAME + "jahiaDisplayMessage","Sorry, Jahia is locked by a super admin. No more access allowed.");            displayLogin( request, response, session );            return;        }        // init host servlet URI        if ( servletURI == null ){            this.servletURI = getServletURI(request, response);        }        // determine installation status...        if(Jahia.getJahiaPropertiesFileName() == null) {                         // jahia is not launched...            request.setAttribute( "jahiaLaunch", "administration" );        // call jahia to init and re-launch admin...            doRedirect( request, response, session, contentServletPath );        } else {                                                            // jahia is running...            if(JahiaTools.checkFileExists( Jahia.getJahiaPropertiesFileName() ))            {                PropertiesManager properties =  new PropertiesManager( Jahia.getJahiaPropertiesFileName() );                installerURL =  request.getContextPath() + properties.getProperty("jahiaEnginesDiskPath");                // get the JahiaPrivate settings and config it with correct values                // change Jahia core http to JahiaAdministration instead of Jahia                jSettings = Jahia.getPrivateSettings();                jSettings.setJahiaCoreHttpPath(this.servletURI);                // set Jahia running mode to Admin                session.setAttribute(ParamBean.SESSION_JAHIA_RUNNING_MODE,new Integer(Jahia.ADMIN_MODE));                JahiaConsole.println("JahiaAdministration","Running mode : " + Jahia.ADMIN_MODE);                if ( Jahia.getLicenseKey() == null ){                    session.setAttribute(CLASS_NAME + "jahiaDisplayMessage","Invalid License");                    displayLogin( request, response, session );                } else {                    try {                        if ( !handleEngines(request,response) )                            userRequestDispatcher( request, response, session );        // ok continue admin...                    } catch ( JahiaException je ){                        JahiaErrorDisplay.DisplayException (request, response, getServletContext(), Jahia.getPrivateSettings(), je);                    }                }            } else {                request.setAttribute( "jahiaLaunch", "installation" );      // call jahia to init and launch install...                doRedirect( request, response, session, contentServletPath );            }        }    } // end service    public static String getServletPath() {        return servletPath;    }    /**     * Static method to generate URLs for the administration. This should be     * used by all JSPs and java code that is called by the administration.     * @param request the current request object, used to generate the context     * path part of the URL     *     * @param response the current response object, used to make a call to     * encodeURL to generate session information in the case that cookies cannot     * be used     * @param doAction a String representing the action we are linking to. This     * is then encoded as a ?do=doAction string     * @param extraQueryParams a string including any other parameters that will     * be directly appended after the doAction string. This is done because this     * way we offer the possibility to do an encodeURL over the whole string.     * Note that this string may be null.     *     * @return a String containing an URL with jsessionid generated and in the     * form : /contextPath/servletPath/?do=doActionextraQueryParams     */    public static String composeActionURL ( HttpServletRequest request,                                            HttpServletResponse response,                                            String doAction,                                            String extraQueryParams ) {        String internalDoAction = "";        String internalQueryParams = "";        if (doAction != null) {            internalDoAction = "/?do=" + doAction;        }        if (extraQueryParams != null) {

⌨️ 快捷键说明

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