Mercurial > hg > Database > jungle-network
changeset 176:6f104ab4eb81
fit jungle core but editMessage is not work
line wrap: on
line diff
--- a/pom.xml Wed Jul 30 22:17:23 2014 +0900 +++ b/pom.xml Mon Sep 01 00:04:32 2014 +0900 @@ -60,17 +60,5 @@ <version>0.6.8</version> </dependency> - <dependency> - <groupId>jungle</groupId> - <artifactId>jungle-core</artifactId> - <version>0.0.3-SNAPSHOT</version> - </dependency> - - - <dependency> - <groupId>jp.ac.u_ryukyu.ie.cr.shoshi.jungle</groupId> - <artifactId>bulletinboard</artifactId> - <version>0.0.1-SNAPSHOT</version> - </dependency> </dependencies> </project>
--- a/src/main/java/alice/jungle/core/NetworkDefaultJungle.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/core/NetworkDefaultJungle.java Mon Sep 01 00:04:32 2014 +0900 @@ -10,6 +10,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; @@ -54,8 +55,8 @@ return _name; } }; - DefaultTreeNode root = new DefaultTreeNode(); - ChangeSet set = new DefaultChangeSet(root.getAsNode(),null,list,uuid,_name, 0); + TreeNode root = new DefaultTreeNode(); + ChangeSet set = new DefaultChangeSet(root,null,list,uuid,_name, 0); DefaultTreeContext<DefaultTreeNode> tc = new DefaultTreeContext<DefaultTreeNode>(root,set); JungleTree newTree = new NetworkDefaultJungleTree<DefaultTreeNode>(_name, tc,uuid,journal.getWriter(),editor); if(trees.putIfAbsent(_name,newTree) != null){
--- a/src/main/java/alice/jungle/datasegment/transformer/NetworkAppendChildAt.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/datasegment/transformer/NetworkAppendChildAt.java Mon Sep 01 00:04:32 2014 +0900 @@ -1,6 +1,7 @@ package alice.jungle.datasegment.transformer; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; @@ -23,8 +24,8 @@ } @Override - public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - Either<Error,T> either = _e.getChildren().addNewChildAt(pos); + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + Either<Error,TreeNode> either = _e.getChildren().addNewChildAt(pos); if(either.isA()){ // error return either; @@ -32,4 +33,10 @@ return DefaultEither.newB(either.b()); } + @Override + public OperationLog getLog() { + // TODO Auto-generated method stub + return null; + } + }
--- a/src/main/java/alice/jungle/operations/NetworkAppendChildAtOperation.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/operations/NetworkAppendChildAtOperation.java Mon Sep 01 00:04:32 2014 +0900 @@ -4,10 +4,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -import alice.jungle.datasegment.transformer.NetworkAppendChildAt; import org.msgpack.annotation.Message; @@ -31,11 +27,11 @@ return Command.APPEND_CHILD; } - @Override - public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { + /*@Override + public <T extends TreeNode> Either<Error, TreeNode> invoke(TreeNode _target) { NetworkAppendChildAt appendChildAt = new NetworkAppendChildAt(pos); return appendChildAt.edit(_target); - } + }*/ @Override public int getPosition() {
--- a/src/main/java/alice/jungle/operations/NetworkDeleteAttributeOperation.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/operations/NetworkDeleteAttributeOperation.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,10 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; + @Message public class NetworkDeleteAttributeOperation implements NodeOperation @@ -34,12 +31,12 @@ return Command.DELETE_ATTRIBUTE; } - @Override + /*@Override public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { DeleteAttribute deleteAttribute = new DeleteAttribute(key); return deleteAttribute.edit(_target); - } + }*/ @Override public int getPosition()
--- a/src/main/java/alice/jungle/operations/NetworkDeleteChildAtOperation.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/operations/NetworkDeleteChildAtOperation.java Mon Sep 01 00:04:32 2014 +0900 @@ -7,7 +7,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -33,12 +32,12 @@ return Command.DELETE_CHILD; } - @Override + /*@Override public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { DeleteChildAt deleteChildAt = new DeleteChildAt(pos); return deleteChildAt.edit(_target); - } + }*/ @Override public int getPosition()
--- a/src/main/java/alice/jungle/operations/NetworkNodeOperation.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/operations/NetworkNodeOperation.java Mon Sep 01 00:04:32 2014 +0900 @@ -7,7 +7,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.AppendChildAt; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -89,7 +88,7 @@ return value; } - @Override +/* @Override public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { switch(getCommand(commandType)) { case PUT_ATTRIBUTE: @@ -108,6 +107,6 @@ break; } return null; - } + }*/ }
--- a/src/main/java/alice/jungle/operations/NetworkPutAttributeOperation.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/operations/NetworkPutAttributeOperation.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,7 +6,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -40,12 +39,12 @@ return Command.PUT_ATTRIBUTE; } - @Override + /*@Override public <T extends EditableNode<T>> Either<Error, T> invoke(T _target) { PutAttribute putAttribute = new PutAttribute(key,value); return putAttribute.edit(_target); - } + }*/ @Override public int getPosition()
--- a/src/main/java/alice/jungle/persistent/PersistentChangeSet.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/persistent/PersistentChangeSet.java Mon Sep 01 00:04:32 2014 +0900 @@ -1,20 +1,20 @@ package alice.jungle.persistent; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; public class PersistentChangeSet implements ChangeSet { - private final Node root; + private final TreeNode root; private final ChangeSet previous; private final ChangeList changeList; private final String uuid; private final long revision; private final String treeName; - public PersistentChangeSet(Node _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision) + public PersistentChangeSet(TreeNode _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision) { root = _node; previous = _prev; @@ -25,7 +25,7 @@ } @Override - public Node getRoot() + public TreeNode getRoot() { return root; }
--- a/src/main/java/alice/jungle/persistent/PersistentJungle.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/persistent/PersistentJungle.java Mon Sep 01 00:04:32 2014 +0900 @@ -4,12 +4,12 @@ import java.util.concurrent.ConcurrentHashMap; import fj.data.List; - import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; @@ -52,8 +52,8 @@ return _name; } }; - DefaultTreeNode root = new DefaultTreeNode(); - ChangeSet set = new PersistentChangeSet(root.getAsNode(),null,list,uuid,_name,0); + TreeNode root = new DefaultTreeNode(); + ChangeSet set = new PersistentChangeSet(root,null,list,uuid,_name,0); DefaultTreeContext<DefaultTreeNode> tc = new DefaultTreeContext<DefaultTreeNode>(root,set); JungleTree newTree = new PersistentJungleTree<DefaultTreeNode>(_name, tc,uuid, journal.getWriter(),editor); if(trees.putIfAbsent(_name,newTree) != null){
--- a/src/main/java/alice/jungle/persistent/PersistentJungleTree.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/persistent/PersistentJungleTree.java Mon Sep 01 00:04:32 2014 +0900 @@ -2,7 +2,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; @@ -11,7 +10,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultJungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.TreeContext; -public class PersistentJungleTree <T extends TreeNode<T>> implements JungleTree { +public class PersistentJungleTree <T extends TreeNode> implements JungleTree { private final AtomicReservableReference<TreeContext<T>> repository; private final String uuid; private final String treeName; @@ -32,12 +31,12 @@ { TreeContext<T> tc = repository.get(); PersistentTransactionManager<T> txManager = new PersistentTransactionManager<T>(treeName, writer,tc,repository,uuid); - T root = tc.getTreeNode(); + TreeNode root = tc.getTreeNode(); return new DefaultJungleTreeEditor<T>(root,txManager,editor); } @Override - public Node getRootNode() + public TreeNode getRootNode() { TreeContext<T> tc = repository.get(); ChangeSet cs = tc.getChangeSet();
--- a/src/main/java/alice/jungle/persistent/PersistentTransactionManager.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/persistent/PersistentTransactionManager.java Mon Sep 01 00:04:32 2014 +0900 @@ -1,6 +1,5 @@ package alice.jungle.persistent; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; @@ -16,7 +15,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class PersistentTransactionManager<T extends TreeNode<T>> implements TransactionManager<T> { +public class PersistentTransactionManager<T extends TreeNode> implements TransactionManager<T> { private final AtomicReservableReference<TreeContext<T>> repository; private final TreeContext<T> tip; private final ChangeListWriter writer; @@ -34,13 +33,13 @@ } @Override - public Either<Error, TransactionManager<T>> commit(T _newRoot,final TreeOperationLog _log) { + public Either<Error, TransactionManager<T>> commit(TreeNode _newRoot,final TreeOperationLog _log) { ChangeSet cs = tip.getChangeSet(); long currentRevision = cs.revision(); long nextRevision = currentRevision + 1; PersistentChangeList list = new PersistentChangeList(uuid, treeName, _log); - Node root = _newRoot.getAsNode(); + TreeNode root = _newRoot; PersistentChangeSet newCs = new PersistentChangeSet(root, cs, list, uuid, treeName, nextRevision); DefaultTreeContext<T> newContext = new DefaultTreeContext<T>(_newRoot,newCs);
--- a/src/main/java/alice/jungle/transaction/NetworkDefaultJungleTree.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/transaction/NetworkDefaultJungleTree.java Mon Sep 01 00:04:32 2014 +0900 @@ -2,7 +2,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; @@ -10,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.AtomicReservableReference; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.TreeContext; -public class NetworkDefaultJungleTree<T extends TreeNode<T>> implements JungleTree { +public class NetworkDefaultJungleTree<T extends TreeNode> implements JungleTree { private final AtomicReservableReference<TreeContext<T>> repository; private final String uuid; private final String treeName; @@ -31,7 +30,7 @@ { TreeContext<T> tc = repository.get(); NetworkTransactionManager<T> txManager = new NetworkTransactionManager<T>(treeName, writer,tc,repository,uuid); - T root = tc.getTreeNode(); + TreeNode root = tc.getTreeNode(); return new NetworkDefaultJungleTreeEditor<T>(treeName, root,txManager,editor); } @@ -40,12 +39,12 @@ { TreeContext<T> tc = repository.get(); NetworkTransactionManager<T> txManager = new NetworkTransactionManager<T>(treeName, writer,tc,repository,uuid); - T root = tc.getTreeNode(); + TreeNode root = tc.getTreeNode(); return NetworkDefaultJungleTreeEditor.NewLocalJungleTreeEditor(treeName,root,txManager, editor); } @Override - public Node getRootNode() + public TreeNode getRootNode() { TreeContext<T> tc = repository.get(); ChangeSet cs = tc.getChangeSet();
--- a/src/main/java/alice/jungle/transaction/NetworkDefaultJungleTreeEditor.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/transaction/NetworkDefaultJungleTreeEditor.java Mon Sep 01 00:04:32 2014 +0900 @@ -8,7 +8,6 @@ import alice.jungle.operations.NetworkTreeOperationLog; import app.bbs.codesegment.LogPutCodeSegment; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; @@ -30,21 +29,21 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; -public class NetworkDefaultJungleTreeEditor<T extends TreeNode<T>> implements JungleTreeEditor { +public class NetworkDefaultJungleTreeEditor<T extends TreeNode> implements JungleTreeEditor { private final TransactionManager<T> txManager; - private final T root; + private final TreeNode root; private final TreeEditor editor; private final String treeName; private final TreeOperationLog log; private boolean exportLog; - public NetworkDefaultJungleTreeEditor(String _treeName, T _root,TransactionManager<T> _txManager,TreeEditor _editor) + public NetworkDefaultJungleTreeEditor(String _treeName, TreeNode _root,TransactionManager<T> _txManager,TreeEditor _editor) { this(_treeName, _root,_txManager,_editor,new DefaultTreeOperationLog()); } - public NetworkDefaultJungleTreeEditor(String _treeName, T _root,TransactionManager<T> _txManager,TreeEditor _editor, TreeOperationLog _log) + public NetworkDefaultJungleTreeEditor(String _treeName, TreeNode _root,TransactionManager<T> _txManager,TreeEditor _editor, TreeOperationLog _log) { treeName = _treeName; root = _root; @@ -54,13 +53,13 @@ exportLog = true; } - public static <T1 extends TreeNode<T1>> NetworkDefaultJungleTreeEditor<T1> NewLocalJungleTreeEditor(String _treeName, T1 _root,TransactionManager<T1> _txManager,TreeEditor _editor) { + public static <T1 extends TreeNode> NetworkDefaultJungleTreeEditor<T1> NewLocalJungleTreeEditor(String _treeName, TreeNode _root,TransactionManager<T1> _txManager,TreeEditor _editor) { NetworkDefaultJungleTreeEditor<T1> treeEditor = new NetworkDefaultJungleTreeEditor<T1>(_treeName, _root,_txManager,_editor,new DefaultTreeOperationLog()); treeEditor.exportLog = false; return treeEditor; } - public static <T1 extends TreeNode<T1>> NetworkDefaultJungleTreeEditor<T1> NewLocalJungleTreeEditor(String _treeName, T1 _root,TransactionManager<T1> _txManager,TreeEditor _editor, TreeOperationLog _log) { + public static <T1 extends TreeNode> NetworkDefaultJungleTreeEditor<T1> NewLocalJungleTreeEditor(String _treeName, TreeNode _root,TransactionManager<T1> _txManager,TreeEditor _editor, TreeOperationLog _log) { NetworkDefaultJungleTreeEditor<T1> treeEditor = new NetworkDefaultJungleTreeEditor<T1>(_treeName, _root,_txManager,_editor,_log); treeEditor.exportLog = false; return treeEditor; @@ -69,12 +68,12 @@ private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { LoggingNodeHook hook = new LoggingNodeHook(_e); - Either<Error,T> either = editor.edit(root,_path,hook); + Either<Error,TreeNode> either = editor.edit(root,_path,hook); if(either.isA()){ return DefaultEither.newA(either.a()); } - T newNode = either.b(); + TreeNode newNode = either.b(); OperationLog newLog = hook.getLog(); IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ @@ -165,9 +164,9 @@ } @Override - public Node getRoot() + public TreeNode getRoot() { - return root.getAsNode(); + return root; } public String getTreeName() {
--- a/src/main/java/alice/jungle/transaction/NetworkTransactionManager.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/alice/jungle/transaction/NetworkTransactionManager.java Mon Sep 01 00:04:32 2014 +0900 @@ -2,7 +2,6 @@ import java.util.Iterator; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; @@ -21,7 +20,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class NetworkTransactionManager<T extends TreeNode<T>> implements TransactionManager<T> +public class NetworkTransactionManager<T extends TreeNode> implements TransactionManager<T> { private final AtomicReservableReference<TreeContext<T>> repository; @@ -41,7 +40,7 @@ } @Override - public Either<Error, TransactionManager<T>> commit(T _newRoot,final TreeOperationLog _log) { + public Either<Error, TransactionManager<T>> commit(TreeNode _newRoot,final TreeOperationLog _log) { ChangeSet cs = tip.getChangeSet(); long currentRevision = cs.revision(); long nextRevision = currentRevision + 1; @@ -61,7 +60,7 @@ } }; - Node root = _newRoot.getAsNode(); + TreeNode root = _newRoot; DefaultChangeSet newCs = new DefaultChangeSet(root, cs, list, uuid, treeName, nextRevision); DefaultTreeContext<T> newContext = new DefaultTreeContext<T>(_newRoot,newCs);
--- a/src/main/java/app/bbs/BulletinBoardJungleManager.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/BulletinBoardJungleManager.java Mon Sep 01 00:04:32 2014 +0900 @@ -3,16 +3,15 @@ import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicInteger; - import alice.jungle.operations.NetworkTreeOperationLog; import alice.jungle.transaction.JungleUpdater; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; 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.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -90,10 +89,10 @@ return either; } - private static int calculatePosition(Node node, long newNodeTimeStamp) { + private static int calculatePosition(TreeNode node, long newNodeTimeStamp) { int count = 0; long childTimeStamp = 0; - for(Node n : node.getChildren()) { + for(TreeNode n : node.getChildren()) { ByteBuffer timestamp = n.getAttributes().get("timestamp"); if(timestamp == null) { return count;
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Mon Sep 01 00:04:32 2014 +0900 @@ -16,13 +16,14 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TraversableNodeWrapper; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +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.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; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultEvaluator; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; @@ -43,7 +44,8 @@ private NetworkJungleBulletinBoard(String _uuid, NetworkJournal _journal) { journal = _journal; - jungle = new NetworkDefaultJungle(journal, _uuid, new DefaultTreeEditor(new DefaultTraverser())); + jungle = new NetworkDefaultJungle(journal, _uuid, + new DefaultTreeEditor(new DefaultTraverser())); BulletinBoardJungleManager.setJungle(jungle); persistentFlag = false; requestCounter = BulletinBoardJungleManager.getRequestCounter(); @@ -57,7 +59,8 @@ } public static NetworkBulletinBoard NewPersistentJungle(String _uuid) { - NetworkJungleBulletinBoard board = new NetworkJungleBulletinBoard( _uuid, new PersistentJournal()); + NetworkJungleBulletinBoard board = new NetworkJungleBulletinBoard( + _uuid, new PersistentJournal()); board.persistentFlag = true; return board; } @@ -109,7 +112,8 @@ tree = jungle.createNewTree(treeName); } JungleTreeEditor editor = tree.getLocalTreeEditor(); - Either<Error, JungleTreeEditor> either = JungleUpdater.edit(editor, chList); + Either<Error, JungleTreeEditor> either = JungleUpdater.edit(editor, + chList); editor = either.b(); if (either.isA()) { throw new IOException("Failed commit log recovery"); @@ -120,18 +124,18 @@ public Iterable<String> getBoards() { JungleTree tree = jungle.getTreeByName("boards"); - Node node = tree.getRootNode(); - Children<Node> chs = node.getChildren(); + TreeNode node = tree.getRootNode(); + Children<TreeNode> chs = node.getChildren(); - IterableConverter.Converter<String, Node> converter = new IterableConverter.Converter<String, Node>() { - public String conv(Node _b) { + IterableConverter.Converter<String, TreeNode> converter = new IterableConverter.Converter<String, TreeNode>() { + public String conv(TreeNode _b) { ByteBuffer e = _b.getAttributes().get("name"); System.out.println(new String(e.array())); return new String(e.array()); } }; - return new IterableConverter<String, Node>(chs, converter); + return new IterableConverter<String, TreeNode>(chs, converter); } public long getRenewTime(String _boardName) { @@ -153,7 +157,8 @@ } 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(); } @@ -179,14 +184,26 @@ editor = either.b(); NodeEditor e = new NodeEditor() { - public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - _e = _e.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); - _e = _e.getAttributes().put("mes", ByteBuffer.wrap(_initMessage.getBytes())).b(); - _e = _e.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); - ByteBuffer tBuffer2 = ByteBuffer.allocate(16); + ByteBuffer tBuffer2 = ByteBuffer.allocate(16); + + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + 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(); tBuffer2.putLong(timestamp); - _e = _e.getAttributes().put("timestamp", tBuffer2).b(); - return DefaultEither.newB(_e); + node = node.getAttributes().put("timestamp", tBuffer2).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); + op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_initMessage.getBytes()))); + op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp", tBuffer2)); + return op; } }; @@ -203,12 +220,13 @@ if (tree == null) { throw new IllegalStateException(); } - + DefaultNodePath path = new DefaultNodePath(); try { for (int count = 0; _nodeNum.substring(count, count + 1) != null; count++) { if (!_nodeNum.substring(count, count + 1).equals("/")) - path = path.add(Integer.parseInt(_nodeNum.substring(count, count + 1))); + path = path.add(Integer.parseInt(_nodeNum.substring(count, + count + 1))); } } catch (Exception _e) { } @@ -217,20 +235,22 @@ final long timestamp = System.currentTimeMillis(); final ByteBuffer tBuffer = ByteBuffer.allocate(16); tBuffer.putLong(timestamp); - + do { - Node node = tree.getRootNode(); + TreeNode node = tree.getRootNode(); DefaultTraverser traverser = new DefaultTraverser(); - TraversableNodeWrapper<Node> traversable = new TraversableNodeWrapper<Node>(node); + // TraversableNodeWrapper<Node> traversable = new + // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TraversableNodeWrapper<Node>>> ret = traverser.traverse(traversable, evaluator); + Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TraversableNodeWrapper<Node>> traversal = ret.b(); - TraversableNodeWrapper<Node> target = traversal.destination(); - int size = target.getWrapped().getChildren().size(); + Traversal<TreeNode> traversal = ret.b(); + TreeNode target = traversal.destination(); + int size = target.getChildren().size(); JungleTreeEditor editor = tree.getTreeEditor(); either = editor.addNewChildAt(path, size); if (either.isA()) { @@ -239,10 +259,20 @@ editor = either.b(); NodeEditor e = new NodeEditor() { - public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - _e = _e.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("timestamp", tBuffer).b(); - return DefaultEither.newB(_e); + + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + node = node.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); + node = node.getAttributes().put("timestamp", tBuffer).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp", tBuffer)); + return op; } }; path = path.add(size); @@ -268,8 +298,8 @@ final ByteBuffer tBuffer = ByteBuffer.allocate(16); tBuffer.putLong(timestamp); do { - - Node node = tree.getRootNode(); + + TreeNode node = tree.getRootNode(); int size = node.getChildren().size(); DefaultNodePath path = new DefaultNodePath(); @@ -281,12 +311,23 @@ editor = either.b(); NodeEditor e = new NodeEditor() { - public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - _e = _e.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); - _e = _e.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); - _e = _e.getAttributes().put("timestamp", tBuffer).b(); - return DefaultEither.newB(_e); + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + 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(); + node = node.getAttributes().put("timestamp", tBuffer).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); + op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp", tBuffer)); + return op; } }; path = path.add(size); @@ -300,31 +341,44 @@ } - public void editMessage(String _board, String _nodeNum, final String _author, final String _message, final String _editKey) { + public void editMessage(String _board, String _nodeNum,final String _author, final String _message, final String _editKey) { 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; - + do { DefaultNodePath path = new DefaultNodePath(); try { for (int count = 0; _nodeNum.substring(count, count + 1) != null; count++) { if (!_nodeNum.substring(count, count + 1).equals("/")) - path = path.add(Integer.parseInt(_nodeNum.substring(count,count + 1))); + path = path.add(Integer.parseInt(_nodeNum.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().put("author", ByteBuffer.wrap(_author.getBytes())).b(); - _e = _e.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); - _e = _e.getAttributes().put("timestamp", tBuffer).b(); - return DefaultEither.newB(_e); + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + System.out.println(new String(node.getAttributes().get("mes").array())); + 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(); + node = node.getAttributes().put("timestamp", tBuffer).b(); + System.out.println(new String(node.getAttributes().get("mes").array())); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); + op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp", tBuffer)); + return op; } }; either = editor.edit(path, e); @@ -349,22 +403,34 @@ try { for (int count = 0; _uuid.substring(count, count + 1) != null; count++) { if (!_uuid.substring(count, count + 1).equals("/")) - path = path.add(Integer.parseInt(_uuid.substring(count, count + 1))); + path = path.add(Integer.parseInt(_uuid.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) { - String str = "0"; + String str; + + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + str = "0"; int count = 0; - for (; _e.getAttributes().get("mes" + String.valueOf(count)) != null; count++) { - } + for (; _e.getAttributes().get("mes" + String.valueOf(count)) != null; count++) { + } str = String.valueOf(count); - _e = _e.getAttributes().put("mes" + str, ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("timestamp" + str, tBuffer).b(); - return DefaultEither.newB(_e); + node = node.getAttributes().put("mes" + str,ByteBuffer.wrap(_message.getBytes())).b(); + node = node.getAttributes().put("timestamp" + str, tBuffer).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("mes" + str,ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp" + str,tBuffer)); + return op; } }; either = editor.edit(path, e); @@ -388,18 +454,28 @@ 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))); + 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) { + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; // EnableNodeWrapper<T> node = _e.getWrap(); - _e = _e.getAttributes().put("mes" + id, ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("timestamp" + id, tBuffer).b(); - return DefaultEither.newB(_e); + node = node.getAttributes().put("mes" + id,ByteBuffer.wrap(_message.getBytes())).b(); + node = node.getAttributes().put("timestamp" + id, tBuffer).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("mes"+ id, ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp"+ id, tBuffer)); + return op; } }; either = editor.edit(path, e); @@ -410,8 +486,7 @@ either = editor.success(); } while (either.isA()); } - - + public void deleteNode(String _board, String _path, String _id) { requestCounter.incrementAndGet(); int id = Integer.parseInt(_id); @@ -425,11 +500,11 @@ 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))); + path = path.add(Integer.parseInt(_path.substring(count,count + 1))); } } catch (Exception _e) { } - + JungleTreeEditor editor = tree.getTreeEditor(); either = editor.deleteChildAt(path, id); @@ -439,9 +514,10 @@ editor = either.b(); either = editor.success(); } while (either.isA()); - + } - public void deleteAttribute(String _board, String _path ,final String id) { + + public void deleteAttribute(String _board, String _path, final String id) { requestCounter.incrementAndGet(); final long timestamp = System.currentTimeMillis(); final ByteBuffer tBuffer = ByteBuffer.allocate(16); @@ -453,29 +529,36 @@ 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))); + path = path.add(Integer.parseInt(_path.substring(count, + count + 1))); } } catch (Exception _e) { System.out.println("屑"); } - + 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(); + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + node = node.getAttributes().delete("mes" + id).b(); + node = node.getAttributes().delete("timestamp" + id).b(); int count = Integer.parseInt(id); - for (; _e.getAttributes().get("mes" + String.valueOf(count + 1)) != null;) { - _e = _e.getAttributes().put("mes" + count, _e.getAttributes().get("mes" + String.valueOf(count + 1))).b(); - _e = _e.getAttributes().put("timestamp" + count, tBuffer).b(); - count++; - } - if(count != Integer.parseInt(id)){ - _e = _e.getAttributes().delete("timestamp" + count ).b(); - _e = _e.getAttributes().delete("mes" + count ).b(); + for (; node.getAttributes().get("mes" + String.valueOf(count + 1)) != null;) { + node = node.getAttributes().put("mes" + count,_e.getAttributes().get("mes"+ String.valueOf(count + 1))).b(); + node = node.getAttributes().put("timestamp" + count, tBuffer).b(); + count++; + } + if (count != Integer.parseInt(id)) { + node = node.getAttributes().delete("timestamp" + count).b(); + node = node.getAttributes().delete("mes" + count).b(); } - return DefaultEither.newB(_e); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + return new DefaultOperationLog(); } }; either = editor.edit(path, e); @@ -486,10 +569,9 @@ either = editor.success(); } while (either.isA()); } - - - public void editMatrixMessage(String _board, String _uuid, final String _author, final String _message, final String _editKey) { + public void editMatrixMessage(String _board, String _uuid, + final String _author, final String _message, final String _editKey) { requestCounter.incrementAndGet(); final long timestamp = System.currentTimeMillis(); final ByteBuffer tBuffer = ByteBuffer.allocate(16); @@ -502,12 +584,23 @@ JungleTreeEditor editor = tree.getTreeEditor(); NodeEditor e = new NodeEditor() { - public <T extends EditableNode<T>> Either<Error, T> edit(T _e) { - _e = _e.getAttributes().put("author", ByteBuffer.wrap(_author.getBytes())).b(); - _e = _e.getAttributes().put("mes", ByteBuffer.wrap(_message.getBytes())).b(); - _e = _e.getAttributes().put("key", ByteBuffer.wrap(_editKey.getBytes())).b(); - _e = _e.getAttributes().put("timestamp", tBuffer).b(); - return DefaultEither.newB(_e); + public <T extends TreeNode> Either<Error, TreeNode> edit(T _e) { + TreeNode node = _e; + 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(); + node = node.getAttributes().put("timestamp", tBuffer).b(); + return DefaultEither.newB(node); + } + + @Override + public OperationLog getLog() { + OperationLog op = new DefaultOperationLog(); + op = op.add(new PutAttributeOperation("author", ByteBuffer.wrap(_author.getBytes()))); + op = op.add(new PutAttributeOperation("mes", ByteBuffer.wrap(_message.getBytes()))); + op = op.add(new PutAttributeOperation("key", ByteBuffer.wrap(_editKey.getBytes()))); + op = op.add(new PutAttributeOperation("timestamp", tBuffer)); + return op; } }; either = editor.edit(path, e); @@ -523,19 +616,19 @@ public Iterable<BoardMessage> getMessages(String _boardName) { requestCounter.incrementAndGet(); JungleTree tree = jungle.getTreeByName(_boardName); - Node node = tree.getRootNode(); - Children<Node> chs = node.getChildren(); + TreeNode node = tree.getRootNode(); + Children<TreeNode> chs = node.getChildren(); final AtomicInteger counter = new AtomicInteger(0); - IterableConverter.Converter<BoardMessage, Node> converter = new IterableConverter.Converter<BoardMessage, Node>() { - public BoardMessage conv(Node _b) { + IterableConverter.Converter<BoardMessage, TreeNode> converter = new IterableConverter.Converter<BoardMessage, TreeNode>() { + public BoardMessage conv(TreeNode _b) { String uuid = Integer.toString(counter.get()); - String author = new String(_b.getAttributes().get("author") .array()); + String author = new String(_b.getAttributes().get("author").array()); String message = new String(_b.getAttributes().get("mes").array()); counter.incrementAndGet(); return new BoardMessageImpl(author, message, uuid); } }; - return new IterableConverter<BoardMessage, Node>(chs, converter); + return new IterableConverter<BoardMessage, TreeNode>(chs, converter); } public Iterable<BoardMessage> getFolder(String _boardName, String _nodeNum) { @@ -550,32 +643,34 @@ } requestCounter.incrementAndGet(); JungleTree tree = jungle.getTreeByName(_boardName); - Node node = tree.getRootNode(); + TreeNode node = tree.getRootNode(); DefaultTraverser traverser = new DefaultTraverser(); - TraversableNodeWrapper<Node> traversable = new TraversableNodeWrapper<Node>(node); + // TraversableNodeWrapper<Node> traversable = new + // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TraversableNodeWrapper<Node>>> ret = traverser.traverse(traversable, evaluator); + Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TraversableNodeWrapper<Node>> traversal = ret.b(); - TraversableNodeWrapper<Node> target = traversal.destination(); - Children<Node> chs = target.getWrapped().getChildren(); + Traversal<TreeNode> traversal = ret.b(); + TreeNode target = traversal.destination(); + Children<TreeNode> chs = target.getChildren(); final AtomicInteger counter = new AtomicInteger(0); - IterableConverter.Converter<BoardMessage, Node> converter = new IterableConverter.Converter<BoardMessage, Node>() { - public BoardMessage conv(Node _b) { + IterableConverter.Converter<BoardMessage, TreeNode> converter = new IterableConverter.Converter<BoardMessage, TreeNode>() { + public BoardMessage conv(TreeNode _b) { String uuid = Integer.toString(counter.get()); - String message = new String(_b.getAttributes().get("mes").array()); + String message = new String(_b.getAttributes().get("mes") + .array()); counter.incrementAndGet(); return new BoardMessageImpl(null, message, uuid); } }; - return new IterableConverter<BoardMessage, Node>(chs, converter); + return new IterableConverter<BoardMessage, TreeNode>(chs, converter); } - public getAttributeImp getAttribute(String _boardName, String _nodeNum) { @@ -583,25 +678,28 @@ try { for (int count = 0; _nodeNum.substring(count, count + 1) != null; count++) { if (!_nodeNum.substring(count, count + 1).equals("/")) - path = path.add(Integer.parseInt(_nodeNum.substring(count,count + 1))); + path = path.add(Integer.parseInt(_nodeNum.substring(count, + count + 1))); } } catch (Exception _e) { } requestCounter.incrementAndGet(); JungleTree tree = jungle.getTreeByName(_boardName); - Node node = tree.getRootNode(); + TreeNode node = tree.getRootNode(); DefaultTraverser traverser = new DefaultTraverser(); - TraversableNodeWrapper<Node> traversable = new TraversableNodeWrapper<Node>(node); + // TraversableNodeWrapper<Node> traversable = new + // TraversableNodeWrapper<Node>(node); DefaultEvaluator evaluator = new DefaultEvaluator(path); - Either<Error, Traversal<TraversableNodeWrapper<Node>>> ret = traverser.traverse(traversable, evaluator); + Either<Error, Traversal<TreeNode>> ret = traverser.traverse(node, + evaluator); if (ret.isA()) { Assert.fail(); } - Traversal<TraversableNodeWrapper<Node>> traversal = ret.b(); - TraversableNodeWrapper<Node> target = traversal.destination(); - return new getAttributeImp(target.getWrapped()); + Traversal<TreeNode> traversal = ret.b(); + TreeNode target = traversal.destination(); + return new getAttributeImp(target); } public int getRequestNum() { @@ -632,18 +730,17 @@ } } - - public String sanitize( String str ) { - if(str==null) { - return str; - } - str = str.replaceAll("&" , "&" ); - str = str.replaceAll("<" , "<" ); - str = str.replaceAll(">" , ">" ); - str = str.replaceAll("\"", """); - str = str.replaceAll("'" , "'" ); - return str; - } + public String sanitize(String str) { + if (str == null) { + return str; + } + str = str.replaceAll("&", "&"); + str = str.replaceAll("<", "<"); + str = str.replaceAll(">", ">"); + str = str.replaceAll("\"", """); + str = str.replaceAll("'", "'"); + return str; + } }
--- a/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import org.eclipse.jetty.util.thread.ThreadPool; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage;
--- a/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Mon Sep 01 00:04:32 2014 +0900 @@ -12,7 +12,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.CreateBoardMessageServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.CreateBoardServlet; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.EditMessageServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.EditMessageUseGetServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.ShowBoardsServlet;
--- a/src/main/java/app/bbs/thinks/CreateNode.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/CreateNode.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import app.bbs.NetworkBulletinBoard;
--- a/src/main/java/app/bbs/thinks/EditAttributeServlet.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/EditAttributeServlet.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,10 +6,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import app.bbs.NetworkBulletinBoard; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard; public class EditAttributeServlet extends HttpServlet { @@ -17,7 +15,7 @@ private static final String PARAM_BOARD_NAME = "bname"; private static final String PARAM_NODE_PATH = "path"; private static final String PARAM_BOARD_MESSAGE= "msg"; - private static final String PARAM_BOARD_EDITKEY = "key"; + //private static final String PARAM_BOARD_EDITKEY = "key"; private static final String PARAM_NODE_ID = "id"; private static final long serialVersionUID = 1L;
--- a/src/main/java/app/bbs/thinks/EditNodeName.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/EditNodeName.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BulletinBoard;
--- a/src/main/java/app/bbs/thinks/ShowMatrix.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/ShowMatrix.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import org.eclipse.jetty.util.thread.ThreadPool; import app.bbs.NetworkBulletinBoard;
--- a/src/main/java/app/bbs/thinks/createAttributeMatrix.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/createAttributeMatrix.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,8 +6,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; - import app.bbs.NetworkBulletinBoard; public class createAttributeMatrix extends HttpServlet
--- a/src/main/java/app/bbs/thinks/deleteAttributeServlet.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/deleteAttributeServlet.java Mon Sep 01 00:04:32 2014 +0900 @@ -6,18 +6,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; - 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_NODE_PATH = "path"; - private static final String PARAM_BOARD_MESSAGE= "msg"; - private static final String PARAM_BOARD_EDITKEY = "key"; + //private static final String PARAM_BOARD_MESSAGE= "msg"; + //private static final String PARAM_BOARD_EDITKEY = "key"; private static final String PARAM_NODE_ID = "id"; private static final long serialVersionUID = 1L;
--- a/src/main/java/app/bbs/thinks/deleteNodeServlet.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/deleteNodeServlet.java Mon Sep 01 00:04:32 2014 +0900 @@ -4,9 +4,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.StringEscapeUtils; - import app.bbs.NetworkBulletinBoard; public class deleteNodeServlet extends HttpServlet
--- a/src/main/java/app/bbs/thinks/getAttributeImp.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/main/java/app/bbs/thinks/getAttributeImp.java Mon Sep 01 00:04:32 2014 +0900 @@ -1,14 +1,15 @@ package app.bbs.thinks; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; + -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; public class getAttributeImp { - private final Node node; + private final TreeNode node; - public getAttributeImp(Node _node) + public getAttributeImp(TreeNode _node) { node = _node; }
--- a/src/test/java/alice/jungle/PersistentJournalTest.java Wed Jul 30 22:17:23 2014 +0900 +++ b/src/test/java/alice/jungle/PersistentJournalTest.java Mon Sep 01 00:04:32 2014 +0900 @@ -12,11 +12,11 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; 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.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; @@ -61,18 +61,18 @@ editor2.success(); } JungleTree tree2 = jungle2.getTreeByName("hoge"); - Node node1 = tree1.getRootNode(); - Node node2 = tree2.getRootNode(); - Children<Node> child1 = node1.getChildren(); - Children<Node> child2 = node2.getChildren(); + TreeNode node1 = tree1.getRootNode(); + TreeNode node2 = tree2.getRootNode(); + Children<TreeNode> child1 = node1.getChildren(); + Children<TreeNode> child2 = node2.getChildren(); assertEquals(child1.size(), child2.size()); - Either<Error, Node> either1 = child1.at(pos); - Either<Error, Node> either2 = child1.at(pos); + Either<Error, TreeNode> either1 = child1.at(pos); + Either<Error, TreeNode> either2 = child1.at(pos); assertFalse(either1.isA()); assertFalse(either2.isA()); - Node nodeA = either1.b(); - Node nodeB = either2.b(); + TreeNode nodeA = either1.b(); + TreeNode nodeB = either2.b(); ByteBuffer bb1 = nodeA.getAttributes().get(key); ByteBuffer bb2 = nodeB.getAttributes().get(key); String strA = new String(bb1.array());