# HG changeset patch # User tatsuki # Date 1406685439 -32400 # Node ID df063cf6f3b5d4edd7b8b3d25972201b6dc44d31 # Parent 2403b9a4416fece72597221bcc94e6dd17daccd9 add Delete Node Method diff -r 2403b9a4416f -r df063cf6f3b5 src/main/java/app/bbs/NetworkBulletinBoard.java --- a/src/main/java/app/bbs/NetworkBulletinBoard.java Wed Jul 30 10:20:01 2014 +0900 +++ b/src/main/java/app/bbs/NetworkBulletinBoard.java Wed Jul 30 10:57:19 2014 +0900 @@ -16,4 +16,5 @@ 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); + public void deleteNode(String _board, String _path, String id); } diff -r 2403b9a4416f -r df063cf6f3b5 src/main/java/app/bbs/NetworkJungleBulletinBoard.java --- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 10:20:01 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 10:57:19 2014 +0900 @@ -409,7 +409,37 @@ either = editor.success(); } while (either.isA()); } + + + public void deleteNode(String _board, String _path, String _id) { + requestCounter.incrementAndGet(); + int id = Integer.parseInt(_id); + final long timestamp = System.currentTimeMillis(); + final ByteBuffer tBuffer = ByteBuffer.allocate(16); + tBuffer.putLong(timestamp); + JungleTree tree = jungle.getTreeByName(_board); + Either 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(); + either = editor.deleteChildAt(path, id); + if (either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + either = editor.success(); + } while (either.isA()); + + } public void deleteAttribute(String _board, String _path ,final String id) { requestCounter.incrementAndGet(); final long timestamp = System.currentTimeMillis(); @@ -597,4 +627,5 @@ } + } diff -r 2403b9a4416f -r df063cf6f3b5 src/main/java/app/bbs/thinks/CreateNode.java --- a/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 10:20:01 2014 +0900 +++ b/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 10:57:19 2014 +0900 @@ -14,7 +14,7 @@ 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 String PARAM_BOARD_UUID = "uuid"; private static final long serialVersionUID = 1L; public CreateNode(NetworkBulletinBoard _bbs) { @@ -26,7 +26,7 @@ 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"); + String nodeNum = _req.getParameter(PARAM_BOARD_UUID); try { bbs.createFolder(boardName, author, msg, key, nodeNum); diff -r 2403b9a4416f -r df063cf6f3b5 src/main/java/app/bbs/thinks/ShowMatrix.java --- a/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 10:20:01 2014 +0900 +++ b/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 10:57:19 2014 +0900 @@ -13,21 +13,21 @@ public class ShowMatrix extends HttpServlet { /** - * - */ + * edit Node Path is rename editNodePath + **/ private static final long serialVersionUID = 1L; private final NetworkBulletinBoard bbs; private final String createBoardMessagePath; - private final String editMessagePath; + private final String editNodePath; 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"; - + private static final String PARAM_BOARD_UUID = "uuid"; public ShowMatrix(NetworkBulletinBoard _bbs, - String _createBoardMessagePath, String _editMessagePath, + String _createBoardMessagePath, String _editNodePath, String _showMatrixPath, String _createAttributePath, String _editAttributePath, String _deleteAttributePath, String _deleteNodePath, ThreadPool thp) { bbs = _bbs; deleteAttributePath = _deleteAttributePath; @@ -36,12 +36,12 @@ editAttributePath = _editAttributePath; showMatrixPath = _showMatrixPath; createBoardMessagePath = _createBoardMessagePath; - editMessagePath = _editMessagePath; + editNodePath = _editNodePath; } public void doGet(HttpServletRequest _req, HttpServletResponse _res) { final String bname = _req.getParameter(PARAM_BOARD_NAME); - String nodeNum = _req.getParameter("uuid"); + String nodeNum = _req.getParameter(PARAM_BOARD_UUID); String nodeName = _req.getParameter("nodeName"); try { printBoard(bname, nodeNum, nodeName, _res.getWriter()); @@ -80,7 +80,9 @@ for (BoardMessage msg : bbs.getFolder(_bname, nodeNum)) { _pw.write("" + msg.getMessage() + ""); _pw.write(" "); - _pw.write("edit

"); + _pw.write("edit"); + _pw.write(" "); + _pw.write("delete

"); } diff -r 2403b9a4416f -r df063cf6f3b5 src/main/java/app/bbs/thinks/deleteNodeServlet.java --- a/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 10:20:01 2014 +0900 +++ b/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 10:57:19 2014 +0900 @@ -13,9 +13,8 @@ { 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 String PARAM_BOARD_PATH = "path"; + private static final String PARAM_NODE_ID = "id"; private static final long serialVersionUID = 1L; @@ -27,17 +26,16 @@ public void doGet(HttpServletRequest _req,HttpServletResponse _res) { String bname = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter("path"); - String id = _req.getParameter("count"); - + String path = _req.getParameter(PARAM_BOARD_PATH ); + String id = _req.getParameter(PARAM_NODE_ID); try{ PrintWriter pw = _res.getWriter(); pw.write("

本当に削除しますか?message

"); pw.write("
" + - "" + - "\n"); + pw.write("

" + + "" + + "\n"); pw.write("

\n"); pw.write(""); pw.flush(); @@ -49,11 +47,10 @@ public void doPost(HttpServletRequest _req,HttpServletResponse _res) { String boardName = _req.getParameter(PARAM_BOARD_NAME); - String path = _req.getParameter("path"); - String id = _req.getParameter("id"); - + String path = _req.getParameter(PARAM_BOARD_PATH); + String id = _req.getParameter(PARAM_NODE_ID); try{ - bbs.deleteAttribute(boardName, path,id); + bbs.deleteNode(boardName, path, id); PrintWriter pw = _res.getWriter(); pw.write("successfully written"); pw.flush();