📄 bulletin.java
字号:
package jp.co.sjts.gsession.bulletin;
import java.util.Iterator;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.File;
import java.util.Hashtable;
import java.util.HashSet;
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.*;
/**
* <p>宖帵斅偺儊僀儞僋儔僗
*
* @author Masakatu OOKUBO <ookubo@sjts.co.jp>
* @author Aki MATSUBARA <aki@sjts.co.jp>
* @author Hideyuki KITADE <aki@sjts.co.jp>
* @author Masako IWAMOTO <masako@sjts.co.jp>
*/
public class Bulletin extends ModBaseServlet{
/** */
private Hashtable hsInitData=null;
/** */
private BLMainConfFile conf=null;
/** */
private BLUserConfFile uconf=null;
/** */
private BLDataFile bldata=null;
/** */
private BLIndexFile blindex=null;
/** 僇儗儞僟乕僆僽僕僃僋僩 */
private GSDate cal = null;
/** */
private GSHtml cnv = null;
/** */
private GSBinaryDownLoad temp = null;
/** 僀儊乕僕僨傿儗僋僩儕偺URL */
private String MapUrl = null;
/** 儐乕僓儅僱乕僕儍乕 */
private IUserManager UM=null;
/**
* <p>弶婜壔
*
* @param config ServletConfig
*/
public void init(ServletConfig config) throws ServletException{
cal = new GSDate();
super.init(config);
hsInitData = new Hashtable();
try{
// 僨乕僞奿擺梡偺僨傿儗僋僩儕傪庢摼(椺丗"c:\DATADIR\")
String BulletinDir = getInitParameter(BLCmd.BL_DIR);
if(BulletinDir!=null){
if(!BulletinDir.endsWith("/"))
BulletinDir+="/";
String GroupDir = BulletinDir+"group/";
String UserDir = BulletinDir+"user/";
BulletinDir = BulletinDir.replace('/',File.separatorChar);
GroupDir = GroupDir.replace('/',File.separatorChar);
UserDir = UserDir.replace('/',File.separatorChar);
// 僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file = new File(BulletinDir);
if(!file.exists()) { // 僼傽僀儖偑懚嵼偡傞偐
if(!file.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+BulletinDir);
}
// 僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file1 = new File(GroupDir);
if(!file1.exists()) { // 僼傽僀儖偑懚嵼偡傞偐
if(!file1.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+BulletinDir);
}
// 僨傿儗僋僩儕偺桳岠惈傪僠僃僢僋
try{
File file2 = new File(UserDir);
if(!file2.exists()) { // 僼傽僀儖偑懚嵼偡傞偐
if(!file2.mkdirs()) // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
throw new ServletException("僨傿儗僋僩儕嶌惉偵帋傒偨偑幐攕偟傑偟偨丅");
}
} catch (SecurityException e) {
throw new ServletException("傾僋僙僗尃僄儔乕:"+BulletinDir);
}
hsInitData.put(BLCmd.BL_DIR,BulletinDir);
}
else
throw new ServletException("InitParameter not find \"BulletinDir\"");
// 儅僢僾梡偺url傪庢摼
MapUrl = getMapURL();
if(MapUrl!=null)
hsInitData.put(BLCmd.BL_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 BLMainConfFile((String)hsInitData.get(BLCmd.BL_DIR));
conf.Load();
} catch (Exception e) {
throw new ServletException(e.toString());
}
}
/**
* <p>僒乕僽儗僢僩廔椆帪偵屇傃弌偝傟傑偡丅
* <p>偙偙偱偼側偵傕偟傑偣傫丅
*/
public void destroy(){
super.destroy();
}
/**
* <p>GET儕僋僄僗僩偺張棟傪峴偄傑偡丅
*
* @param hsPara 儕僋僄僗僩僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 儕僋僄僗僩僆僽僕僃僋僩
* @param res 儗僗億儞僗僆僽僕僃僋僩
*/
public void GSdoGet(Hashtable hsPara,HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException{
try {
// 僷儔儊乕僞側偟偺帪偼MAIN儁乕僕偲偡傞
if(hsPara == null) {
hsPara = new Hashtable();
String[] value = {Integer.toString(BLCmd.BL_BULLITEN)};
hsPara.put(BLCmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(BLCmd.PA_PAG,value1);
hsPara.put(BLCmd.PA_GID,value1);
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Bulletin::GSdoGet",e);
CreateErrorPage epage = new CreateErrorPage(CreateErrorPage.ERR
,MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
epage.write(req,res);
}
}
/**
* <p>POST儕僋僄僗僩偺張棟傪峴偄傑偡丅
*
* @param hsPara 儕僋僄僗僩僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 儕僋僄僗僩僆僽僕僃僋僩
* @param res 儗僗億儞僗僆僽僕僃僋僩
*/
public void GSdoPost(Hashtable hsPara,HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException{
try {
// 僷儔儊乕僞側偟偺帪偼MAIN儁乕僕偲偡傞
if(hsPara == null) {
hsPara = new Hashtable();
String[] value = {Integer.toString(BLCmd.BL_BULLITEN)};
hsPara.put(BLCmd.PA_CMD,value);
String[] value1 = {"0"};
hsPara.put(BLCmd.PA_PAG,value1);
hsPara.put(BLCmd.PA_GID,value1);
}
Dispatch(hsPara,req,res);
} catch(Exception e) {
log("Bulletin::GSdoPost",e);
CreateErrorPage epage = new CreateErrorPage(CreateErrorPage.ERR
,MapUrl,GSTool.removeParaFormURI(req.getRequestURI()));
epage.write(req,res);
}
}
/**
* <p>儊僀儞夋柺傊偺弌椡傪峴偄傑偡丅
*
* @param mbp MainBodyParam
* @exception GSExcption
*/
public void GSMainBodyWrite(MainBodyParam mbp)
throws GSException{
PrintWriter pw = mbp.getWriter();
String myUrl = mbp.getMyUrl();
int uid = mbp.getUid();
IUserManager UM = mbp.getUserManager();
String dataDir = (String)hsInitData.get(BLCmd.BL_DIR);
// 儐乕僓乕愝掕僼傽僀儖庢摼
uconf = new BLUserConfFile(dataDir,Integer.toString(uid));
uconf.Load();
// 宖帵斅僨乕僞昞帵
Createbulletin_pop page = new Createbulletin_pop(hsInitData,uconf.GetDisplayMax(),uconf.GetGroupArray(),uid,UM);
page.write(pw,myUrl);
}
/**
* <p>僒乕僽儗僢僩忣曬傪曉偟傑偡丅
*
* @return 僒乕僽儗僢僩忣曬
*/
public String getServletInfo() {
return "Group Session Servlet ver. 1.1";
}
/**
* <p>張棟偺怳傝暘偗傪峴偄傑偡丅
*
* @param hsPara 僷儔儊乕僞奿擺僴僢僔儏僥乕僽儖
* @param req 儕僋僄僗僩
* @param res 儗僗億儞僗
* @exception GSException
*/
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 grpname = null;
String selectgrp = 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);
int cmd = Integer.parseInt((String)((String[])hsPara.get(BLCmd.PA_CMD))[0]);
String urlMap = (String)hsInitData.get(BLCmd.BL_MAP);
String dataDir = (String)hsInitData.get(BLCmd.BL_DIR);
CreatePage page=null;
String[] buf;
String url = GSTool.removeParaFormURI(req.getRequestURI()); // 2001.2.28 add ookubo
// 儐乕僓乕愝掕僼傽僀儖庢摼
uconf = new BLUserConfFile(dataDir,sessionUID.toString());
uconf.Load();
selectgrp = (String)((String[])hsPara.get(BLCmd.PA_GID))[0];
// GROUP愝掕僼傽僀儖庢摼
blindex = new BLIndexFile(dataDir,selectgrp);
synchronized(blindex){
blindex.DateChk(selectgrp);
blindex.Save();
}
String strpage = (String)((String[])hsPara.get("pag"))[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -