Mercurial > hg > Members > nobuyasu > jungle-network
view src/main/java/app/bbs/codesegment/LogUpdateCodeSegment.java @ 112:8f9811a1e00c
Moved app files
author | one |
---|---|
date | Fri, 29 Nov 2013 04:31:22 +0900 |
parents | src/main/java/jungle/app/bbs/codesegment/LogUpdateCodeSegment.java@f42f2e6b31de |
children | 7d9b7fcb4d9a |
line wrap: on
line source
package app.bbs.codesegment; import java.util.List; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.operations.NetworkTreeOperationLog; import app.bbs.JungleManager; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; public class LogUpdateCodeSegment extends CodeSegment { Receiver log = ids.create(CommandType.PEEK); Receiver clist = ids.create(CommandType.PEEK); public LogUpdateCodeSegment() { log.setKey("log"); clist.setKey("_CLIST");; } public LogUpdateCodeSegment(int index) { log.setKey("log", index); clist.setKey("_CLIST");; } public void run() { int index = log.index; NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); @SuppressWarnings("unchecked") List<String> list = clist.asClass(List.class); if (!log.from.equals("local")) { Either<Error, JungleTreeEditor> either = JungleManager.update(netLog); if(either.isA()) { /* Should throw after new LogUpdateCodeSegment */ throw new IllegalStateException(); } } for (String node : list) { if (!node.equals(log.from)) { ods.put(node, log.key, log.getVal()); } } new LogUpdateCodeSegment(index); } }