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