85
|
1 package alice.jungle.persistence;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.io.OutputStream;
|
|
5
|
|
6 import org.msgpack.MessagePack;
|
|
7
|
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
|
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
|
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result;
|
|
11 import alice.jungle.operations.NetworkTreeOperationLog;
|
|
12
|
|
13 public class PersistentChangeListWriter implements ChangeListWriter {
|
|
14
|
|
15 MessagePack msgpack = NetworkJournal.getMessagePack();
|
|
16 OutputStream out;
|
|
17
|
|
18 public PersistentChangeListWriter(OutputStream _out) {
|
|
19 out = _out;
|
|
20 }
|
|
21
|
|
22 @Override
|
88
|
23 public Result write(ChangeList cs)
|
85
|
24 {
|
88
|
25 NetworkTreeOperationLog log = new NetworkTreeOperationLog(cs.uuid(), cs.getTreeName(), cs);
|
85
|
26 try {
|
|
27 msgpack.write(out, log);
|
|
28 out.flush();
|
87
|
29 return Result.SUCCESS;
|
85
|
30 } catch (IOException e) {
|
|
31 }
|
87
|
32 return null;
|
85
|
33 }
|
|
34 }
|