📄 circular.java
字号:
package jp.co.sjts.gsession.circular;
/*
* Ciroular 偺儊僀儞 Circular.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.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 Circular extends ModBaseServlet
{
private Hashtable hsInitData=null;
private Properties properties=null;
private CIMainConfFile conf=null;
private CIUserConfFile uconf=null;
private GSDate cal = null;
private GSHtml cnv = null;
private GSBinaryDownLoad temp = null;
private CIRdirectFile cirdirect = null;
private File file = null;
private CIRdirectFile cifile = null;
private CIRdirectData cidata = null;
private CIDirFile tofile = null;
private CIDirData todata = null;
private CINoteFile cinote = null;
private String[] bu1f = null;
private String MapUrl = null;
private IUserManager UM=null;
public void init(ServletConfig config) throws ServletException
{
cal = new GSDate();
super.init(config);
properties = System.getProperties();
hsInitData = new Hashtable();
try{
String CircularDir = getInitParameter(CICmd.CI_DIR);
if(CircularDir!=null){
if(!CircularDir.endsWith("/"))
CircularDir+="/";
String DataDir = CircularDir+"data/";
String UserDir = CircularDir+"user/";
CircularDir = CircularDir.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));
// 儊僀儞乮夞棗斉乯僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file = new File(CircularDir);
if(!file.exists()) // 僼傽僀儖偑懚嵼偡傞偐
{
if(!file.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+CircularDir);
}
// 僨乕僞僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
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);
}
hsInitData.put(CICmd.CI_DIR,CircularDir);
}
else
throw new ServletException("InitParameter not find \"CircularDir\"");
// 儅僢僾梡偺url傪庢摼
MapUrl = getMapURL();
if(MapUrl!=null)
hsInitData.put(CICmd.CI_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 \"HelpUrl\"");
// 婎杮愝掕僼傽僀儖庢摼
conf = new CIMainConfFile((String)hsInitData.get(CICmd.CI_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(CICmd.CI_CIRCULAR)};
hsPara.put(CICmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(CICmd.PA_PAG,value1);
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Circular::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(CICmd.CI_CIRCULAR)};
hsPara.put(CICmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(CICmd.PA_PAG,value1);
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Circular::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
//{
// Createcircular_pop page = new Createcircular_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();
Createcircular_pop page = new Createcircular_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
{
String entuserid = null;
String taitol = null;
String messege = null;
String tmpfile = null;
String tmptype = null;
String limit = 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 sessionUNAME = (String)session.getAttribute(GSBase.SESSION_PARA_UNAME);
String url = GSTool.removeParaFormURI(req.getRequestURI()); //2001.3.1 add ookubo
int cmd = Integer.parseInt((String)((String[])hsPara.get(CICmd.PA_CMD))[0]);
String urlMap = (String)hsInitData.get(CICmd.CI_MAP);
String dataDir = (String)hsInitData.get(CICmd.CI_DIR);
CreatePage page=null;
String[] buf;
// 儐乕僓乕愝掕僼傽僀儖庢摼
uconf = new CIUserConfFile(dataDir,sessionUID.toString());
uconf.Load();
String strpage = (String)((String[])hsPara.get("pag"))[0];
int intpage = Integer.parseInt( strpage );
if(cmd == CICmd.CI_TEMP) {
String path = dataDir + "data" + File.separator + (String)((String[])hsPara.get(CICmd.PA_CID))[0] + File.separator + "noteb" ;
cinote = new CINoteFile(dataDir,(String)((String[])hsPara.get(CICmd.PA_CID))[0],2);
cinote.Get(dataDir,(String)((String[])hsPara.get(CICmd.PA_CID))[0]);
temp = new GSBinaryDownLoad(path,cinote.getTmpfile());
temp.setContentType(cinote.getTmptype()) ;
temp.write(res) ;
return;
}
switch(cmd){
case CICmd.CI_CIRCULAR:// 夞棗斉庴怣堦棗
page = new Createcircular_jushin(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString(),UM);
break;
case CICmd.CI_RECEIRVE://庴怣堦棗
buf = (String[])hsPara.get("send.x");//憲怣嵪傒僼僅儖僟乕
if(buf!=null) {
page = new Createcircular_send(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString());
break;
}
buf = (String[])hsPara.get("new.x");//怴婯夞棗
if(buf!=null) {
/* work note 嶌惉 */
cinote = new CINoteFile(dataDir,sessionUID.toString(),1);
cinote.Delete();
cinote.CINote(sessionUID.toString()," "," "," ","7"," "," "," ");
cinote.Save();
String dir = dataDir + "user" + File.separator + sessionUID.toString() + File.separator + "cirdirect" ;
File file = new File(dir);
if(file.exists())
file.delete();
page = new Createcircular_new(hsInitData,hsPara,intpage,UM,sessionUID.toString());
break;
}
buf = (String[])hsPara.get("pers.x");//屄恖愝掕
if(buf!=null) {
page = new Createcircular_setting(hsInitData,hsPara,intpage,sessionUID.toString(),uconf);
break;
}
buf = (String[])hsPara.get("down.x");//慜儁乕僕
if(buf!=null) {
intpage--;
}
buf = (String[])hsPara.get("up.x");//師儁乕僕
if(buf!=null) {
intpage++;
}
page = new Createcircular_jushin(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString(),UM);
break;
case CICmd.CI_SEND://憲怣堦棗
buf = (String[])hsPara.get("rec.x");
if(buf!=null) {
page = new Createcircular_jushin(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString(),UM);
break;
}
buf = (String[])hsPara.get("new.x");//怴婯夞棗
if(buf!=null) {
/* work note 嶌惉 */
cinote = new CINoteFile(dataDir,sessionUID.toString(),1);
cinote.Delete();
cinote.CINote(sessionUID.toString()," "," "," ","7"," "," "," ");
cinote.Save();
String dir = dataDir + "user" + File.separator + sessionUID.toString() + File.separator + "cirdirect" ;
File file = new File(dir);
if(file.exists())
file.delete();
page = new Createcircular_new(hsInitData,hsPara,intpage,UM,sessionUID.toString());
break;
}
buf = (String[])hsPara.get("pers.x");//屄恖愝掕
if(buf!=null) {
page = new Createcircular_setting(hsInitData,hsPara,intpage,sessionUID.toString(),uconf);
break;
}
buf = (String[])hsPara.get("del.x");//嶍彍
if(buf!=null) {
bu1f = (String[])hsPara.get("cbox");
if(bu1f!=null) {
String msg = "憲怣嵪傒僨乕僞傪嶍彍偟傑偡丅傛傠偟偄偱偡偐丅";
String title = "憲怣嵪傒僨乕僞偺嶍彍";
String IconName = "kakunin.gif";
// String url = GSTool.removeParaFormURI(req.getRequestURI()); //2001.3.1 del ookubo
Para[] paras = new Para[4+bu1f.length];
paras[0] = new Para("action",url);
paras[1] = new Para(CICmd.PA_CMD,Integer.toString(CICmd.CI_S_DEL));
paras[2] = new Para(CICmd.PA_PAG,Integer.toString(intpage));
paras[3] = new Para(CICmd.PA_MOD,"1");
for( int ii=0;ii<bu1f.length;ii++) {
paras[4+ii] = new Para(CICmd.PA_CBOX,bu1f[ii]);
}
CreateMsgPage mpage = new CreateMsgPage(CreateMsgPage.MB_YESNO,CreateMsgPage.ID_POST ,title,msg,paras,urlMap+IconName);
mpage.write(req,res);
return;
}
}
buf = (String[])hsPara.get("down.x");//慜儁乕僕
if(buf!=null) {
intpage--;
}
buf = (String[])hsPara.get("up.x");//師儁乕僕
if(buf!=null) {
intpage++;
}
page = new Createcircular_send(hsInitData,hsPara,intpage,uconf.GetDisplayMax(),sessionUID.toString());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -