亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? exportwebhelper.java

?? java servlet著名論壇源代碼
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/ExportWebHelper.java,v 1.2 2004/01/18 19:13:10 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.2 $
 * $Date: 2004/01/18 19:13:10 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2004 by MyVietnam.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding mvnForum MUST remain intact
 * in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in the
 * footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Igor Manic   imanic@users.sourceforge.net
 */
package com.mvnforum.admin;

import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.mvnforum.*;
import com.mvnforum.admin.importexport.XMLUtil;
import com.mvnforum.admin.importexport.XMLWriter;
import net.myvietnam.mvncore.db.DBUtils;
import net.myvietnam.mvncore.exception.*;

/**
 * @author <a href="mailto:imanic@users.sourceforge.net">Igor Manic</a>
 * @version $Revision: 1.2 $, $Date: 2004/01/18 19:13:10 $
 * <br/>
 * <code>ExportWebHelper</code> todo Igor: enter description
 *
 */
public class ExportWebHelper {

    /** Message log. */
    private static Log log = LogFactory.getLog(ExportWebHelper.class);

    /** Cannot instantiate. */
    private ExportWebHelper() {
        super();
    }


// =================================================================
// ===================== MAIN PUBLIC METHODS =======================
// =================================================================
    public static void exportXml(String filename, HttpServletRequest request,
           int logonMemberID, String logonMemberName,
           Calendar backupTime, String backupIP)
    throws ExportException {
        log.debug("Making backup xml = \""+filename+"\".");
        String filepath = MVNForumConfig.getBackupDir() + File.separatorChar + filename;
        File resultFile = new File(filepath);
        XMLWriter xmlWriter = new XMLWriter("   "/*indentString*/, resultFile);
        try {
            createBackupXml(xmlWriter, backupTime, backupIP);
        } catch (ExportException e) {
            /* xmlWriter.close() will be called again in finally section, but,
             * nevermind, I'll ignore IOException then. Anyway, the most
             * important is that it is called in any case, and here, in case
             * of exception, I must first close xmlWriter, before trying
             * to delete resultFile.
             */
            try {
                xmlWriter.close();
            } catch (IOException ee) {
                log.error("I/O error while closing created XML. Ignoring...");
                //ignore this
            } finally {
                xmlWriter=null;
            }
            if (resultFile!=null) { resultFile.delete(); resultFile=null; }
            throw e; //rethrow; just wanted to ensure bad resultFile is deleted
        } finally {
            //see above section "catch ExportException"
            try {
                xmlWriter.close();
            } catch (IOException e) {
                log.error("I/O error while closing created XML. Ignoring...");
                //ignore this
            } finally {
                xmlWriter=null;
            }
        }
        /*return resultFile;*/ resultFile=null;
    }

    public static void exportZip(String filename, HttpServletRequest request,
           int logonMemberID, String logonMemberName,
           Calendar backupTime, String backupIP)
    throws ExportException {
        log.debug("Making backup zip = \""+filename+"\".");
        // First, make the main XML file, in "temp" directory.
        File mainXmlFile = null;
        try {
            mainXmlFile = File.createTempFile("IMPORT", ".xml", new File(MVNForumConfig.getTempDir()));
            XMLWriter xmlWriter = new XMLWriter("   "/*indentString*/, mainXmlFile);
            try {
                createBackupXml(xmlWriter, backupTime, backupIP);
            } finally {
                xmlWriter.close(); xmlWriter=null;
            }
        } catch (IOException e) {
            log.error("I/O error while creating XML.");
            if (mainXmlFile!=null) { mainXmlFile.delete(); mainXmlFile=null; }
            throw new ExportException("I/O error while creating main XML file.", e);
        } catch (ExportException e) {
            if (mainXmlFile!=null) { mainXmlFile.delete(); mainXmlFile=null; }
            throw e; //rethrow; just wanted to ensure mainXmlFile is deleted
        }

        /* Second, create ZIP file in "backup" directory and add avatarsDir, attachsDir, mainXmlFile.
         * I am adding XML file at the end, since it might be better for import to process
         * XML after the other files are copied. It's not so important, but it's maybe
         * more convenient for the admin to see those file extraction prior to
         * importing XML, since when that XML processing starts, he will be
         * "bombed" with dozens of messages about database items...
         */
        String zipFilePath = MVNForumConfig.getBackupDir() + File.separatorChar + filename;
        String avatarsDir = request.getSession().getServletContext().getRealPath(MVNForumGlobal.UPLOADED_AVATAR_DIR);
        String attachsDir = MVNForumConfig.getAttachmentDir();

        ZipOutputStream out = null;
        try {
            //now create ZIP file
            out = new ZipOutputStream(new FileOutputStream(zipFilePath));
            //Select your choice of STORED (not compressed) or DEFLATED (compressed).
            out.setMethod(ZipOutputStream.DEFLATED);

            //add avatarsDir and attachsDir
            addDirectory(out, new File(avatarsDir), MVNForumConfig.BACKUP_FILE_AvatarsDirNameInZip);
            addDirectory(out, new File(attachsDir), MVNForumConfig.BACKUP_FILE_AttachsDirNameInZip);
            //add mainXmlFile
            addFile(out, mainXmlFile, MVNForumConfig.BACKUP_FILE_MainXmlFileNameInZip);
        } catch (FileNotFoundException e) {
            log.error("Can't find a file that has been created.");
            throw new ExportException("Can't find a file that has been created.", e);
        } catch (IOException e) {
            log.error("I/O error while making ZIP file.");
            try { out.close(); } catch (Exception ee) {}
            out=null;
            try { new File(zipFilePath).delete(); } catch (Exception ee) {}
            throw new ExportException("I/O error while making ZIP file.", e);
        } finally {
            if (out!=null) try { out.flush(); out.close(); } catch (IOException e) {}
            out=null;
            //delete mainXmlFile, so I don't get both XML and ZIP in the backup repository
            if (mainXmlFile!=null) { mainXmlFile.delete(); mainXmlFile=null; }
        }
        /*return new File(zipFilePath);*/
    }

    private static void addFile(ZipOutputStream out, File file, String relativePath)
    throws IOException {
        byte[] buf = new byte[1024];
        FileInputStream in = new FileInputStream(file);

        // Add ZIP entry to output stream.
        out.putNextEntry(new ZipEntry(relativePath));
        //ZipEntry zipentry = new ZipEntry(rgstring[i]);
        //zipentry.setSize(file.length());
        //zipentry.setTime(file.lastModified());
        //out.putNextEntry(zipentry);

        //Transfer bytes from the file to the ZIP file
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }

        // Complete the entry
        in.close(); in=null;
        out.closeEntry();
    }

    private static void addDirectory(ZipOutputStream out, File dir, String relativePath)
    throws IOException {
        if (dir.isFile()) {
            log.error("Called addDirectory on a file \""+dir.getAbsolutePath()+"\".");
            throw new IOException("I/O error while adding directory to ZIP.");
        }
        if (relativePath.length()>0) { //ignore starting directory
            if (!relativePath.endsWith("/")) relativePath+="/";
            // Add ZIP entry to output stream.
            out.putNextEntry(new ZipEntry(relativePath));
            out.closeEntry();
        }
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                if (file.isFile()) {
                    addFile(out, file, relativePath+file.getName());
                } else {
                    addDirectory(out, file, relativePath+file.getName()+"/");
                }
            }
        }
    }


// =================================================================
// ================= MAIN CREATING XML/ZIP METHOD ==================
// =================================================================
    private static void createBackupXml(XMLWriter xmlWriter,
                        Calendar backupTime, String backupIP)
    throws ExportException {
        try {
            xmlWriter.startDocument(MVNForumConstant.dtdschemaDecl);
            String strExportDate = XMLUtil.sqlTimestampToStringDefNow(
                   new Timestamp(backupTime.getTime().getTime()));
            xmlWriter.startElement("mvnforum",
                      new String[]{"version", "1.0",
                                   "exportDate", strExportDate});

            MemberXML.exportMemberList(xmlWriter);
            GroupXML.exportGroupList(xmlWriter);
            CategoryXML.exportCategoryList(xmlWriter);
            RankXML.exportRankList(xmlWriter);

            xmlWriter.endElement("mvnforum");
            xmlWriter.endDocument();
        } catch (IOException e) {
            log.error("I/O error while trying to create backup XML file on server.", e);
            throw new ExportException("", e);
        } catch (ObjectNotFoundException e) {
            log.error("Object not found error while trying to createBackupXml()", e);
            throw new ExportException("Database object not found error while trying to create backup XML file on server.", e);
        } catch (DatabaseException e) {
            log.error("Database error while trying to createBackupXml()", e);
            throw new ExportException("Database error while trying to create backup XML file on server.", e);
        }
    }


// =================================================================
// ======================= UTILITY METHODS =========================
// =================================================================
    public static Collection execSqlQuery(String query)
    throws DatabaseException {
        Connection connection = null;
        PreparedStatement statement = null;
        ResultSet resultSet = null;
        Collection retValue = new ArrayList();
        try {
            connection = DBUtils.getConnection();
            statement = connection.prepareStatement(query);
            resultSet = statement.executeQuery();
            int numCols = resultSet.getMetaData().getColumnCount();
            while (resultSet.next()) {
                String[] thisResult = new String[numCols];
                for (int i=0; i<numCols; i++) {
                    thisResult[i]=resultSet.getString(i+1);
                }
                retValue.add(thisResult);
            }
            return retValue;
        } catch (SQLException sqle) {
            log.error("Sql Execution Error!", sqle);
            throw new DatabaseException("Error executing SQL in ExportWebHelper.execSqlQuery.");
        } finally {
            DBUtils.closeResultSet(resultSet);
            DBUtils.closeStatement(statement);
            DBUtils.closeConnection(connection);
        }
    }


}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩中文字幕亚洲一区二区va在线 | 成人精品gif动图一区| 欧美综合亚洲图片综合区| 久久嫩草精品久久久精品| 91在线精品一区二区| 精品成人一区二区三区四区| 国产成人精品三级麻豆| 最新日韩av在线| 福利电影一区二区| 福利一区在线观看| 一本色道久久综合亚洲aⅴ蜜桃 | 亚瑟在线精品视频| 99在线精品观看| 国产亚洲精品资源在线26u| 日韩电影在线一区二区| 在线国产电影不卡| 一区精品在线播放| 国产成人午夜精品影院观看视频 | 日韩欧美精品三级| 一区二区三区精品视频在线| 国产jizzjizz一区二区| 日韩精品一区二区三区四区视频| 亚洲一区在线视频观看| 国产成人亚洲综合a∨婷婷 | 欧美色精品在线视频| 日本一区二区三区免费乱视频 | 亚洲精品大片www| 成人深夜福利app| 久久综合久色欧美综合狠狠| 美女视频免费一区| 日韩欧美在线网站| 在线观看91精品国产麻豆| 亚洲女同女同女同女同女同69| 国产成人免费网站| 久久久久久久综合狠狠综合| 久久成人免费日本黄色| 日韩三级精品电影久久久 | 国产精品国产精品国产专区不片| 国产一区二区三区精品欧美日韩一区二区三区 | 在线免费观看日本一区| 亚洲欧美日韩国产中文在线| 99视频精品全部免费在线| 国产精品无人区| 成人理论电影网| 亚洲欧洲日本在线| 99久久精品国产一区二区三区| 中文在线一区二区| 972aa.com艺术欧美| 亚洲精品中文在线观看| 欧美性猛片xxxx免费看久爱| 亚洲福利视频导航| 777色狠狠一区二区三区| 日韩中文欧美在线| 欧美变态tickling挠脚心| 精品中文av资源站在线观看| 精品国产麻豆免费人成网站| 国产一区91精品张津瑜| 中文幕一区二区三区久久蜜桃| 成人丝袜18视频在线观看| 国产精品久久久久精k8| 色综合久久综合| 亚洲国产精品欧美一二99| 欧美精品三级日韩久久| 久久国产夜色精品鲁鲁99| 久久久精品欧美丰满| 成人av资源在线| 亚洲综合免费观看高清完整版在线| 欧美图片一区二区三区| 久久精品99国产精品| 国产日韩欧美一区二区三区综合| 99久久伊人精品| 性欧美大战久久久久久久久| 日韩欧美亚洲国产另类| 成人免费毛片嘿嘿连载视频| 亚洲美女免费在线| 欧美一卡在线观看| 国产乱国产乱300精品| 亚洲日本电影在线| 91精品国产91久久久久久一区二区 | 五月天激情综合| 欧美xxxx在线观看| 成人国产电影网| 亚洲一级二级三级在线免费观看| 日韩亚洲欧美在线观看| 成人免费看片app下载| 亚洲一区二区三区中文字幕 | 一本久道久久综合中文字幕| 午夜不卡av免费| 久久久综合视频| 在线看日本不卡| 精品伊人久久久久7777人| 国产精品欧美极品| 56国语精品自产拍在线观看| 国产99久久久精品| 亚洲成va人在线观看| 久久久久99精品国产片| 欧美色中文字幕| 国产精品一区二区黑丝| 亚洲自拍偷拍图区| 国产日韩欧美激情| 正在播放一区二区| 99精品欧美一区二区三区小说| 日本亚洲免费观看| 亚洲男人天堂av网| 久久久99精品久久| 欧美日韩国产不卡| 不卡一区二区三区四区| 蜜臀av一级做a爰片久久| 综合色天天鬼久久鬼色| 久久亚洲精品国产精品紫薇| 欧洲一区二区三区在线| 丁香五精品蜜臀久久久久99网站| 婷婷成人激情在线网| 国产精品初高中害羞小美女文| 日韩欧美国产三级| 欧美日韩综合色| 不卡大黄网站免费看| 久久国产精品99精品国产| 亚洲一区精品在线| 日韩美女视频一区二区| 久久久久久久久岛国免费| 欧美麻豆精品久久久久久| 91在线国产福利| 国产不卡在线视频| 久久国产成人午夜av影院| 天天做天天摸天天爽国产一区 | 日本一区二区三区在线不卡 | av亚洲精华国产精华精华| 国内成人自拍视频| 青青草视频一区| 亚洲一区二区免费视频| 亚洲免费观看高清完整版在线| 久久久综合激的五月天| 日韩精品一区二区三区视频在线观看| 91国在线观看| 色诱视频网站一区| 99久久精品免费看国产免费软件| 激情综合色综合久久综合| 日本伊人午夜精品| 亚洲高清视频的网址| 夜夜揉揉日日人人青青一国产精品| 中文字幕在线一区免费| 国产欧美综合在线观看第十页| 精品美女在线观看| 欧美成人三级在线| 欧美成人精品1314www| 日韩欧美激情在线| 日韩视频免费观看高清完整版| 91精品国产一区二区人妖| 欧美日韩性生活| 欧美日韩国产a| 911精品国产一区二区在线| 欧美日韩一区视频| 6080日韩午夜伦伦午夜伦| 777午夜精品免费视频| 欧美二区三区91| 欧美一区二区大片| 精品国产制服丝袜高跟| 337p粉嫩大胆噜噜噜噜噜91av | 日韩午夜激情视频| 日韩女优毛片在线| 日韩欧美不卡一区| 久久久久久影视| 欧美激情综合五月色丁香| 国产精品久久久久一区二区三区| 国产精品伦一区二区三级视频| 国产精品精品国产色婷婷| 国产精品国产三级国产aⅴ入口| 亚洲欧美综合另类在线卡通| 亚洲日本一区二区三区| 亚洲一级二级三级在线免费观看| 亚洲高清在线精品| 日本不卡不码高清免费观看| 久草这里只有精品视频| 福利一区二区在线观看| 91首页免费视频| 欧美日韩日本视频| 日韩一区二区免费视频| 2023国产精品自拍| 国产精品久久久久一区| 亚洲精品日韩专区silk| 日韩精品乱码免费| 国产一区二区三区久久久 | 韩国欧美一区二区| 成人一区二区三区视频| 色综合中文字幕国产 | 精品国产一区二区三区四区四| 久久久久久麻豆| 亚洲人成网站在线| 日日骚欧美日韩| 国产真实精品久久二三区| 99视频精品全部免费在线| 欧美日韩第一区日日骚| 精品国产乱码久久久久久1区2区| 国产免费久久精品| 亚洲专区一二三| 韩日av一区二区| 色综合久久久久综合| 91精品国产美女浴室洗澡无遮挡| 久久精品男人的天堂|