📄 gsession.java
字号:
//擔晅傪愝掕
String year = null;
if( (buf = (String[])hsPara.get(GSCmd.GS_PARA_DATE)) != null)
year = buf[0];
else
year = (new GSDate()).getstrYear();
Holiday holiday = new Holiday(new File(getRootDir()),year);
if( (buf2 = (String[])hsPara.get(GSCmd.GS_PARA_SUBCMD)) != null) {
//曄峏夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_CHG ) {
page = new CreateHoliday_Change(hsPara,holiday,getMapURL(),getHelpURL());
break;
}
//捛壛夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_ADD ) {
page = new CreateHoliday_Make(hsPara,year,getMapURL(),getHelpURL());
break;
}
//媥擔僥儞僾儗乕僩堦棗夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_TMP ) {
page = new CreateHoliday_Temp(hsPara,year,new File(getRootDir()),getMapURL(),getHelpURL());
break;
}
String[] buf3;
String back = "0";
if( (buf3 = (String[])hsPara.get(GSCmd.GS_PARA_BACKPAGE)) != null)
back = buf3[0];
//媥擔僥儞僾儗乕僩曇廤夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_TMPEDIT ) {
//媥擔僥儞僾儗乕僩捛壛夋柺昞帵
if( hsPara.get(GSCmd.GS_PARA_ADDPAGEX) != null ) {
page = new CreateHoliday_Temp_Make(hsPara,year,back,getMapURL(),getHelpURL());
break;
}
page = new CreateHoliday_Temp_Edit(hsPara,year,back,new File(getRootDir()),getMapURL(),getHelpURL());
break;
}
//媥擔僥儞僾儗乕僩捛壛(奼挘)夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_TMPADD2 ) {
page = new CreateHoliday_Temp_Make2(hsPara,year,back,getMapURL(),getHelpURL());
break;
}
//媥擔僥儞僾儗乕僩曄峏夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_TMPCHG ) {
page = new CreateHoliday_Temp_Change(hsPara,year,back,new File(getRootDir()),getMapURL(),getHelpURL());
break;
}
//媥擔僥儞僾儗乕僩曄峏(奼挘)夋柺昞帵
if( Integer.parseInt(buf2[0]) == GSCmd.SUB_HDAY_TMPCHG2 ) {
page = new CreateHoliday_Temp_Change2(hsPara,year,back,new File(getRootDir()),getMapURL(),getHelpURL());
break;
}
}
page = new CreateHoliday(hsPara,holiday,getRootDir(),getMapURL(),getHelpURL());
break;
}
case GSCmd.GS_SHAIN_MAP:{ //幨恀昞帵
int uid = -1;
if((buf=(String[])hsPara.get(GSCmd.GS_PARA_UID))!=null) {
uid = Integer.parseInt(buf[0]);
}
if(uid<=0) {
return;
}
GSGifDownLoad gifdf= new GSGifDownLoad(getRootDir()+GSFilename.GS_DIR_USER
+File.separator+Integer.toString(uid)
+File.separator+User.PICNAME,"shashin.gif");
gifdf.write(res);
return;
}
case GSCmd.GS_SHAININFO:{//幮堳忣曬
int subcmd=(hsPara.get(GSCmd.GS_PARA_SUBCMD)!=null)?
Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_SUBCMD))[0]):-1;
if((buf=(String[])hsPara.get(GSCmd.GS_PARA_TOUID))!=null) {
if(buf[0].length() > 0) {
subcmd=(hsPara.get(GSCmd.GS_PARA_FLG)!=null)?
Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_FLG))[0]):-1;
String backurl = "?"+GSCmd.GS_PARA_CMD+"="+Integer.toString(cmd)
+"&"+GSCmd.GS_PARA_SUBCMD+"="+Integer.toString(subcmd)
+"&"+GSCmd.GS_PARA_FLG+"="+((String[])hsPara.get(GSCmd.GS_PARA_FLG))[0];
if(hsPara.get(GSCmd.GS_PARA_IDX2) != null)
backurl += "&"+GSCmd.GS_PARA_IDX+"="+((String[])hsPara.get(GSCmd.GS_PARA_IDX2))[0];
if(hsPara.get(GSCmd.GS_PARA_GID2) != null)
backurl += "&"+GSCmd.GS_PARA_GID+"="+((String[])hsPara.get(GSCmd.GS_PARA_GID2))[0];
try {
IUser user = usermanager.getUser(Integer.parseInt(buf[0]));
MailAddress toAddress = new MailAddress();
toAddress.addTO(user.getName(), user.getEmail());
session.setAttribute(GSBase.SESSION_MAIL_ADDRESS, toAddress);
backurl = req.getServletPath() + backurl;
session.setAttribute(GSBase.SESSION_SENDBACK_URL, backurl);
RequestDispatcher maildispatcher = req.getRequestDispatcher(getMailerURL());
maildispatcher.forward(req, res);
break;
} catch(Exception e) {
backurl = GSTool.removeParaFormURI(req.getRequestURI()) + backurl;
page = new CreateErrorPage("儊乕儔乕夋柺偵堏摦偱偒傑偣傫偱偟偨丅", getMapURL(), backurl);
break;
}
}
}
try {
//嶌惉
if(hsPara.get(GSCmd.GS_PARA_CREATEX) != null) {
res.setContentType("application/octet-stream; charset=EUC-JP");
OutputStream os = res.getOutputStream();
res.setHeader("Content-Disposition","attachment; filename=ShainData.csv");
res.setHeader("Content-Description","file download");
String[] elementids = (String[])hsPara.get(GSCmd.GS_PARA_ELEMENTS);
UserCsvFile csvfile = new UserCsvFile(os, usermanager, elementids);
String[] uids = (String[])hsPara.get(GSCmd.GS_PARA_UID);
if(uids != null) {
for(int i=0; i < uids.length; i++) {
csvfile.setCsvRecord(uids[i]);
}
String encode = ((String[])hsPara.get(GSCmd.GS_PARA_ENCODE))[0];
if(Integer.parseInt(encode) == 0)
csvfile.setEncode("SJIS");
else
csvfile.setEncode("EUCJIS");
csvfile.Save();
}
break;
}
} catch(Exception e) {
String errurl = GSTool.removeParaFormURI(req.getRequestURI())+"?"+GSCmd.GS_PARA_CMD+"="+GSCmd.GS_SHAININFO+"&"+GSCmd.GS_PARA_SUBCMD+"="+GSCmd.SUB_SHAIN_NAME;
page = new CreateErrorPage(CreateErrorPage.ERR, getMapURL(), errurl);
break;
}
if(hsPara.get(GSCmd.GS_PARA_NAMETABX) != null) {
subcmd = GSCmd.SUB_SHAIN_NAME;
} else if(hsPara.get(GSCmd.GS_PARA_EMAILTABX) != null) {
subcmd = GSCmd.SUB_SHAIN_EMAIL;
} else if(hsPara.get(GSCmd.GS_PARA_GROUPTABX) != null) {
hsPara.remove(GSCmd.GS_PARA_INDEXS);
subcmd = GSCmd.SUB_SHAIN_GROUP;
} else if(hsPara.get(GSCmd.GS_PARA_SETX) != null) {
subcmd = GSCmd.SUB_SHAIN_PSET;
} else if(hsPara.get(GSCmd.GS_PARA_EXPORTX) != null) {
subcmd = GSCmd.SUB_SHAIN_EXPORT;
}
if(getIndex(hsPara) > 0) {
String[] idx = new String[1];
idx[0] = Integer.toString(getIndex(hsPara));
hsPara.put(GSCmd.GS_PARA_IDX, idx);
}
// 慖戰
if(hsPara.get(GSCmd.GS_PARA_SELECTX) != null)
hsPara.put(GSCmd.GS_PARA_SELECTION, "1");
// 慡偰夝彍
if(hsPara.get(GSCmd.GS_PARA_ALLRELEASEX) != null)
hsPara.remove(GSCmd.GS_PARA_UID);
// 僄僋僗億乕僩
if(subcmd == GSCmd.SUB_SHAIN_EXPORT) {
if(hsPara.get(GSCmd.GS_PARA_BACKX) != null) {
subcmd = Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_BACKPAGE))[0]);
} else {
if(hsPara.get(GSCmd.GS_PARA_FLG) != null) {
hsPara.put(GSCmd.GS_PARA_BACKPAGE, ((String[])hsPara.get(GSCmd.GS_PARA_FLG))[0]);
} else if(hsPara.get(GSCmd.GS_PARA_BACKPAGE) != null) {
hsPara.put(GSCmd.GS_PARA_BACKPAGE, ((String[])hsPara.get(GSCmd.GS_PARA_BACKPAGE))[0]);
}
page = new CreateShainExportPage(hsPara,getMapURL(),getHelpURL());
break;
}
}
MailerFile mailerFile=new MailerFile(getRootDir()+GSFilename.GS_DIR_USER
+File.separator+Integer.toString(sessionUID));
// 屄恖愝掕僨乕僞峏怴
if( (subcmd==GSCmd.SUB_SHAIN_PSET)&&(hsPara.get(GSCmd.GS_PARA_SUBMITX)!=null) ) {
subcmd=(hsPara.get(GSCmd.GS_PARA_FLG)!=null)?
Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_FLG))[0]):-1;
int mailer=(hsPara.get(GSCmd.GS_PARA_MAILER)!=null)
?Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_MAILER))[0])
:MailerFile.BASICMILER;
mailerFile.setMailer(mailer);
mailerFile.Save();
}
//
mailerFile.Load();
if(getMailerURL() != null && mailerFile.getMailer() == MailerFile.GSMILER)
hsPara.put(GSCmd.GS_PARA_GSMAILER, "1");
switch(subcmd) {
case GSCmd.SUB_SHAIN_EXPORT:{
// 僄僋僗億乕僩
if(getMailerURL() != null)
hsPara.put(GSCmd.GS_PARA_GSMAILER, "1");
page = new CreateShainExportPage(hsPara,getMapURL(),getHelpURL());
break;}
case GSCmd.SUB_SHAIN_PSET:{
// 屄恖愝掕
if(getMailerURL() != null)
hsPara.put(GSCmd.GS_PARA_GSMAILER, "1");
page = new CreateShainSetPage(hsPara,getRootDir(),getMapURL(),getHelpURL());
break;}
case GSCmd.SUB_SHAIN_EMAIL:{
// E-mail専嶕
page = new CreateShainEmailPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;}
case GSCmd.SUB_SHAIN_GROUP:{
// 僌儖乕僾専嶕
page = new CreateShainGroupPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;}
default:{
// 偐側専嶕
page = new CreateShainKanaPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
}
}
break;
}
case GSCmd.GS_SHAIN:{// 幮堳忣曬
page = new CreateUserInfo(hsPara,getRootDir(),usermanager,getMapURL());
break;
}
case GSCmd.GS_SHAINADD:{//幮堳忣曬(傾僪儗僗挔)
int subcmd=(hsPara.get(GSCmd.GS_PARA_SUBCMD)!=null)?
Integer.parseInt(((String[])hsPara.get(GSCmd.GS_PARA_SUBCMD))[0]):-1;
try {
//搊榐
if(hsPara.get(GSCmd.GS_PARA_REGISTRYX) != null) {
MailAddress address = getMailAddress(session);
String next_mail_url = (String)session.getAttribute(GSBase.SESSION_MAIL_URL);
RequestDispatcher dispatcher = req.getRequestDispatcher(next_mail_url);
address = AddressIndex.setMailAddress(address, usermanager, hsPara, getRootDir());
session.setAttribute(GSBase.SESSION_MAIL_ADDRESS, address);
dispatcher.forward(req, res);
break;
}
//庢徚
if(hsPara.get(GSCmd.GS_PARA_CANCELX) != null) {
String next_mail_url = (String)session.getAttribute(GSBase.SESSION_MAIL_URL);
RequestDispatcher dispatcher = req.getRequestDispatcher(next_mail_url);
dispatcher.forward(req, res);
break;
}
} catch(Exception e) {
String errurl = GSTool.removeParaFormURI(req.getRequestURI())+"?"+GSCmd.GS_PARA_CMD+"="+GSCmd.GS_SHAINADD;
page = new CreateErrorPage(CreateErrorPage.ERR, getMapURL(), errurl);
break;
}
if(hsPara.get(GSCmd.GS_PARA_NAMETABX) != null) {
subcmd = GSCmd.SUB_SHAINADD_NAME;
} else if(hsPara.get(GSCmd.GS_PARA_EMAILTABX) != null) {
subcmd = GSCmd.SUB_SHAINADD_EMAIL;
} else if(hsPara.get(GSCmd.GS_PARA_GROUPTABX) != null) {
subcmd = GSCmd.SUB_SHAINADD_GROUP;
hsPara.remove(GSCmd.GS_PARA_INDEXS);
}
if(getIndex(hsPara) > 0) {
String[] idx = new String[1];
idx[0] = Integer.toString(getIndex(hsPara));
hsPara.put(GSCmd.GS_PARA_IDX, idx);
}
// 慖戰
String TO = "1";
String CC = "2";
String BCC = "3";
if(hsPara.get(GSCmd.GS_PARA_TOSELECTX) != null)
hsPara.put(GSCmd.GS_PARA_SELECTION, TO);
else if(hsPara.get(GSCmd.GS_PARA_CCSELECTX) != null)
hsPara.put(GSCmd.GS_PARA_SELECTION, CC);
else if(hsPara.get(GSCmd.GS_PARA_BCCSELECTX) != null)
hsPara.put(GSCmd.GS_PARA_SELECTION, BCC);
// 慡偰夝彍
if(hsPara.get(GSCmd.GS_PARA_ALLRELEASEX) != null) {
hsPara.remove("to");
hsPara.remove("cc");
hsPara.remove("bcc");
}
HashSet indexSet = AddressIndex.getIndexs(subcmd, usermanager, getRootDir());
if(subcmd == GSCmd.SUB_SHAINADD_EMAIL) {
// EMAIL専嶕
hsPara.put(GSCmd.GS_PARA_INDEXS, indexSet);
page = new CreateShainAddressEmailPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;
} else if(subcmd == GSCmd.SUB_SHAINADD_GROUP) {
// 僌儖乕僾専嶕
page = new CreateShainAddressGroupPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;
} else if(subcmd == GSCmd.SUB_SHAINADD_NAME){
// 偐側専嶕
hsPara.put(GSCmd.GS_PARA_INDEXS, indexSet);
page = new CreateShainAddressKanaPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;
} else {
MailAddress address = getMailAddress(session);
hsPara = AddressIndex.setParam(address, usermanager, hsPara, getRootDir());
hsPara.put(GSCmd.GS_PARA_INDEXS, indexSet);
page = new CreateShainAddressKanaPage(hsPara,getRootDir(),usermanager,getMapURL(),getHelpURL());
break;
}
}
}
if(page != null){
page.write(req,res);
}
}
/**
* <p>巜掕偟偨儐乕僓偑娗棟幰尃尷傪傕偭偰偄傞偐敾掕偟傑偡丅
*
* @param uid 儐乕僓ID
* @param req 儕僋僄僗僩
* @param res 儗僗億儞僗
* @param nextUrl
* @return true:娗棟幰尃尷偁傝,false:娗棟幰尃尷側偟
*/
private boolean superUserCheck(int uid,HttpServletRequest req,HttpServletResponse res,String nextUrl)
throws GSException {
if(uid<0)
throw new GSException("儐乕僓ID偑晄惓偱偡丅");
if(usermanager.isSU(uid))
return true;
CreateErrorPage page = new CreateErrorPage(CreateErrorPage.ERR_NO_SU,getMapURL(),nextUrl);
try {
page.write(req,res);
} catch(GSException e) {
}
return false;
}
/**
* <p>晄柧側僄儔乕偺応崌偵僄儔乕儁乕僕傪惗惉偟傑偡丅
*
* @param req 儕僋僄僗僩
* @param res 儗僗億儞僗
*/
private void unKnownError(HttpServletRequest req,HttpServletResponse res) {
CreateErrorPage page = new CreateErrorPage(CreateErrorPage.ERR,getMapURL(),getMainURL());
page.setTarget("_top");
try {
page.write(req,res);
} catch(GSException e) {
}
}
/**
* 僴僢僔儏僥乕僽儖偐傜index傪庢摼偟傑偡
*
* @param Para 僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @return int
*/
private int getIndex(Hashtable Para) {
String[] indexs = {"偁","偄","偆","偊","偍","偐","偒","偔","偗","偙","偝","偟","偡","偣","偦","偨","偪","偮","偰","偲","側","偵","偸","偹","偺","偼","傂","傆","傊","傎","傑","傒","傓","傔","傕","傗","備","傛","傜","傝","傞","傟","傠","傢","傪","傫","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","etc"};
for(int i=0; i < indexs.length; i++) {
if(Para.get(indexs[i].hashCode() + ".x") != null) {
return indexs[i].hashCode();
}
}
return 0;
}
/**
* 僙僢僔儑儞偐傜MailAddress僆僽僕僃僋僩傪庢摼偟傑偡丅
*
* @param session : javax.servet.http.HttpSession
* @return MailAddress
*/
public MailAddress getMailAddress(HttpSession session) {
// MailAddress庢摼
MailAddress address = null;
try {
if(session.getAttribute(GSBase.SESSION_MAIL_ADDRESS) != null)
address = (MailAddress)((MailAddress)session.getAttribute(GSBase.SESSION_MAIL_ADDRESS)).clone();
else
address = new MailAddress();
} catch(Exception e) {
address = new MailAddress();
}
return address;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -