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

📄 extractdeploysite.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// $Id: ExtractDeploySite.java,v 1.19 2002/12/16 14:27:02 knguyen Exp $////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////              . . . i n   j a h i a   w e   t r u s t . . .//////  ExtractDeploySite////  23.07.2001  NK  added in jahia.//package org.jahia.admin.sites;import java.io.*;import java.util.*;import java.sql.*;import javax.servlet.*;import javax.servlet.http.*;import org.w3c.dom.*;import org.xml.sax.*;import org.jahia.bin.*;import org.jahia.params.*;import org.jahia.utils.*;import org.jahia.utils.xml.*;import org.jahia.utils.properties.*;import org.jahia.admin.database.*;import org.jahia.data.*;import org.jahia.data.constants.JahiaConstants;import org.jahia.data.applications.ApplicationBean;import org.jahia.services.database.*;import org.jahia.services.sites.*;         		// Site servicesimport org.jahia.services.pages.*;         		// Pages servicesimport org.jahia.services.fields.*;        		// Fields servicesimport org.jahia.services.containers.*;    		// Containers servicesimport org.jahia.services.filemanager.*;   		// Filemanager servicesimport org.jahia.services.usermanager.*;   		// Usermanager servicesimport org.jahia.services.applications.*;  		// Applications servicesimport org.jahia.services.shares.*;  	   		// Applications Sharingimport org.jahia.services.audit.*;  	   		// Logsimport org.jahia.services.acl.*;  	   	   		// Aclsimport org.jahia.services.files.*; 	   	   		// Files ( Big Text )import org.jahia.services.templates_deployer.*;import org.jahia.services.homepages.*;			// Homepage definitions Servicesimport org.jahia.services.search.*;				// Search servicesimport org.jahia.registries.*;             		// ServicesRegistryimport org.jahia.exceptions.*;             		// JahiaException/** * This class is used by the administration to manage site extraction and * redeployment. * * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * * @author Khue Nguyen * @version 1.0 */public class ExtractDeploySite{    private static final String CLASS_NAME   		= "ExtractDeploySite";    private static final String JSP_PATH     		= JahiaAdministration.JSP_PATH;    private static final String mXMLDOC				= "xmldocs";    private static final String mAPPS				= "apps";    private static final String mDATA				= "data";    private static final String mCONTENT            = "content";    private static final String mCONTENT_BIGTEXT    = "bigtext";    private static final String mCONTENT_FILEMANAGER= "filemanager";    private static final String mTEMPLATES			= "templates";    private static final String mXMLPORTLETS		= "xmlportlets";    private static final String mEXTROOTFOLDER		= "site_extraction";    private static final String mFILEMANAGER		= "filemanager";    private static final String mNEW_WEBAPPS		= "new_webapps";    private static final String mNEW_TEMPLATES		= "new_templates";    private static final String mTOMCATWEBAPPS		= "webapps";    private static final String mSEARCHINDEX		= "search_indexes";    private static final String mFIELD_DEFINITIONS  = "field_definitions";    /**     * the server type     */    private static String mServerType				= "";    /**     * Extraction root folder full path     */    private static String mERFFullPath				= "";    /**     * Filemanager root folder full path     */    private static String mFilemanagerFullPath		= "";    private static PropertiesManager   properties;    private static ServletContext      context;    private static ServicesRegistry   sReg;    private static JahiaSitesService  siteServ;    private static byte[] mLock 	  = new byte[1];	private ACLDataFilter aclFilter;    /**     * the extraction folder     */    private String mSiteExtractionFolder			= "";    //--------------------------------------------------------------------------    /**     * Default constructor.     * @author  Khue Nguyen     *     * @param   request       Servlet request.     * @param   response      Servlet response.     * @param   session       Servlet session for the current user.     * @param   context       Servlet context.     */    public ExtractDeploySite( 	HttpServletRequest    request,                                HttpServletResponse   response,                                HttpSession           session,                                ServletContext        context )    throws Throwable    {        this.context =  context;        sReg  =  ServicesRegistry.getInstance();        // load Jahia settings        if ( properties == null ){            properties =  new PropertiesManager( Jahia.getJahiaPropertiesFileName() );            if ( properties == null ){                throw new JahiaException("Error occured while processing your request",                CLASS_NAME+": Cannot load jahia properties file",                JahiaException.CONFIG_ERROR,                JahiaException.ERROR);            }            // set the server type            if ( properties.getProperty("server") == null ){                throw new JahiaException("Error occured while processing your request",                CLASS_NAME+": Cannot retrieve the Type of running Server ",                JahiaException.CONFIG_ERROR,                JahiaException.ERROR);            }            mServerType = properties.getProperty("server").trim();            if ( mServerType.equals("") ){                throw new JahiaException("Error occured while processing your request",                CLASS_NAME+": Cannot retrieve the Type of running Server ",                JahiaException.CONFIG_ERROR,                JahiaException.ERROR);            }            // check extraction root folder            StringBuffer buff = new StringBuffer(                                properties.getProperty("jahiaVarDiskPath").trim());            buff.append(File.separator);            buff.append(mEXTROOTFOLDER);            mERFFullPath = JahiaTools.convertContexted(buff.toString(),context);            // set filemanager directory            buff = null;            buff = new StringBuffer(                                properties.getProperty("jahiaVarDiskPath").trim());            buff.append(File.separator);            buff.append(mFILEMANAGER);            //mFilemanagerFullPath = JahiaTools.convertContexted(buff.toString(),context);            mFilemanagerFullPath = ServicesRegistry.getInstance()                        .getJahiaFilemanagerService().getFileRepositoryRootPath();            File f = new File(mERFFullPath);            if ( !f.isDirectory() ){                // try to create it                f.mkdirs();                if ( !f.isDirectory() || !f.canWrite() ){                    throw new JahiaException("Error occured while processing your request",                    CLASS_NAME+": Cannot create extraction root folder",                    JahiaException.FILE_ERROR,                    JahiaException.ERROR);                }            }        }        if (sReg != null) {            siteServ =  sReg.getJahiaSitesService();        }        userRequestDispatcher( request, response, session );    }    //--------------------------------------------------------------------------    /**     * This method is used like a dispatcher for user requests.     * @author  Khue Nguyen     *     * @param   request       Servlet request.     * @param   response      Servlet response.     * @param   session       Servlet session for the current user.     */    private void userRequestDispatcher( HttpServletRequest    request,                                        HttpServletResponse   response,                                        HttpSession           session )    throws IOException,ServletException {        try {            // clean session            session.setAttribute(CLASS_NAME+"warningMsg",null);            String operation =  request.getParameter("sub");            if(operation.equals("display")) {                displayChoice( request, response, session );            } else if(operation.equals("opchoice")) {                processChoice( request, response, session );            } else if(operation.equals("displayExtract")) {                displayExtract( request, response, session );            } else if(operation.equals("extract")) {                processExtract( request, response, session );            } else if(operation.equals("detail")) {                displayDetail( request, response, session );            } else if(operation.equals("extractlist")) {                displayManageExtractions(request, response, session );            } else if(operation.equals("flush")) {                processFlush(request, response, session );            } else if(operation.equals("displayRestore")) {                displayRestore( request, response, session );            } else if(operation.equals("restore")) {                processRestore( request, response, session );            }        } catch ( Throwable t ){            t.printStackTrace();            request.setAttribute("jahiaDisplayMessage",                                    "An error occured while processing your request");            displayChoice( 	request, response, session );        }    }    //--------------------------------------------------------------------------    /**     * Display the page where the user can choose what he want to do. He can     * choice to extract of deploy site.     *     * @author  Khue Nguyen     *     * @param   request       Servlet request.     * @param   response      Servlet response.     * @param   session       Servlet session for the current user.     */    private void displayChoice( HttpServletRequest    request,                                HttpServletResponse   response,                                HttpSession           session )    throws IOException, ServletException    {        String warningMsg = (String)session.getAttribute(CLASS_NAME+"warningMsg");        if ( warningMsg == null ){            warningMsg = "";        }        request.setAttribute("warningMsg",warningMsg);        JahiaAdministration.doRedirect( request, response, session,                                        JSP_PATH + "extdep_site.jsp" );    }    //--------------------------------------------------------------------------    /**     * Process the operation choice.     *     * @author  Khue Nguyen     *     * @param   request       Servlet request.     * @param   response      Servlet response.     * @param   session       Servlet session for the current user.     */    private void processChoice( HttpServletRequest   request,                                HttpServletResponse  response,                                HttpSession          session )    throws IOException, ServletException    {        JahiaConsole.println(CLASS_NAME+".processChoice","started");        // get form values...        Integer action =  new Integer( (String) request.getParameter("which_action").trim() );        // store the action that the user want...        session.setAttribute(CLASS_NAME + "jahiaWhichAction",  action);        // determine which action are requested...        if(action.intValue() == 1) {            // reset session variables            session.setAttribute(CLASS_NAME + "selSiteIDs",null);            session.setAttribute(CLASS_NAME + "jahiaExtractName","");            session.setAttribute(CLASS_NAME + "jahiaExtractDesc","");            displayExtract( request, response, session );        } else if(action.intValue() == 2) {            // reset session variables            session.setAttribute(CLASS_NAME + "selSiteKeys",null);            displayManageExtractions(request, response, session );        }    }    //--------------------------------------------------------------------------

⌨️ 快捷键说明

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