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