Mercurial > hg > Database > jungle-network
changeset 169:2403b9a4416f
create Delete Attribute Method
author | tatsuki |
---|---|
date | Wed, 30 Jul 2014 10:20:01 +0900 |
parents | 54d68cda84c4 |
children | df063cf6f3b5 |
files | src/main/java/app/bbs/NetworkBulletinBoard.java src/main/java/app/bbs/NetworkJungleBulletinBoard.java src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java src/main/java/app/bbs/thinks/CreateFolderMatrix.java src/main/java/app/bbs/thinks/CreateNode.java src/main/java/app/bbs/thinks/EditAttribute.java src/main/java/app/bbs/thinks/EditAttributeServlet.java src/main/java/app/bbs/thinks/EditFolderName.java src/main/java/app/bbs/thinks/EditNodeName.java src/main/java/app/bbs/thinks/ShowMatrix.java src/main/java/app/bbs/thinks/deleteAttributeServlet.java src/main/java/app/bbs/thinks/deleteNodeServlet.java |
diffstat | 12 files changed, 368 insertions(+), 189 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/app/bbs/NetworkBulletinBoard.java Tue Jul 29 18:51:44 2014 +0900 +++ b/src/main/java/app/bbs/NetworkBulletinBoard.java Wed Jul 30 10:20:01 2014 +0900 @@ -15,4 +15,5 @@ public void createAttribute(String boardName, String uuid, String author, String msg, String key); public getAttributeImp getAttribute(String _bname, String nodeNum); public void editAttribute(String boardName, String path, String id, String message); + public void deleteAttribute(String _board, String _path , String id); }
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Tue Jul 29 18:51:44 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 10:20:01 2014 +0900 @@ -356,7 +356,6 @@ JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - // EnableNodeWrapper<T> node = _e.getWrap(); String str = "0"; int count = 0; for (; _e.getAttributes().get("mes" + String.valueOf(count)) != null; count++) { @@ -411,6 +410,48 @@ } while (either.isA()); } + public void deleteAttribute(String _board, String _path ,final String id) { + requestCounter.incrementAndGet(); + final long timestamp = System.currentTimeMillis(); + final ByteBuffer tBuffer = ByteBuffer.allocate(16); + tBuffer.putLong(timestamp); + JungleTree tree = jungle.getTreeByName(_board); + Either<Error, JungleTreeEditor> either = null; + DefaultNodePath path = new DefaultNodePath(); + do { + try { + for (int count = 0; _path.substring(count, count + 1) != null; count++) { + if (!_path.substring(count, count + 1).equals("/")) + path = path.add(Integer.parseInt(_path.substring(count, count + 1))); + } + } catch (Exception _e) { + } + + JungleTreeEditor editor = tree.getTreeEditor(); + NodeEditor e = new NodeEditor() { + public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { + _e = _e.getAttributes().delete("mes" + id ).b(); + _e = _e.getAttributes().delete("timestamp" + id ).b(); + int count = Integer.parseInt(id); + for (; _e.getAttributes().get("mes" + String.valueOf(count + 1)) != null; count++) { + _e = _e.getAttributes().put("mes" + count, _e.getAttributes().get("mes" + String.valueOf(count + 1))).b(); + _e = _e.getAttributes().put("timestamp" + count, tBuffer).b(); + } + _e = _e.getAttributes().delete("mes" + count ).b(); + _e = _e.getAttributes().delete("timestamp" + count ).b(); + return DefaultEither.newB(_e); + } + }; + either = editor.edit(path, e); + if (either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + either = editor.success(); + } while (either.isA()); + } + + public void editMatrixMessage(String _board, String _uuid, final String _author, final String _message, final String _editKey) { requestCounter.incrementAndGet(); @@ -556,6 +597,4 @@ } - - }
--- a/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Tue Jul 29 18:51:44 2014 +0900 +++ b/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Wed Jul 30 10:20:01 2014 +0900 @@ -25,11 +25,13 @@ import app.bbs.NetworkJungleBulletinBoard; import app.bbs.RequestNumCheckServlet; import app.bbs.ShowMessageWithTimeStampServlet; -import app.bbs.thinks.CreateFolderMatrix; -import app.bbs.thinks.EditAttribute; -import app.bbs.thinks.EditFolderName; +import app.bbs.thinks.CreateNode; +import app.bbs.thinks.EditAttributeServlet; +import app.bbs.thinks.EditNodeName; import app.bbs.thinks.ShowMatrix; import app.bbs.thinks.createAttributeMatrix; +import app.bbs.thinks.deleteAttributeServlet; +import app.bbs.thinks.deleteNodeServlet; public class StartBBSCodeSegment extends CodeSegment { @@ -82,19 +84,22 @@ String showMatrixPath = "/showMatrix"; String createAttributePath = "/createAttribute"; String editAttributePath = "/editAttribute"; - + String deleteAttributePath = "/deleteAttribute"; + String deleteNodePath = "/deleteNode"; Server serv = new Server(bbsPort); ThreadPool thp = serv.getThreadPool(); Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS); - Servlet createFolder = new CreateFolderMatrix(cassaBBS); + Servlet createFolder = new CreateNode(cassaBBS); Servlet createBoard = new CreateBoardServlet(cassaBBS); - Servlet editBoardMessage = new EditFolderName(cassaBBS); + Servlet editBoardMessage = new EditNodeName(cassaBBS); Servlet createAttribute = new createAttributeMatrix(cassaBBS); - Servlet editAttribute = new EditAttribute(cassaBBS); + Servlet editAttribute = new EditAttributeServlet(cassaBBS); + Servlet deleteAttribute = new deleteAttributeServlet(cassaBBS); + Servlet deleteNode = new deleteNodeServlet(cassaBBS); Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath); // Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath); Servlet board = new ShowMessageWithTimeStampServlet(cassaBBS,createBoardMessagePath,editMessagePath,showMatrixPath, thp); - Servlet matrix = new ShowMatrix(cassaBBS,createFolderPath,editMessagePath, showMatrixPath, createAttributePath, editAttributePath,thp); + Servlet matrix = new ShowMatrix(cassaBBS,createFolderPath,editMessagePath, showMatrixPath, createAttributePath, editAttributePath,deleteAttributePath,deleteNodePath,thp); ServletHandler context = new ServletHandler(); context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath); @@ -103,6 +108,8 @@ context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath); context.addServletWithMapping(new ServletHolder(createAttribute),createAttributePath); context.addServletWithMapping(new ServletHolder(index),"/"); + context.addServletWithMapping(new ServletHolder(deleteAttribute),deleteAttributePath); + context.addServletWithMapping(new ServletHolder(deleteNode),deleteNodePath); context.addServletWithMapping(new ServletHolder(editAttribute),editAttributePath); context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath); context.addServletWithMapping(new ServletHolder(matrix),showMatrixPath);
--- a/src/main/java/app/bbs/thinks/CreateFolderMatrix.java Tue Jul 29 18:51:44 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -package app.bbs.thinks; - -import java.io.PrintWriter; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import app.bbs.NetworkBulletinBoard; - -public class CreateFolderMatrix extends HttpServlet { - private final NetworkBulletinBoard bbs; - private static final String PARAM_BOARD_NAME = "bname"; - private static final String PARAM_BOARD_AUTHOR = "author"; - private static final String PARAM_BOARD_INITMESSAGE = "msg"; - private static final String PARAM_BOARD_EDITKEY = "key"; - - private static final long serialVersionUID = 1L; - - public CreateFolderMatrix(NetworkBulletinBoard _bbs) { - bbs = _bbs; - } - - public void doPost(HttpServletRequest _req, HttpServletResponse _res) { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String author = _req.getParameter(PARAM_BOARD_AUTHOR); - String msg = _req.getParameter(PARAM_BOARD_INITMESSAGE); - String key = _req.getParameter(PARAM_BOARD_EDITKEY); - String nodeNum = _req.getParameter("uuid"); - - try { - bbs.createFolder(boardName, author, msg, key, nodeNum); - PrintWriter pw = _res.getWriter(); - pw.write("successfully written"); - } catch (Exception _e) { - _res.setStatus(500); - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 10:20:01 2014 +0900 @@ -0,0 +1,39 @@ +package app.bbs.thinks; + +import java.io.PrintWriter; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import app.bbs.NetworkBulletinBoard; + +public class CreateNode extends HttpServlet { + private final NetworkBulletinBoard bbs; + private static final String PARAM_BOARD_NAME = "bname"; + private static final String PARAM_BOARD_AUTHOR = "author"; + private static final String PARAM_BOARD_INITMESSAGE = "msg"; + private static final String PARAM_BOARD_EDITKEY = "key"; + + private static final long serialVersionUID = 1L; + + public CreateNode(NetworkBulletinBoard _bbs) { + bbs = _bbs; + } + + public void doPost(HttpServletRequest _req, HttpServletResponse _res) { + String boardName = _req.getParameter(PARAM_BOARD_NAME); + String author = _req.getParameter(PARAM_BOARD_AUTHOR); + String msg = _req.getParameter(PARAM_BOARD_INITMESSAGE); + String key = _req.getParameter(PARAM_BOARD_EDITKEY); + String nodeNum = _req.getParameter("uuid"); + + try { + bbs.createFolder(boardName, author, msg, key, nodeNum); + PrintWriter pw = _res.getWriter(); + pw.write("successfully written"); + } catch (Exception _e) { + _res.setStatus(500); + } + } +}
--- a/src/main/java/app/bbs/thinks/EditAttribute.java Tue Jul 29 18:51:44 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -package app.bbs.thinks; - -import java.io.PrintWriter; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import app.bbs.NetworkBulletinBoard; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; - -public class EditAttribute extends HttpServlet -{ - private final NetworkBulletinBoard bbs; - private static final String PARAM_BOARD_NAME = "bname"; - private static final String PARAM_BOARD_MSGID = "uuid"; - private static final String PARAM_BOARD_MESSAGE= "msg"; - private static final String PARAM_BOARD_EDITKEY = "key"; - - private static final long serialVersionUID = 1L; - - public EditAttribute(NetworkBulletinBoard _bbs) - { - bbs = _bbs; - } - - public void doGet(HttpServletRequest _req,HttpServletResponse _res) - { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter("path"); - String id = _req.getParameter("count"); - - - try{ - PrintWriter pw = _res.getWriter(); - pw.write("<html><body><h1>edit message</h1>"); - pw.write("<form method='POST'\n"); - pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + - "<input type='hidden' name='id' value='"+id+"'/>" + - "<input type='hidden' name='bname' value='"+bname+"'</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("</body></html>"); - pw.flush(); - }catch(Exception _e){ - _res.setStatus(500); - } - } - - public void doPost(HttpServletRequest _req,HttpServletResponse _res) - { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String msg = _req.getParameter(PARAM_BOARD_MESSAGE); - String path = _req.getParameter("path"); - String id = _req.getParameter("id"); - - try{ - bbs.editAttribute(boardName, path,id, msg); - PrintWriter pw = _res.getWriter(); - pw.write("successfully written"); - pw.flush(); - }catch(Exception _e){ - _res.setStatus(500); - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/app/bbs/thinks/EditAttributeServlet.java Wed Jul 30 10:20:01 2014 +0900 @@ -0,0 +1,66 @@ +package app.bbs.thinks; + +import java.io.PrintWriter; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import app.bbs.NetworkBulletinBoard; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; + +public class EditAttributeServlet extends HttpServlet +{ + private final NetworkBulletinBoard bbs; + private static final String PARAM_BOARD_NAME = "bname"; + private static final String PARAM_BOARD_MSGID = "uuid"; + private static final String PARAM_BOARD_MESSAGE= "msg"; + private static final String PARAM_BOARD_EDITKEY = "key"; + + private static final long serialVersionUID = 1L; + + public EditAttributeServlet(NetworkBulletinBoard _bbs) + { + bbs = _bbs; + } + + public void doGet(HttpServletRequest _req,HttpServletResponse _res) + { + String bname = _req.getParameter(PARAM_BOARD_NAME); + String path = _req.getParameter("path"); + String id = _req.getParameter("count"); + + + try{ + PrintWriter pw = _res.getWriter(); + pw.write("<html><body><h1>edit message</h1>"); + pw.write("<form method='POST'\n"); + pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + + "<input type='hidden' name='id' value='"+id+"'/>" + + "<input type='hidden' name='bname' value='"+bname+"'</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("</body></html>"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } + + public void doPost(HttpServletRequest _req,HttpServletResponse _res) + { + String boardName = _req.getParameter(PARAM_BOARD_NAME); + String msg = _req.getParameter(PARAM_BOARD_MESSAGE); + String path = _req.getParameter("path"); + String id = _req.getParameter("id"); + + try{ + bbs.editAttribute(boardName, path,id, msg); + PrintWriter pw = _res.getWriter(); + pw.write("successfully written"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } +}
--- a/src/main/java/app/bbs/thinks/EditFolderName.java Tue Jul 29 18:51:44 2014 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -package app.bbs.thinks; - -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.BulletinBoard; - -public class EditFolderName extends HttpServlet -{ - private final BulletinBoard bbs; - private static final String PARAM_BOARD_NAME = "bname"; - private static final String PARAM_BOARD_MSGID = "uuid"; - private static final String PARAM_BOARD_AUTHOR = "author"; - private static final String PARAM_BOARD_MESSAGE= "msg"; - private static final String PARAM_BOARD_EDITKEY = "key"; - - private static final long serialVersionUID = 1L; - - public EditFolderName(BulletinBoard _bbs) - { - bbs = _bbs; - } - - public void doGet(HttpServletRequest _req,HttpServletResponse _res) - { - String bname = _req.getParameter(PARAM_BOARD_NAME); - String uuid = _req.getParameter(PARAM_BOARD_MSGID); - - - try{ - PrintWriter pw = _res.getWriter(); - pw.write("<html><body><h1>edit message</h1>"); - pw.write("<form method='POST'\n"); - pw.write("<p><input type='hidden' name='author'/>" + - "<input type='hidden' name='key' value='"+uuid+"'/>" + - "<input type='hidden' name='bname' value='"+bname+"'</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("</body></html>"); - pw.flush(); - }catch(Exception _e){ - _res.setStatus(500); - } - } - - public void doPost(HttpServletRequest _req,HttpServletResponse _res) - { - String boardName = _req.getParameter(PARAM_BOARD_NAME); - String author = _req.getParameter(PARAM_BOARD_AUTHOR); - String msg = _req.getParameter(PARAM_BOARD_MESSAGE); - String key = _req.getParameter(PARAM_BOARD_EDITKEY); - String uuid = _req.getParameter(PARAM_BOARD_MSGID); - - try{ - bbs.editMessage(boardName, uuid, author, msg, key); - PrintWriter pw = _res.getWriter(); - pw.write("successfully written"); - pw.flush(); - }catch(Exception _e){ - _res.setStatus(500); - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/app/bbs/thinks/EditNodeName.java Wed Jul 30 10:20:01 2014 +0900 @@ -0,0 +1,66 @@ +package app.bbs.thinks; + +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.BulletinBoard; + +public class EditNodeName extends HttpServlet +{ + private final BulletinBoard bbs; + private static final String PARAM_BOARD_NAME = "bname"; + private static final String PARAM_BOARD_MSGID = "uuid"; + private static final String PARAM_BOARD_AUTHOR = "author"; + private static final String PARAM_BOARD_MESSAGE= "msg"; + private static final String PARAM_BOARD_EDITKEY = "key"; + + private static final long serialVersionUID = 1L; + + public EditNodeName(BulletinBoard _bbs) + { + bbs = _bbs; + } + + public void doGet(HttpServletRequest _req,HttpServletResponse _res) + { + String bname = _req.getParameter(PARAM_BOARD_NAME); + String uuid = _req.getParameter(PARAM_BOARD_MSGID); + + + try{ + PrintWriter pw = _res.getWriter(); + pw.write("<html><body><h1>edit message</h1>"); + pw.write("<form method='POST'\n"); + pw.write("<p><input type='hidden' name='author'/>" + + "<input type='hidden' name='key' value='"+uuid+"'/>" + + "<input type='hidden' name='bname' value='"+bname+"'</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("</body></html>"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } + + public void doPost(HttpServletRequest _req,HttpServletResponse _res) + { + String boardName = _req.getParameter(PARAM_BOARD_NAME); + String author = _req.getParameter(PARAM_BOARD_AUTHOR); + String msg = _req.getParameter(PARAM_BOARD_MESSAGE); + String key = _req.getParameter(PARAM_BOARD_EDITKEY); + String uuid = _req.getParameter(PARAM_BOARD_MSGID); + + try{ + bbs.editMessage(boardName, uuid, author, msg, key); + PrintWriter pw = _res.getWriter(); + pw.write("successfully written"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } +}
--- a/src/main/java/app/bbs/thinks/ShowMatrix.java Tue Jul 29 18:51:44 2014 +0900 +++ b/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 10:20:01 2014 +0900 @@ -22,12 +22,16 @@ private final String showMatrixPath; private final String createAttributePath; private final String editAttributePath; + private final String deleteAttributePath; + private final String deleteNodePath; private static final String PARAM_BOARD_NAME = "bname"; public ShowMatrix(NetworkBulletinBoard _bbs, String _createBoardMessagePath, String _editMessagePath, - String _showMatrixPath, String _createAttributePath, String _editAttributePath, ThreadPool thp) { + String _showMatrixPath, String _createAttributePath, String _editAttributePath, String _deleteAttributePath, String _deleteNodePath, ThreadPool thp) { bbs = _bbs; + deleteAttributePath = _deleteAttributePath; + deleteNodePath = _deleteNodePath; createAttributePath = _createAttributePath; editAttributePath = _editAttributePath; showMatrixPath = _showMatrixPath; @@ -70,22 +74,22 @@ _pw.write("<input type='hidden' name='uuid' value='" + nodeNum + "'/>"); _pw.write("<p><input type='submit' value='submit'/></p>\n"); _pw.write("</form>"); - + _pw.write("<hr/>"); _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() + "&nodeName=" + msg.getMessage() + ">" + msg.getMessage() + "</a></small>"); _pw.write(" "); - _pw.write("<small><a href='" + editMessagePath + "?bname=" + _bname + "&uuid=" + nodeNum + "/"+ msg.getUUID() + "'>edit</a></small>"); + _pw.write("<small><a href='" + editMessagePath + "?bname=" + _bname + "&uuid=" + nodeNum + "/"+ msg.getUUID() + "'>edit</a><br><br></small>"); } - _pw.write("<br><hr/><p>Value</p><br>"); + _pw.write("<br><hr/><p>Value</p>"); getAttributeImp attribute = (bbs.getAttribute(_bname, nodeNum)); for (int count = 0; attribute.getMessage(count) != null; count++) { - _pw.write("<p><b>" + "Value " + count + " : </b>"); - _pw.write("<a href='" + editAttributePath + "?bname=" + _bname + "&path=" + nodeNum + "&count="+ count + "'>" + attribute.getMessage(count) + "</a></p>"); + _pw.write("<p><b>" + count + " : </b>"); + _pw.write("<a href='" + editAttributePath + "?bname=" + _bname + "&path=" + nodeNum + "&count="+ count + "'>" + attribute.getMessage(count) + "</a>"); + _pw.write("<a href='" + deleteAttributePath + "?bname=" + _bname + "&path=" + nodeNum + "&count="+ count + "'>" + " delete" + "</a></p>"); } _pw.write("</body></html>"); _pw.flush();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/app/bbs/thinks/deleteAttributeServlet.java Wed Jul 30 10:20:01 2014 +0900 @@ -0,0 +1,64 @@ +package app.bbs.thinks; + +import java.io.PrintWriter; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import app.bbs.NetworkBulletinBoard; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; + +public class deleteAttributeServlet extends HttpServlet +{ + private final NetworkBulletinBoard bbs; + private static final String PARAM_BOARD_NAME = "bname"; + private static final String PARAM_BOARD_MSGID = "uuid"; + private static final String PARAM_BOARD_MESSAGE= "msg"; + private static final String PARAM_BOARD_EDITKEY = "key"; + + private static final long serialVersionUID = 1L; + + public deleteAttributeServlet(NetworkBulletinBoard _bbs) + { + bbs = _bbs; + } + + public void doGet(HttpServletRequest _req,HttpServletResponse _res) + { + String bname = _req.getParameter(PARAM_BOARD_NAME); + String path = _req.getParameter("path"); + String id = _req.getParameter("count"); + + + try{ + PrintWriter pw = _res.getWriter(); + pw.write("<html><body><h1>delete Attribute ?</h1>"); + pw.write("<form method='POST'\n"); + pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + + "<input type='hidden' name='id' value='"+id+"'/>" + + "<input type='hidden' name='bname' value='"+bname+"'</p>\n"); + pw.write("<p><input type='submit' value='submit'/></p>\n"); + pw.write("</body></html>"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } + + public void doPost(HttpServletRequest _req,HttpServletResponse _res) + { + String boardName = _req.getParameter(PARAM_BOARD_NAME); + String path = _req.getParameter("path"); + String id = _req.getParameter("id"); + + try{ + bbs.deleteAttribute(boardName, path,id); + PrintWriter pw = _res.getWriter(); + pw.write("successfully written"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 10:20:01 2014 +0900 @@ -0,0 +1,64 @@ +package app.bbs.thinks; +//未実装まだひな形コピーのみ +import java.io.PrintWriter; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import app.bbs.NetworkBulletinBoard; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; + +public class deleteNodeServlet extends HttpServlet +{ + private final NetworkBulletinBoard bbs; + private static final String PARAM_BOARD_NAME = "bname"; + private static final String PARAM_BOARD_MSGID = "uuid"; + private static final String PARAM_BOARD_MESSAGE= "msg"; + private static final String PARAM_BOARD_EDITKEY = "key"; + + private static final long serialVersionUID = 1L; + + public deleteNodeServlet(NetworkBulletinBoard _bbs) + { + bbs = _bbs; + } + + public void doGet(HttpServletRequest _req,HttpServletResponse _res) + { + String bname = _req.getParameter(PARAM_BOARD_NAME); + String path = _req.getParameter("path"); + String id = _req.getParameter("count"); + + + try{ + PrintWriter pw = _res.getWriter(); + pw.write("<html><body><h1>本当に削除しますか?message</h1>"); + pw.write("<form method='POST'\n"); + pw.write("<p><input type='hidden' name='path' value='"+path+"'/>" + + "<input type='hidden' name='id' value='"+id+"'/>" + + "<input type='hidden' name='bname' value='"+bname+"'</p>\n"); + pw.write("<p><input type='submit' value='submit'/></p>\n"); + pw.write("</body></html>"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } + + public void doPost(HttpServletRequest _req,HttpServletResponse _res) + { + String boardName = _req.getParameter(PARAM_BOARD_NAME); + String path = _req.getParameter("path"); + String id = _req.getParameter("id"); + + try{ + bbs.deleteAttribute(boardName, path,id); + PrintWriter pw = _res.getWriter(); + pw.write("successfully written"); + pw.flush(); + }catch(Exception _e){ + _res.setStatus(500); + } + } +}