diff src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/ShowMessageWithTimeStampServletMatrix.java @ 1:b036c87f1e5c

app
author tatsuki
date Fri, 24 Oct 2014 09:45:52 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/cr/ie/tatsuki/bbs/ShowMessageWithTimeStampServletMatrix.java	Fri Oct 24 09:45:52 2014 +0900
@@ -0,0 +1,68 @@
+package jp.ac.u_ryukyu.cr.ie.tatsuki.bbs;
+
+import java.io.PrintWriter;
+
+
+
+
+
+
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard;
+
+public class ShowMessageWithTimeStampServletMatrix extends HttpServlet {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private final XmlBulletinBoard bbs;
+	private final String createBoardMessagePath;
+	private final String editMessagePath;
+	private final String showMatrixPath;
+
+	private static final String PARAM_BOARD_NAME = "bname";
+
+	public ShowMessageWithTimeStampServletMatrix(XmlBulletinBoard _bbs,
+			String _createBoardMessagePath, String _editMessagePath, String _showMatrixPath) {
+		bbs = _bbs;
+		showMatrixPath = _showMatrixPath;
+		createBoardMessagePath = _createBoardMessagePath;
+		editMessagePath = _editMessagePath;
+	}
+
+	public void doGet(HttpServletRequest _req, HttpServletResponse _res) {
+		final String bname = (_req.getParameter(PARAM_BOARD_NAME));
+		try {
+			_res.setCharacterEncoding("UTF-8");
+			printBoard(bname, _res.getWriter());
+		} catch (Exception _e) {
+			_res.setStatus(500);
+		}
+	}
+
+	private void printBoard(String _bname, PrintWriter _pw) throws Exception {
+		_pw.write("<html><body>\n");
+		_pw.write("<h1>" + bbs.sanitize(_bname) + "</h1>\n");
+
+		_pw.write("<form action='" + createBoardMessagePath + "' method='POST'\n");
+		_pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" +bbs.sanitize( _bname) + "'/> EditKey : <input type='textarea' name='key'/></p>\n");
+		_pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n");
+		_pw.write("<p><input type='submit' value='submit'/></p>\n");
+		_pw.write("<small><a href=" + showMatrixPath + "?bname=" + bbs.sanitize(_bname) + "&uuid= >MatrixMode"+"</a></small><br>");
+		
+		for (BoardMessage msg : bbs.getMessages(_bname)) {//フォルダの表示
+			_pw.write("<hr/>");
+			_pw.write("<p> Author <b>" + bbs.sanitize(msg.getAuthor()) + "</b></p>");
+			_pw.write("<small><a href=" + editMessagePath + "?bname=" + bbs.sanitize(_bname)
+					+ "&uuid=" + msg.getUUID() + ">"+ bbs.sanitize(msg.getMessage()) +"</a></small><br>");
+		}
+
+		_pw.write("</body></html>");
+		_pw.flush();
+	}
+}