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