view src/main/java/app/bbs/thinks/ShowMatrix.java @ 166:564f683b7aef

Matrix Date type insert ok but bad source
author tatsuki
date Mon, 28 Jul 2014 17:02:31 +0900
parents b3d5fbe95b9a
children 91f6dd655a01
line wrap: on
line source

package app.bbs.thinks;

import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.util.thread.ThreadPool;

import app.bbs.NetworkBulletinBoard;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage;

public class ShowMatrix extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final NetworkBulletinBoard bbs;
	private final String createBoardMessagePath;
	private final String editMessagePath;
	private final String showMatrixPath;
	private final String createAttributePath;
	private static final String PARAM_BOARD_NAME = "bname";

	public ShowMatrix(NetworkBulletinBoard _bbs,
			String _createBoardMessagePath, String _editMessagePath,
			String _showMatrixPath, String _createAttributePath, ThreadPool thp) {
		bbs = _bbs;
		createAttributePath = _createAttributePath;
		showMatrixPath = _showMatrixPath;
		createBoardMessagePath = _createBoardMessagePath;
		editMessagePath = _editMessagePath;
	}

	public void doGet(HttpServletRequest _req, HttpServletResponse _res) {
		final String bname = _req.getParameter(PARAM_BOARD_NAME);
		String nodeNum = _req.getParameter("uuid");
		try {
			printBoard(bname, nodeNum, _res.getWriter());
		} catch (Exception _e) {
			_res.setStatus(500);
		}
	}

	private void printBoard(String _bname, String nodeNum, PrintWriter _pw)
			throws Exception {
		_pw.write("<html><body>\n");
		_pw.write("<h1>" + " This Borad is Test Board  " + "</h1>\n");
		_pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname)
				+ "</p>\n");
		;

		_pw.write("<form action='" + createBoardMessagePath
				+ "' method='POST'>\n");
		_pw.write("<p><input type='hidden' name='author'/> "
				+ "<input type='hidden' name='bname' value='" + _bname
				+ "'/> <input type='hidden' name='key'/></p>\n");
		_pw.write("<p>Folder Name<br/> <input type='textarea' name='msg'/> </p>\n");
		_pw.write("<input type='hidden' name='uuid' value='" + nodeNum + "'/>");
		_pw.write("<p><input type='submit' value='submit'/></p>\n");
		_pw.write("</form>");

		_pw.write("<p><br>add Attribute</p>");
		_pw.write("<form action='" + createAttributePath + "' method='POST'\n");
		_pw.write("<p>AUTHOR :<input type='textarea' name='author'/> "
				+ "<input type='hidden' name='bname' value='" + _bname
				+ "'/> KEY :<input type='textarea' name='key'/></p>\n");
		_pw.write("<p>attributeName<br/> <input type='textarea' name='msg'/> </p>\n");
		_pw.write("<input type='hidden' name='uuid' value='" + nodeNum + "'/>");
		_pw.write("<p><input type='submit' value='submit'/></p>\n");
		_pw.write("</form>");

		_pw.write("<p>Folder</p>");

		for (BoardMessage msg : bbs.getFolder(_bname, nodeNum)) {
			_pw.write("<hr/>");
			_pw.write("<small><a href=" + showMatrixPath + "?bname=" + _bname
					+ "&uuid=" + nodeNum + "/" + msg.getUUID() + ">"
					+ msg.getMessage() + "(folder)" + "</a></small><br>");
			_pw.write("<small><a href='" + createAttributePath + "?bname="
					+ _bname + "&uuid=0" + msg.getUUID()
					+ "'>edit(not s)</a></small>");
		}
		_pw.write("<br><br><hr/><p>Value</p><br><br>");
		getAttributeImp attribute = (bbs.getAttribute(_bname, nodeNum));
		
		for (int count = 0; attribute.getMessage(count) != null; count++) {

			_pw.write("<p><b>" + "Author : " + attribute.getMessage(count)
					+ "</b></p>");
			// _pw.write("<small><a href='" + createAttributePath + "?bname=" +
			// _bname
			// + "&uuid=" + msg.getUUID() + "'>edit</a></small>");
		}

		_pw.write("</body></html>");
		_pw.flush();
	}
}