1
|
1 package jp.ac.u_ryukyu.cr.ie.tatsuki.bbs;
|
|
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
|
|
9 import org.eclipse.jetty.util.thread.ThreadPool;
|
|
10
|
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage;
|
|
12
|
|
13 public class ShowMatrix extends HttpServlet {
|
|
14 /**
|
|
15 * edit Node Path is rename editNodePath
|
|
16 **/
|
|
17 private static final long serialVersionUID = 1L;
|
|
18 private final XmlBulletinBoard bbs;
|
|
19 private final String createBoardMessagePath;
|
|
20 private final String editNodePath;
|
|
21 private final String showMatrixPath;
|
|
22 private final String createAttributePath;
|
|
23 private final String editAttributePath;
|
|
24 private final String deleteAttributePath;
|
|
25 private final String deleteNodePath;
|
|
26 private static final String PARAM_BOARD_NAME = "bname";
|
|
27 private static final String PARAM_NODE_PATH = "uuid";
|
|
28 private static final String PARAM_NODE_NAME = "nodeName";
|
|
29
|
|
30 public ShowMatrix(XmlBulletinBoard _bbs,
|
|
31 String _createBoardMessagePath, String _editNodePath,
|
|
32 String _showMatrixPath, String _createAttributePath,
|
|
33 String _editAttributePath, String _deleteAttributePath,
|
|
34 String _deleteNodePath, ThreadPool thp) {
|
|
35 bbs = _bbs;
|
|
36 deleteAttributePath = _deleteAttributePath;
|
|
37 deleteNodePath = _deleteNodePath;
|
|
38 createAttributePath = _createAttributePath;
|
|
39 editAttributePath = _editAttributePath;
|
|
40 showMatrixPath = _showMatrixPath;
|
|
41 createBoardMessagePath = _createBoardMessagePath;
|
|
42 editNodePath = _editNodePath;
|
|
43 }
|
|
44
|
|
45 public void doGet(HttpServletRequest _req, HttpServletResponse _res) {
|
|
46
|
|
47 final String bname = _req.getParameter(PARAM_BOARD_NAME);
|
|
48 String path = _req.getParameter(PARAM_NODE_PATH);
|
|
49 String nodeName = _req.getParameter(PARAM_NODE_NAME);
|
|
50 try {
|
|
51 _res.setCharacterEncoding("UTF-8");
|
|
52 printBoard(bname, path, nodeName, _res.getWriter());
|
|
53 } catch (Exception _e) {
|
|
54 _res.setStatus(500);
|
|
55 }
|
|
56 }
|
|
57
|
|
58 private void printBoard(String _bname, String path, String nodeName,
|
|
59 PrintWriter _pw) throws Exception {
|
|
60 _pw.write("<html><body>\n");
|
|
61
|
|
62 if (nodeName == null)
|
|
63 nodeName = "rootNode";
|
|
64 if (path == null)
|
|
65 path = "0";
|
|
66
|
|
67 _pw.write("<h1>" + bbs.sanitize(nodeName) + " Path = " + path + "</h1>\n");
|
|
68
|
|
69 _pw.write("<form action='" + createBoardMessagePath+ "' method='POST'>\n");
|
|
70 _pw.write("<p><input type='hidden' name='bname' value='" + bbs.sanitize(_bname)+ "'/> </p>\n");
|
|
71 _pw.write("<p>Folder Name<br/> <input type='textarea' name='name'/> </p>\n");
|
|
72 _pw.write("<input type='hidden' name='path' value='" + path + "'/>");
|
|
73 _pw.write("<p><input type='submit' value='submit'/></p>\n");
|
|
74 _pw.write("</form>");
|
|
75
|
|
76 _pw.write("<p><br>add Attribute</p>");
|
|
77 _pw.write("<form action='" + createAttributePath + "' method='POST'\n");
|
|
78 _pw.write("<p><input type='hidden' name='bname' value='" + bbs.sanitize(_bname)
|
|
79 + "'</p>\n");
|
|
80 _pw.write("<p>attributeName<br/> <input type='textarea' name='msg'/> </p>\n");
|
|
81 _pw.write("<input type='hidden' name='path' value='" + path + "'/>");
|
|
82 _pw.write("<p><input type='submit' value='submit'/></p>\n");
|
|
83 _pw.write("</form>");
|
|
84 _pw.write("<hr/>");
|
|
85 _pw.write("<p>Folder</p>");
|
|
86
|
|
87 for (BoardMessage msg : bbs.getFolder(_bname, path)) {
|
|
88 _pw.write("<small><a href=" + showMatrixPath + "?bname=" + bbs.sanitize(_bname)
|
|
89 + "&uuid=" + path + "/" + msg.getUUID() + "&nodeName="
|
|
90 + bbs.sanitize(msg.getMessage()) + ">" + bbs.sanitize(msg.getMessage())
|
2
|
91 + "</a><br><br></small>");
|
1
|
92 }
|
|
93
|
|
94 _pw.write("<br><hr/><p>Value</p>");
|
|
95 getAttributeImp attribute = (bbs.getAttribute(_bname, path));
|
|
96
|
2
|
97 _pw.write(bbs.sanitize(attribute.getMessage()));
|
|
98
|
1
|
99
|
|
100 _pw.write("</body></html>");
|
|
101 _pw.flush();
|
|
102 }
|
|
103 } |