# HG changeset patch # User one # Date 1410506768 -32400 # Node ID b3aaff7d95009d8d25316b145e855983e5f18a8f # Parent 8e44d61b8a65b3602256345bcdd223d7efb5036c fit junglecore diff -r 8e44d61b8a65 -r b3aaff7d9500 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/JungleBulletinBoard.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/JungleBulletinBoard.java Thu Sep 04 13:11:50 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/bbs/JungleBulletinBoard.java Fri Sep 12 16:26:08 2014 +0900 @@ -12,6 +12,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditor; @@ -20,6 +21,8 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; +import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging; +import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.LoggingIndexNode; public class JungleBulletinBoard implements BulletinBoard { @@ -53,7 +56,7 @@ } JungleTree tree = jungle.getTreeByName("boards"); - JungleTreeEditor editor = tree.getTreeEditor(); + JungleTreeEditor editor = tree.getIndexTreeEditor(); DefaultNodePath root = new DefaultNodePath(); Either either = editor.addNewChildAt(root, 0); if (either.isA()) { @@ -61,8 +64,7 @@ } editor = either.b(); - either = editor.putAttribute(root.add(0), "name", - ByteBuffer.wrap(_name.getBytes())); + either = editor.putAttribute(root.add(0), "name", ByteBuffer.wrap(_name.getBytes())); if (either.isA()) { throw new IllegalStateException(); } @@ -73,26 +75,33 @@ } tree = jungle.getTreeByName(_name); - editor = tree.getTreeEditor(); + editor = tree.getIndexTreeEditor(); either = editor.addNewChildAt(root, 0); if (either.isA()) { throw new IllegalStateException(); } editor = either.b(); - NodeEditor e = new NodeEditor() { + /* NodeEditor e = new NodeEditor() { - public Either edit(TreeNode node) { + public Either edit(TreeNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_initMessage.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); System.out.println(node.getAttributes().get("mes")); return DefaultEither.newB(node); } + + public Logging wrap(TreeNode node, OperationLog op) { + return new LoggingIndexNode(node ,op, null); + } - }; - - either = editor.edit(root.add(0), e); + };*/ + + editor = editor.putAttribute(root.add(0),"author", ByteBuffer.wrap(_author.getBytes())).b(); + editor = editor.putAttribute(root.add(0),"key", ByteBuffer.wrap(_editKey.getBytes())).b(); + either = editor.putAttribute(root.add(0),"mes", ByteBuffer.wrap(_initMessage.getBytes())); + if (either.isA()) { throw new IllegalStateException(); } @@ -121,8 +130,8 @@ } editor = either.b(); - NodeEditor e = new NodeEditor() { - public Either edit(TreeNode node) { + /*NodeEditor e = new NodeEditor() { + public Either edit(LoggingNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); @@ -133,11 +142,22 @@ path = path.add(size); either = editor.edit(path, e); + if (either.isA()) { throw new IllegalStateException(); } editor = either.b(); - } while (editor.success().isA()); + } while (editor.success().isA());*/ + + editor = editor.putAttribute(path.add(0),"author", ByteBuffer.wrap(_author.getBytes())).b(); + editor = editor.putAttribute(path.add(0),"key", ByteBuffer.wrap(_editKey.getBytes())).b(); + either = editor.putAttribute(path.add(0),"mes", ByteBuffer.wrap(_message.getBytes())); + + if (either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + }while (editor.success().isA()); } public void editMessage(String _board, String _uuid, final String _author, @@ -149,9 +169,9 @@ JungleTree tree = jungle.getTreeByName(_board); editor = tree.getTreeEditor(); - NodeEditor e = new NodeEditor() { + /*NodeEditor e = new NodeEditor() { - public Either edit(TreeNode node) { + public Either edit(LoggingNode node) { node = node.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); node = node.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); @@ -165,7 +185,17 @@ throw new IllegalStateException(); } editor = either.b(); - } while (editor.success().isA()); + } while (editor.success().isA());*/ + + editor = editor.putAttribute(path.add(0),"author", ByteBuffer.wrap(_author.getBytes())).b(); + editor = editor.putAttribute(path.add(0),"key", ByteBuffer.wrap(_editKey.getBytes())).b(); + Either either = editor.putAttribute(path.add(0),"mes", ByteBuffer.wrap(_message.getBytes())); + + if (either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + }while (editor.success().isA()); } public Iterable getMessages(String _boardName) {