knu project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
4.4 KiB

/*************************************************************************************************
* 프로그램명 : HttpDocCancle.java 프로그램설명 : 집계취소 파라미터 작성자 : 작성일 : 변경일 :
**************************************************************************************************/
package kr.co.kihyun.beans.totsys.totper;
import java.io.IOException;
import java.io.PrintWriter;
import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.TotDocProcess;
import kr.co.kihyun.beans.entity.TotDocType;
import kr.co.kihyun.beans.entity.util.*;
import kr.co.kihyun.beans.user.HttpSSOLogin;
import kr.co.kihyun.lang.Encoder;
import kr.co.kihyun.lang.MLong;
import kr.co.kihyun.lang.MString;
import kr.co.kihyun.moumi.MoumiConfig;
import kr.co.kihyun.text.html.ServletUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@WebServlet("/servlet/kr.co.kihyun.beans.totsys.totper.HttpDocCancle")
public class HttpDocCancle extends HttpServlet {
private static final long serialVersionUID = -3115363713832399885L;
private static final Logger LOG = LoggerFactory.getLogger(HttpDocCancle.class);
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html;charset=UTF-8");
PrintWriter out = res.getWriter();
/*********** User HttpSSOLogin check ***********/
if (!HttpSSOLogin.isLogin(req)) {
String connURL = "location='/totsys/login/login.jsp';";
out.println(ServletUtil.getJavaScript(connURL));
return;
}
Long docID = MLong.parseLong(req.getParameter("docID"));
String userID = Encoder.toJava(req.getParameter("userID"));
String url = MString.checkNull(req.getParameter("url"));
String docType = MString.checkNull(req.getParameter("docType"));
int sysAuth = HttpSSOLogin.getSysAuth(req);
PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try {
tx.begin();
TotDoc totDoc = pm.getObjectById(TotDoc.class, docID);
if (sysAuth == MoumiConfig.TOTPER && !userID.equals(totDoc.getUser(pm).getId())) {
out.println(ServletUtil.alert(TotDocType.TOT_DOC + MoumiConfig.getMessageBundle().getString("moumi.message.popup.totDocCancelFail")));
out.println(ServletUtil
.getJavaScript("document.location='/totsys/totper/mydocbox/prssbox/doc_list.jsp?docType="
+ docType + "';"));
return;
}
totDoc.setProcess(TotDocProcess.CANCEL);
if ("mmprss".equals(url)) {
if (totDoc.getMasterTotDoc() != null)
totDoc.setMasterTotDoc(null);
}
pm.makePersistent(totDoc);
tx.commit();
out.println(ServletUtil.alert(TotDocType.TOT_DOC + MoumiConfig.getMessageBundle().getString("moumi.message.popup.delcalSuccess")));
out.println(ServletUtil
.getJavaScript("document.location='/totsys/totper/mydocbox/prssbox/doc_list.jsp?docType="
+ docType + "';"));
} catch (Exception ex) {
ex.printStackTrace();
out.println(ServletUtil.alert(TotDocType.TOT_DOC + MoumiConfig.getMessageBundle().getString("moumi.message.popup.totDocCancelFail2")));
//v2. 9.크로스사이트 스크립트 (PrintWrier) : Update by KWON,HAN
// out.println(ServletUtil
// .getJavaScript("document.location='/totsys/totper/mydocbox/prssbox/doc_list.jsp?docType="
// + docType + "';"));
// 수정 : 외부 입력값 필터링
String callbackFunc = "document.location='/totsys/totper/mydocbox/prssbox/doc_list.jsp?docType=" + docType + "';";
String filtered_callbackFunc = callbackFunc.replaceAll("<","").replaceAll(">","").replaceAll("&","").replaceAll(",","");
LOG.debug("v2 9.크로스사이트 스크립트 (PrintWrier) : HttpDocCancle.doPost() filtered_callbackFunc={}, Not Test", filtered_callbackFunc);
out.println(ServletUtil.getJavaScript(filtered_callbackFunc));
//========================================
} finally {
if (tx.isActive())
tx.rollback();
pm.close();
}
}
}