📄 schedule.java
字号:
package jp.co.sjts.gsession.schedule;
/*
* Copyright (C) 1999-2002 Japan Total System Co,LTD
*
*/
import java.util.Iterator;
import java.util.Collection;
import java.io.IOException;
import java.io.File;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Properties;
import java.util.List;
import java.util.Map;
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.*;
/**
* 僗働僕儏乕儖偺儊僀儞僋儔僗偱偡丅<BR><BR>
*
* @author Ei Kishida <ei@sjts.co.jp>
* @author Hideyuki Kitade <kitade@sjts.co.jp>
* @author Masako IWAMOTO <masako@sjts.co.jp@gt;
*/
public class Schedule extends ModBaseServlet{
private Hashtable hsInitData=null;
private Properties properties=null;
private SCConfGroupFile gconf=null;
private SCConfUserFile uconf=null;
private SCScheFile sfile=null;
private SCConfFile conf=null;
private String mainURL = null;
private String MapUrl = null;
private GSDate cal = null;
private GSHtml cnv = null;
private IUserManager UM=null;
private String today;
private File file;
private SCMsgData mdata;
private String strErrPara; //僄儔乕僷儔儊乕僞乕
public void init(ServletConfig config) throws ServletException{
cal = new GSDate();
today = cal.getYMD();
super.init(config);
properties = System.getProperties();
hsInitData = new Hashtable();
try{
// 僨乕僞奿擺梡偺僨傿儗僋僩儕傪庢摼(椺丗"c:\DATADIR\")
String ScheDir = getInitParameter(SCCmd.SC_DIR);
if(ScheDir!=null){
if(!ScheDir.endsWith("/"))
ScheDir+="/";
String UserDir = ScheDir+SCCmd.SC_USER+"/"; //儐乕僓
String GroupDir = ScheDir+SCCmd.SC_GROUP+"/"; //僌儖乕僾
UserDir = UserDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
GroupDir = GroupDir.replace('/',this.properties.getProperty("file.separator").charAt(0));
// 儊僀儞乮柤巋娗棟乯僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file = new File(ScheDir);
if(!file.exists()) // 僼傽僀儖偑懚嵼偡傞偐
{
if(!file.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
hsInitData.put(SCCmd.SC_DIR,ScheDir);
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+ScheDir);
}
// 儐乕僓僨乕僞僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file1 = new File(UserDir);
if(!file1.exists()) // 僼傽僀儖偑懚嵼偡傞偐
{
if(!file1.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
hsInitData.put(SCCmd.SC_USER,UserDir);
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+UserDir);
}
// 僌儖乕僾僨乕僞僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file1 = new File(GroupDir);
if(!file1.exists()) // 僼傽僀儖偑懚嵼偡傞偐
{
if(!file1.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
hsInitData.put(SCCmd.SC_GROUP,GroupDir);
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+GroupDir);
}
}
else
throw new ServletException("InitParameter not find \"ScheduleDir\"");
// 儅僢僾梡偺url傪庢摼
MapUrl = getMapURL();
if(MapUrl!=null)
hsInitData.put(SCCmd.SC_MAP,MapUrl);
else
throw new ServletException("InitParameter not find \"MapDir\"");
// 儊僀儞偺URL傪庢摼
mainURL = getMainURL();
if(mainURL!=null)
hsInitData.put(SCCmd.SC_MAIN,mainURL);
else
throw new GSException("弶婜抣偺庢摼偵幐攕(儊僀儞倀俼俴)");
//Help偺URL傪庢摼
String HelpUrl = getHelpURL();
if(HelpUrl!=null){
hsInitData.put("help",HelpUrl); //僴僢僔儏偵搊榐
}else{
throw new ServletException("InitParameter not find \"HelpDir\"");
}
} catch (Exception e) {
throw new ServletException(e.toString());
}
}
public void destroy(){
super.destroy();
}
/**
* GET偱巜掕偟偨僨乕僞傪庢摼偟傑偡丅
*
* @param hsPara 僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 僒乕僽儗僢僩儕僋僄僗僩
* @param res 僒乕僽儗僢僩儗僗億儞僗
*/
public void GSdoGet(Hashtable hsPara,
HttpServletRequest req,
HttpServletResponse res
) throws ServletException, IOException {
try {
if(hsPara == null) {
hsPara = new Hashtable();
String[] value = {Integer.toString(SCCmd.CD_WEEK)};
hsPara.put(SCCmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(SCCmd.PA_MOD,value1);
HttpSession session = req.getSession(false);
Integer ssUID = (Integer)session.getAttribute(GSBase.SESSION_PARA_UID);
String[] value2 = {ssUID.toString()};
hsPara.put(SCCmd.PA_UID,value2);
/* 2001/2/15
UM = getUserManager();
if(Integer.parseInt(ssUID.toString())!=0)
{
IUser iuser = UM.getUser(Integer.parseInt(ssUID.toString()));
String[] value3 = {Integer.toString(iuser.getDefaultGroup())};
hsPara.put(SCCmd.PA_GID,value3);
}else{
String[] value4 = {"-1"};
hsPara.put(SCCmd.PA_GID,value4);
}
*/
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Schedule::GSdoGet",e);
CreateErrorPage epage = new CreateErrorPage("僨乕僞偺庢摼偵幐攕偟傑偟偨",MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
epage.write(req,res);
return;
}
}
/**
* 億僗僩偱巜掕偟偨僨乕僞傪庢摼偟傑偡丅
*
* @param hsPara 僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 僒乕僽儗僢僩儕僋僄僗僩
* @param res 僒乕僽儗僢僩儗僗億儞僗
*/
public void GSdoPost(Hashtable hsPara ,
HttpServletRequest req ,
HttpServletResponse res
) throws ServletException, IOException {
try {
if(hsPara == null)
{
hsPara = new Hashtable();
String[] value = {Integer.toString(SCCmd.CD_WEEK)};
hsPara.put(SCCmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(SCCmd.PA_MOD,value1);
HttpSession session = req.getSession(false);
Integer ssUID = (Integer)session.getAttribute(GSBase.SESSION_PARA_UID);
String[] value2 = {ssUID.toString()};
hsPara.put(SCCmd.PA_UID,value2);
/* 2001/02/15
UM = getUserManager();
if(Integer.parseInt(ssUID.toString())!=0)
{
IUser iuser = UM.getUser(Integer.parseInt(ssUID.toString()));
String[] value3 = {Integer.toString(iuser.getDefaultGroup())};
hsPara.put(SCCmd.PA_GID,value3);
}else{
String[] value4 = {"-1"};
hsPara.put(SCCmd.PA_GID,value4);
}
*/
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Schedule::GSdoPost",e);
CreateErrorPage epage = new CreateErrorPage("僨乕僞偺庢摼偵幐攕偟傑偟偨",MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
epage.write(req,res);
return;
}
}
/**
* 僗働僕儏乕儖偺儊僀儞娭悢偱偡丅
*
* @param hsPara 僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 僒乕僽儗僢僩儕僋僄僗僩
* @param res 僒乕僽儗僢僩儗僗億儞僗
*/
private void Dispatch(Hashtable hsPara,
HttpServletRequest req,
HttpServletResponse res
) throws GSException {
GSDate caltoday = new GSDate();
today = caltoday.getYMD();
HttpSession session = req.getSession(false);
Integer sessionUID = (Integer)session.getAttribute(GSBase.SESSION_PARA_UID);
String sessionUNAME = (String)session.getAttribute(GSBase.SESSION_PARA_UNAME);
String uid = (hsPara.get(SCCmd.PA_UID)!=null)?(String)((String[])hsPara.get(SCCmd.PA_UID))[0]:sessionUID.toString();
UM = getUserManager(req);
String gid = "-1";
if (hsPara.get(SCCmd.PA_GID) != null){
gid = (String)((String[])hsPara.get(SCCmd.PA_GID))[0];
}else{
if(Integer.parseInt(uid)!=0){
IUser iuser = UM.getUser(Integer.parseInt(uid));
//String[] value3 = {Integer.toString(iuser.getDefaultGroup())};
//hsPara.put(SCCmd.PA_GID,value3);
gid = Integer.toString(iuser.getDefaultGroup());
}
}
//String gid = (hsPara.get(SCCmd.PA_GID)!=null)?(String)((String[])hsPara.get(SCCmd.PA_GID))[0]:"-1";
int cmd = Integer.parseInt((String)((String[])hsPara.get(SCCmd.PA_CMD))[0]);
int mod = Integer.parseInt((String)((String[])hsPara.get(SCCmd.PA_MOD))[0]);
String hiduke = (hsPara.get(SCCmd.PA_DATE)!=null)?(String)((String[])hsPara.get(SCCmd.PA_DATE))[0]:today;
String yymmdd = (hsPara.get(SCCmd.PA_EDATE)!=null)?((String)((String[])hsPara.get(SCCmd.PA_EDATE))[0]):hiduke;
String mid = (hsPara.get(SCCmd.PA_MID)!=null)?(String)((String[])hsPara.get(SCCmd.PA_MID))[0]:"-1";
String sid = (hsPara.get(SCCmd.PA_SID)!=null)?(String)((String[])hsPara.get(SCCmd.PA_SID))[0]:"-1";
String groid = (hsPara.get("sc_grp")!=null)?(String)((String[])hsPara.get("sc_grp"))[0]:"-1";
if(Integer.parseInt(groid)!=-1){
gid = groid;
}
String grid = (hsPara.get(SCCmd.PA_GRP)!=null)?(String)((String[])hsPara.get(SCCmd.PA_GRP))[0]:"-1";
String sub = (hsPara.get(SCCmd.PA_SUB)!=null)?(String)((String[])hsPara.get(SCCmd.PA_SUB))[0]:Integer.toString(SCCmd.CD_WEEK);
String euid = (hsPara.get(SCCmd.PA_USER)!=null)?(String)((String[])hsPara.get(SCCmd.PA_USER))[0]:sessionUID.toString();
//強嵼
String shozai = (hsPara.get(SCCmd.PA_SHOZAI)!=null)?(String)((String[])hsPara.get(SCCmd.PA_SHOZAI))[0]:"0";
String dataDir = (String)hsInitData.get(SCCmd.SC_DIR);
String userDir = (String)hsInitData.get(SCCmd.SC_USER);
String groupDir = (String)hsInitData.get(SCCmd.SC_GROUP);
CreatePage page=null;
String[] buf;
String[] buf1;
int[] buf2;
cal.setYMD(hiduke);
//僄儔乕帪偺僷儔儊乕僞愝掕
String url = GSTool.removeParaFormURI(req.getRequestURI());
strErrPara = url + "?"
+ SCCmd.PA_CMD + "=" + cmd + "&"
+ SCCmd.PA_MOD + "=" + mod + "&"
+ SCCmd.PA_UID + "=" + uid + "&"
+ SCCmd.PA_DATE + "=" + hiduke + "&"
+ SCCmd.PA_EDATE + "=" + yymmdd + "&"
+ SCCmd.PA_GID + "=" + gid + "&"
+ SCCmd.PA_MID + "=" + mid + "&"
+ SCCmd.PA_SID + "=" + sid + "&"
+ SCCmd.PA_GRP + "=" + grid + "&"
+ SCCmd.PA_SUB + "=" + sub + "&"
+ SCCmd.PA_USER + "=" + euid + "&"
+ SCCmd.PA_SHOZAI + "=" + shozai + "&"
+ SCCmd.SC_MAP + "=" + MapUrl + "&"
+ SCCmd.SC_DIR + "=" + dataDir + "&"
+ SCCmd.SC_USER + "=" + userDir + "&"
+ SCCmd.SC_GROUP + "=" + groupDir;
switch(cmd){
case SCCmd.CD_WEEK:// 僗働僕儏乕儖乮廡娫乯
buf = (String[])hsPara.get("zweek.x");//慜廡
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()-7);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("zday.x");//慜擔
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()-1);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("tday.x");//崱擔
if(buf!=null) {
cal.setYMD(today);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("yday.x");//梻擔
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()+1);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("yweek.x");//梻廡
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()+7);
hiduke = cal.getYMD();
}
page = new Createsche_week(hsInitData,hsPara,UM,mod,hiduke,gid,getHoliday(cal.getstrYear()));
break;
case SCCmd.CD_MONTH:// 僗働僕儏乕儖乮寧娫)
buf = (String[])hsPara.get("zmon.x");//慜寧
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth()-1,cal.getDay());
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("kmon.x");//摉寧
if(buf!=null) {
cal.setYMD(today);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("ymon.x");//梻寧
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth()+1,cal.getDay());
hiduke = cal.getYMD();
}
page = new Createsche_month(hsInitData,hsPara,UM,mod,hiduke,gid,euid,getHoliday(cal.getstrYear()));
break;
case SCCmd.CD_DAY:// 僗働僕儏乕儖乮擔娫乯
buf = (String[])hsPara.get("zweek.x");//慜廡
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()-7);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("zday.x");//慜擔
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()-1);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("tday.x");//崱擔
if(buf!=null) {
cal.setYMD(today);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("yday.x");//梻擔
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()+1);
hiduke = cal.getYMD();
}
buf = (String[])hsPara.get("yweek.x");//梻廡
if(buf!=null) {
cal.setYMD(cal.getYear(),cal.getMonth(),cal.getDay()+7);
hiduke = cal.getYMD();
}
page = new Createsche_day(hsInitData,hsPara,UM,mod,hiduke,gid,euid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -