169
|
1 package app.bbs.thinks;
|
|
2
|
|
3 import java.io.PrintWriter;
|
|
4
|
|
5 import javax.servlet.http.HttpServlet;
|
|
6 import javax.servlet.http.HttpServletRequest;
|
|
7 import javax.servlet.http.HttpServletResponse;
|
|
8
|
174
|
9 import org.apache.commons.lang.StringEscapeUtils;
|
|
10
|
169
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard;
|
|
12
|
170
|
13 public class EditNodeName extends HttpServlet
|
169
|
14 {
|
|
15 private final BulletinBoard bbs;
|
|
16 private static final String PARAM_BOARD_NAME = "bname";
|
173
|
17 private static final String PARAM_NODE_PATH = "path";
|
169
|
18 private static final String PARAM_BOARD_AUTHOR = "author";
|
|
19 private static final String PARAM_BOARD_MESSAGE= "msg";
|
|
20 private static final String PARAM_BOARD_EDITKEY = "key";
|
|
21
|
|
22 private static final long serialVersionUID = 1L;
|
|
23
|
170
|
24 public EditNodeName(BulletinBoard _bbs)
|
169
|
25 {
|
|
26 bbs = _bbs;
|
|
27 }
|
|
28
|
|
29 public void doGet(HttpServletRequest _req,HttpServletResponse _res)
|
|
30 {
|
174
|
31 String bname = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME));
|
|
32 String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH));
|
169
|
33
|
|
34
|
|
35 try{
|
174
|
36 _res.setCharacterEncoding("UTF-8");
|
169
|
37 PrintWriter pw = _res.getWriter();
|
|
38 pw.write("<html><body><h1>edit message</h1>");
|
|
39 pw.write("<form method='POST'\n");
|
|
40 pw.write("<p><input type='hidden' name='author'/>" +
|
173
|
41 "<input type='hidden' name='key' value='"+path+"'/>" +
|
169
|
42 "<input type='hidden' name='bname' value='"+bname+"'</p>\n");
|
|
43 pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n");
|
|
44 pw.write("<p><input type='submit' value='submit'/></p>\n");
|
|
45 pw.write("</body></html>");
|
|
46 pw.flush();
|
|
47 }catch(Exception _e){
|
|
48 _res.setStatus(500);
|
|
49 }
|
|
50 }
|
|
51
|
|
52 public void doPost(HttpServletRequest _req,HttpServletResponse _res)
|
|
53 {
|
174
|
54 String boardName = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_NAME));
|
|
55 String author = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_AUTHOR));
|
|
56 String msg = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_MESSAGE));
|
|
57 String key = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_BOARD_EDITKEY));
|
|
58 String path = StringEscapeUtils.unescapeHtml(_req.getParameter(PARAM_NODE_PATH));
|
169
|
59
|
|
60 try{
|
173
|
61 bbs.editMessage(boardName, path, author, msg, key);
|
169
|
62 PrintWriter pw = _res.getWriter();
|
|
63 pw.write("successfully written");
|
|
64 pw.flush();
|
|
65 }catch(Exception _e){
|
|
66 _res.setStatus(500);
|
|
67 }
|
|
68 }
|
|
69 }
|