Mercurial > hg > Database > jungle-network
annotate src/jungle/app/bbs/codesegment/LogUpdateCodeSegment.java @ 96:fcce7ca4adb9
Modified LogUpdateCodesegment
author | one |
---|---|
date | Mon, 18 Nov 2013 19:34:15 +0900 |
parents | 87ec5dd0dc27 |
children | 11ad00323206 |
rev | line source |
---|---|
66 | 1 package jungle.app.bbs.codesegment; |
34 | 2 |
40 | 3 |
59
8a532ca5df80
refactoring LogUpdateCodeSegment and ChildLogCheckCodeSegment
one
parents:
58
diff
changeset
|
4 |
96 | 5 import java.util.List; |
6 | |
40 | 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | |
66 | 10 import jungle.app.bbs.JungleManager; |
34 | 11 import alice.codesegment.CodeSegment; |
12 import alice.datasegment.CommandType; | |
13 import alice.datasegment.Receiver; | |
96 | 14 import alice.jungle.operations.NetworkTreeOperationLog; |
34 | 15 |
16 public class LogUpdateCodeSegment extends CodeSegment { | |
17 | |
96 | 18 Receiver log = ids.create(CommandType.PEEK); |
52 | 19 Receiver host = ids.create(CommandType.PEEK); |
96 | 20 Receiver clist = ids.create(CommandType.PEEK); |
21 | |
39 | 22 |
47 | 23 public LogUpdateCodeSegment() { |
96 | 24 log.setKey("log"); |
50 | 25 host.setKey("host"); |
96 | 26 clist.setKey("_CLIST");; |
39 | 27 } |
28 | |
50 | 29 public LogUpdateCodeSegment(int index) { |
96 | 30 log.setKey("log", index); |
50 | 31 host.setKey("host"); |
96 | 32 clist.setKey("_CLIST");; |
49 | 33 } |
34 | |
34 | 35 public void run() { |
96 | 36 int index = log.index; |
37 NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); | |
38 String hostName = host.asString(); | |
39 @SuppressWarnings("unchecked") | |
40 List<String> list = clist.asClass(List.class); | |
41 if (!hostName.equals((log.from))) { | |
42 Either<Error, JungleTreeEditor> either = JungleManager.update(netLog); | |
43 if(either.isA()) { | |
44 throw new IllegalStateException(); | |
45 } | |
42 | 46 } |
96 | 47 for (String node : list) { |
48 if (!node.equals(log.from)) { | |
49 ods.update(node, log.key, log.getVal()); | |
50 } | |
46 | 51 } |
51 | 52 new LogUpdateCodeSegment(index); |
34 | 53 } |
54 } |