comparison src/main/java/app/bbs/PersistentJungleBulletinBoard.java @ 130:652a6dff6288

Fixed
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sat, 11 Jan 2014 09:10:02 +0900
parents 6104702a1880
children a6fa10e42601
comparison
equal deleted inserted replaced
129:1a3edba05f50 130:652a6dff6288
127 either = editor.putAttribute(root.add(0),"name",ByteBuffer.wrap(_name.getBytes())); 127 either = editor.putAttribute(root.add(0),"name",ByteBuffer.wrap(_name.getBytes()));
128 if(either.isA()){ 128 if(either.isA()){
129 throw new IllegalStateException(); 129 throw new IllegalStateException();
130 } 130 }
131 editor = either.b(); 131 editor = either.b();
132 final long timestamp = new Date().getTime();
133 ByteBuffer tBuffer = ByteBuffer.allocate(16);
134 either = editor.putAttribute(root.add(0),"timestamp", tBuffer.putLong(timestamp));
135 if(either.isA()){
136 throw new IllegalStateException();
137 }
138 editor = either.b();
132 Either<Error,JungleTreeEditor> result = editor.success(); 139 Either<Error,JungleTreeEditor> result = editor.success();
133 if(result.isA()){ 140 if(result.isA()){
134 throw new IllegalStateException(); 141 throw new IllegalStateException();
135 } 142 }
136 final long timestamp = new Date().getTime();
137 143
138 144
139 tree = jungle.getTreeByName(_name); 145 tree = jungle.getTreeByName(_name);
140 editor = tree.getTreeEditor(); 146 editor = tree.getTreeEditor();
141 either = editor.addNewChildAt(root,0); 147 either = editor.addNewChildAt(root,0);
147 NodeEditor e = new NodeEditor(){ 153 NodeEditor e = new NodeEditor(){
148 public <T extends EditableNode<T>> Either<Error, T> edit(T _e){ 154 public <T extends EditableNode<T>> Either<Error, T> edit(T _e){
149 _e = _e.getAttributes().put("author",ByteBuffer.wrap(_author.getBytes())).b(); 155 _e = _e.getAttributes().put("author",ByteBuffer.wrap(_author.getBytes())).b();
150 _e = _e.getAttributes().put("mes",ByteBuffer.wrap(_initMessage.getBytes())).b(); 156 _e = _e.getAttributes().put("mes",ByteBuffer.wrap(_initMessage.getBytes())).b();
151 _e = _e.getAttributes().put("key",ByteBuffer.wrap(_editKey.getBytes())).b(); 157 _e = _e.getAttributes().put("key",ByteBuffer.wrap(_editKey.getBytes())).b();
152 ByteBuffer tBuffer = ByteBuffer.allocate(16); 158 ByteBuffer tBuffer2 = ByteBuffer.allocate(16);
153 _e = _e.getAttributes().put("timestamp",tBuffer.putLong(timestamp)).b(); 159 _e = _e.getAttributes().put("timestamp",tBuffer2.putLong(timestamp)).b();
154 return DefaultEither.newB(_e); 160 return DefaultEither.newB(_e);
155 } 161 }
156 }; 162 };
157 163
158 either = editor.edit(root.add(0),e); 164 either = editor.edit(root.add(0),e);