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

📄 work.java

📁 一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package jp.co.sjts.gsession.work;

/*
 * Work 偺儊僀儞  Work.java
 * Copyright (C) 1999-2000 Japan Total System Co,LTD
 *	  Masakatu O	<ookubo@sjts.co.jp>
 */

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jp.co.sjts.gsession.tools.*;

public class Work extends ModBaseServlet
{
	private Hashtable hsInitData=null;
	private Properties properties=null;
	private WKMainConfFile conf=null;
	private WKUserConfFile uconf=null;
	private WKTempConfFile tconf=null;
	private WKReceivFile wkrecfile = null;
	private WKRouteFile tofile = null;
	private WKRouteData todata = null;
	private WKModirectFile cifile = null;
	private WKModirectData cidata = null;
    private	WKNoteFile cinote = null;
	private GSDate cal = null;
	private GSHtml cnv = null;
	private GSBinaryDownLoad temp = null;
	private GSDspDownLoad dsp = null;
	private String[] bu1f = null;
	private File file = null;
	private IUserManager UM=null;
	private IUser	IU=null;
	private String MapUrl = null;

	public void init(ServletConfig config) throws ServletException
	{
		cal = new GSDate();

		super.init(config);
		properties = System.getProperties();
		hsInitData = new Hashtable();

		try{
			String WorkDir = getInitParameter(WKCmd.WK_DIR);
			if(WorkDir!=null){
  				if(!WorkDir.endsWith("/"))
  					WorkDir+="/";
				String DataDir = WorkDir+"data/";
				String UserDir = WorkDir+"user/";
				String TempDir = WorkDir+"temp/";
				WorkDir = WorkDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
				DataDir = DataDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
				UserDir = UserDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
				TempDir = TempDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

				// 儊僀儞乮儚乕僋僼儘乕乯僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
				try{
					File file = new File(WorkDir);
					if(!file.exists())	{	// 僼傽僀儖偑懚嵼偡傞偐
						if(!file.mkdirs()) {	// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
							throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
						}
					}
				} catch (SecurityException e) {
					throw new ServletException("傾僋僙僗尃僄儔乕:"+WorkDir);
				}

				// 僨乕僞僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
				try{
					File file1 = new File(DataDir);
					if(!file1.exists()) {		// 僼傽僀儖偑懚嵼偡傞偐
						if(!file1.mkdirs()) {	// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
							throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
						}
					}
				} catch (SecurityException e) {
					throw new ServletException("傾僋僙僗尃僄儔乕:"+DataDir);
				}

				// 儐乕僓乕僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
				try{
					File file2 = new File(UserDir);
					if(!file2.exists()) {		// 僼傽僀儖偑懚嵼偡傞偐
						if(!file2.mkdirs()) {	// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
							throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
						}
					}
				} catch (SecurityException e) {
					throw new ServletException("傾僋僙僗尃僄儔乕:"+UserDir);
				}

				// 儐乕僓乕僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
				try{
					File file3 = new File(TempDir);
					if(!file3.exists()) {		// 僼傽僀儖偑懚嵼偡傞偐
						if(!file3.mkdirs()) {	// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
							throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
						}
					}
				} catch (SecurityException e) {
					throw new ServletException("傾僋僙僗尃僄儔乕:"+TempDir);
				}

				hsInitData.put(WKCmd.WK_DIR,WorkDir);
			}
			else
				throw new ServletException("InitParameter not find \"WorkDir\"");

			// 儅僢僾梡偺url傪庢摼
			MapUrl = getMapURL();
			if(MapUrl!=null)
				hsInitData.put(WKCmd.WK_MAP,MapUrl);
			else
				throw new ServletException("InitParameter not find \"MapDir\"");

			// 梡偺url傪庢摼
			String HelpUrl = getHelpURL();
			if(HelpUrl!=null)
				hsInitData.put("help",HelpUrl);
			else
				throw new ServletException("InitParameter not find \"HelpDir\"");

			// 婎杮愝掕僼傽僀儖庢摼
			conf = new WKMainConfFile((String)hsInitData.get(WKCmd.WK_DIR));
			conf.Load();

		} catch (Exception e) {
			throw new ServletException(e.toString());
		}
	}


	public void destroy()
	{

		super.destroy();
	}


	public void GSdoGet(Hashtable hsPara,HttpServletRequest req,HttpServletResponse res)
		throws ServletException, IOException
	{
		try {
			// 僷儔儊乕僞側偟偺帪偼MAIN儁乕僕偲偡傞
			if(hsPara == null) {
				hsPara = new Hashtable();
				String[] value = {Integer.toString(WKCmd.WK_WORK)};
				hsPara.put(WKCmd.PA_CMD,value);
				String[] value1 = {"0"};
				hsPara.put(WKCmd.PA_PAG,value1);
				String[] value2 = {"0"};
				hsPara.put(WKCmd.PA_MOD,value2);
			}
			Dispatch(hsPara,req,res);
		} catch(Exception e) {
			log("Work::GSdoGet",e);
			CreateErrorPage epage = new CreateErrorPage(CreateErrorPage.ERR
														,MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
			epage.write(req,res);
			return;
		}
	}

	public void GSdoPost(Hashtable hsPara,HttpServletRequest req,HttpServletResponse res)
		throws ServletException, IOException
	{
		try {
			// 僷儔儊乕僞側偟偺帪偼MAIN儁乕僕偲偡傞
			if(hsPara == null) {
				hsPara = new Hashtable();
				String[] value = {Integer.toString(WKCmd.WK_WORK)};
				hsPara.put(WKCmd.PA_CMD,value);
				String[] value1 = {"0"};
				hsPara.put(WKCmd.PA_PAG,value1);
				String[] value2 = {"0"};
				hsPara.put(WKCmd.PA_MOD,value2);
			}
			Dispatch(hsPara,req,res);
		} catch(Exception e) {
			log("Work::GSdoPost",e);
			CreateErrorPage epage = new CreateErrorPage(CreateErrorPage.ERR
														,MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
			epage.write(req,res);
			return;
		}
	}


	//public void GSMainBodyWrite(PrintWriter pw,String url,int uid)
	//	throws GSException
	//{
	//	CreateWork_pop page = new CreateWork_pop(hsInitData,Integer.toString(uid));
	//	page.write(pw,url);
	//}
    
    /**
     *<p>儊僀儞夋柺傊偺弌椡(廋惓)
     *
     * @param mbp MainBodyParam
     * @exception GSException
     */
    public void GSMainBodyWrite(MainBodyParam mbp)
		throws GSException
	{
        PrintWriter pw = mbp.getWriter();
        String url = mbp.getMyUrl();
        int uid = mbp.getUid();
        
		CreateWork_pop page = new CreateWork_pop(hsInitData,Integer.toString(uid));
		page.write(pw,url);
	}

	public String getServletInfo()
	{
		return "Group Session Servlet ver. 1.1";
	}

	private void Dispatch(Hashtable hsPara,HttpServletRequest req,HttpServletResponse res)
		throws GSException
	{
		// 僨僶僢僋
		try {

		String entuserid = null;
		String taitol = null;
		String messege = null;
		String tmpfile = null;
		String tmptype = null;
		String timestamp = null;
		String mode = null;

		UM = getUserManager(req);

		HttpSession session = req.getSession(false);
		Integer sessionUID = (Integer)session.getAttribute(GSBase.SESSION_PARA_UID);
		String MainUrl = getMainURL();

		String url = GSTool.removeParaFormURI(req.getRequestURI());
		int cmd = Integer.parseInt((String)((String[])hsPara.get(WKCmd.PA_CMD))[0]);
		String urlMap = (String)hsInitData.get(WKCmd.WK_MAP);
		String dataDir = (String)hsInitData.get(WKCmd.WK_DIR);
		CreatePage page=null;
		String[] buf;
		String[] skey = {"0"};

		// 儐乕僓乕愝掕僼傽僀儖庢摼
		uconf = new WKUserConfFile(dataDir,sessionUID.toString());
		uconf.Load();

		// 僥儞僾儗乕僩愝掕僼傽僀儖庢摼
		tconf = new WKTempConfFile(dataDir);
		tconf.Load();

		if(cmd == WKCmd.WK_TEMP_ON) {	// 僥儞僾儗乕僩嶲徠夋柺昞帵
			page = new CreateWork_temp_sel(hsInitData,hsPara);
			page.write(req,res);
			return;
		}


		if(cmd == WKCmd.WK_TEMP_SEL) {	//僥儞僾儗乕僩嶲徠揥奐
			String id = (String)((String[])hsPara.get(WKCmd.PA_WID))[0];
        	WKTempFile tfile = new WKTempFile(dataDir);
            WKTempData tdata = tfile.GetMOD(id);//柧嵶撉傒崬傒

			String path = dataDir + "temp" + File.separator + id ;
			dsp = new  GSDspDownLoad(path,tdata.GetFilename(),tdata.GetType());
			dsp.write(res) ;
			return;
		}


		String strpage = (String)((String[])hsPara.get("pag"))[0];
		int intpage = Integer.parseInt( strpage );

		if(cmd == WKCmd.WK_TEMP) {
			buf = (String[])hsPara.get(WKCmd.PA_MO2);//
			int i_mode = 0 ;
			String path1 = "" ;
			if(buf==null) {
				path1 = "data" + File.separator + "motion" + File.separator ;
			}else{
				mode = (String)((String[])hsPara.get(WKCmd.PA_MO2))[0] ;
				if(Integer.parseInt( mode ) == 0) {
					path1 = "data" + File.separator + "motion" + File.separator ;
				}else{
					path1 = "data" + File.separator + "complete" + File.separator ;
					i_mode = 1 ;
				}
			}
            cinote = new WKNoteFile(dataDir,(String)((String[])hsPara.get(WKCmd.PA_WID))[0] ,i_mode);
            cinote.Get(dataDir,(String)((String[])hsPara.get(WKCmd.PA_WID))[0] ,i_mode);

			String path = dataDir + path1 + (String)((String[])hsPara.get(WKCmd.PA_WID))[0] + File.separator + "noteb" ;
			temp = new  GSBinaryDownLoad(path,cinote.getTmpfile());
			temp.setContentType(cinote.getTmptype()) ;
			temp.write(res) ;
			return;
		}

		WKAdminFile wkaf = new WKAdminFile(dataDir);
		boolean admin = wkaf.Chkuid(sessionUID) ;

		boolean backflg = false ;
		switch(cmd){


		case WKCmd.WK_WORK:// 儚乕僋僼儘乕 儊僀儞
			page = new CreateWork_receive(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString(),conf,UM);
			break;


		case WKCmd.WK_RECEIVE://儚乕僋僼儘乕 (庴怣僼僅儖僟乕)
			buf = (String[])hsPara.get("app_mnt.x");//怽惪拞彂椶娗棟
			if(buf!=null) {
                        	if(superUserCheck(sessionUID.intValue(),req,res,url,0,admin)) return;
				page = new CreateWork_app_mnt(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),UM);
				break;
			}
			buf = (String[])hsPara.get("acc_mnt.x");//姰椆彂椶娗棟
			if(buf!=null) {
				if(superUserCheck(sessionUID.intValue(),req,res,url,1,admin)) return;
				hsPara.put(WKCmd.PA_SORTKEY,skey);
				page = new CreateWork_acc_mnt(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString(),UM);
				break;
			}
			buf = (String[])hsPara.get("new.x");//怴婯嶌惉
			if(buf!=null) {
				if(superUserCheck(sessionUID.intValue(),req,res,url,2,admin)) return;
				IU = UM.getUser(sessionUID.intValue());
				/* work note 嶌惉  */

⌨️ 快捷键说明

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