diff --git a/src/main/java/org/bdware/server/action/EventActions.java b/src/main/java/org/bdware/server/action/EventActions.java index 13bd2a7..c03a8eb 100644 --- a/src/main/java/org/bdware/server/action/EventActions.java +++ b/src/main/java/org/bdware/server/action/EventActions.java @@ -36,6 +36,6 @@ public class EventActions { CMActions.manager.subEventByClient(topic, rcb.getChannel()); ret.addProperty("status", "Success"); ret.addProperty("data", topic); - rcb.onResult(ret.toString()); + rcb.onResult(ret); } } diff --git a/src/main/java/org/bdware/server/action/FileActions.java b/src/main/java/org/bdware/server/action/FileActions.java index 8cdf785..3349604 100644 --- a/src/main/java/org/bdware/server/action/FileActions.java +++ b/src/main/java/org/bdware/server/action/FileActions.java @@ -35,7 +35,6 @@ import org.bdware.server.http.URIPath; import org.bdware.server.nodecenter.Response; import org.bdware.server.permission.Role; import org.bdware.server.ws.ContractManagerFrameHandler; -import org.bdware.units.NetworkManager; import org.zz.gmhelper.SM2KeyPair; import org.zz.gmhelper.SM2Util; @@ -631,27 +630,24 @@ public class FileActions { @Action(userPermission = 1 << 10) public void lockEdit(JsonObject args, ResultCallback resultCallback) { if (!args.has("pubKey")) { - resultCallback.onResult( - "{\"action\":\"onLockEdit\",\"status\":\"failed\",\"data\":\"missing pubKey\"}"); + ReplyUtil.replyWithStatus(resultCallback, "onLockEdit", false, "missing pubkey"); return; } String pubKey = args.get("pubKey").getAsString(); KeyValueDBUtil.instance.setValue(CMTables.LockedUser.toString(), pubKey, "locked"); - resultCallback.onResult( - "{\"action\":\"onLockEdit\",\"status\":\"success\",\"data\":\"" + pubKey + "\"}"); + ReplyUtil.replyWithStatus(resultCallback, "onLockEdit", true, pubKey); + } @Action(userPermission = 1 << 10) public void unlockEdit(JsonObject args, ResultCallback resultCallback) { if (!args.has("pubKey")) { - resultCallback.onResult( - "{\"action\":\"onUnLockEdit\",\"status\":\"failed\",\"data\":\"missing pubKey\"}"); + ReplyUtil.replyWithStatus(resultCallback, "onUnlockEdit", false, "missing pubkey"); return; } String pubKey = args.get("pubKey").getAsString(); KeyValueDBUtil.instance.delete(CMTables.LockedUser.toString(), pubKey); - resultCallback.onResult( - "{\"action\":\"onUnlockEdit\",\"status\":\"success\",\"data\":\"" + pubKey + "\"}"); + ReplyUtil.replyWithStatus(resultCallback, "onUnlockEdit", true, pubKey); } @Action(userPermission = 1L << 17, async = true) @@ -677,7 +673,7 @@ public class FileActions { Map r = new HashMap<>(); r.put("action", "onCompile"); r.put("result", compileInternal(parPath, projectName, isPrivate, false)); - resultCallback.onResult(JsonUtil.toJson(r)); + resultCallback.onResult(r); } @Action(userPermission = 1L << 17, async = true) @@ -718,11 +714,11 @@ public class FileActions { } } } else { - resultCallback.onResult(JsonUtil.toJson(r)); + resultCallback.onResult(r); return; } if (manifest == null) { - resultCallback.onResult(JsonUtil.toJson(r)); + resultCallback.onResult(r); return; } @@ -744,7 +740,7 @@ public class FileActions { if (doi == null) { r.put("result", "get doi register failed!"); - resultCallback.onResult(JsonUtil.toJson(r)); + resultCallback.onResult(r); return; } @@ -793,7 +789,7 @@ public class FileActions { changeSet.remove(dir.getAbsolutePath()); r.put("result", doi); - resultCallback.onResult(JsonUtil.toJson(r)); + resultCallback.onResult(r); } @Action(userPermission = 1L << 17) @@ -803,7 +799,7 @@ public class FileActions { response.data = "[]"; response.isPrivate = false; List dirs = new ArrayList<>(); - + ReplyUtil.injectRequestID(response, json); File f; if (json.has("isPrivate") && json.get("isPrivate").getAsBoolean()) { @@ -812,6 +808,7 @@ public class FileActions { } else { f = new File(GlobalConf.instance.publicCompiledDir); } + ReplyUtil.injectRequestID(response, json); returnFileListResponse(resultCallback, response, dirs, f); } @@ -824,6 +821,7 @@ public class FileActions { response.data = "[]"; response.isPrivate = false; List dirs = new ArrayList<>(); + ReplyUtil.injectRequestID(response, json); File f; @@ -858,6 +856,8 @@ public class FileActions { response.action = "onGetProject"; response.data = "[]"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); + List dirs = new ArrayList<>(); String project = json.get("project").getAsString(); @@ -891,6 +891,8 @@ public class FileActions { String project = json.get("project").getAsString(); response.data = "[]"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); + ListProjectResp resp = new ListProjectResp(); // List dirs = new ArrayList<>(); @@ -928,6 +930,9 @@ public class FileActions { Response response = new Response(); response.action = "onListFile"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); + + ListProjectResp resp = new ListProjectResp(); String parPath; @@ -964,6 +969,7 @@ public class FileActions { String url; Response response = new Response(); response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); String projectDir; @@ -1078,6 +1084,7 @@ public class FileActions { response.action = "onRenameFile"; response.data = "failed"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); String parPath; if (json.has("isPrivate") && json.get("isPrivate").getAsBoolean()) { @@ -1314,6 +1321,7 @@ public class FileActions { e.printStackTrace(); } } + ReplyUtil.injectRequestID(response, json); resultCallback.onResult(JsonUtil.toJson(response)); } @@ -1336,7 +1344,7 @@ public class FileActions { ret.put("data", dirs); } ret.put("action", "onListMemoryFiles"); - resultCallback.onResult(JsonUtil.toJson(ret)); + resultCallback.onResult(ret); } @Action(userPermission = 1L << 23) @@ -1346,6 +1354,7 @@ public class FileActions { response.data = "failed"; String contractName = json.get("contractName").getAsString(); String path = GlobalConf.instance.memoryDir + "/" + contractName; + ReplyUtil.injectRequestID(response, json); try { String fileName = json.get("file").getAsString(); @@ -1379,6 +1388,7 @@ public class FileActions { response.data = "failed"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); File file = new File(GlobalConf.instance.privateDir + "/" + handler.getPubKey(), fileName); LOGGER.debug("[FileActions] from " + file.getAbsolutePath()); @@ -1406,6 +1416,7 @@ public class FileActions { response.action = "onUploadFile"; response.data = "failed"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); String fileName = json.get("fileName").getAsString(); if (!checkFileType(fileName)) { @@ -1480,6 +1491,8 @@ public class FileActions { response.action = "onSaveFile"; response.data = "failed"; response.isPrivate = false; + ReplyUtil.injectRequestID(response, json); + try { boolean isAppend = json.get("isAppend").getAsBoolean(); String path = json.get("path").getAsString(); @@ -1632,7 +1645,7 @@ public class FileActions { json.addProperty("distributeID", reqID); LOGGER.debug("[FileActions] distributeContract : "); LOGGER.debug(JsonUtil.toJson(json)); - ControllerManager.getNodeCenterController().distributeContract(reqID,resultCallback,json); + ControllerManager.getNodeCenterController().distributeContract(reqID, resultCallback, json); } static class ListProjectResp { diff --git a/src/main/java/org/bdware/server/action/UserManagerAction.java b/src/main/java/org/bdware/server/action/UserManagerAction.java index 719b8fa..ee4c26e 100644 --- a/src/main/java/org/bdware/server/action/UserManagerAction.java +++ b/src/main/java/org/bdware/server/action/UserManagerAction.java @@ -47,7 +47,8 @@ public class UserManagerAction { @Action(userPermission = 0) public void login(JsonObject json, ResultCallback resultCallback) { if (sessionID == null) { - resultCallback.onResult("{\"action\":\"onLogin\",\"data\":\"failed\"}"); + resultCallback.onResult("{\"action\":\"onLogin\",\"status\":\"failed, no session\"," + + "\"data\":\"" + Role.Anonymous.name() + "\"}"); } LOGGER.debug("[NodeManagerAction] session:" + (sessionID)); String pubKey = json.get("pubKey").getAsString(); @@ -64,7 +65,9 @@ public class UserManagerAction { } else { handler.setPermission(0); resultCallback.onResult( - "{\"action\":\"onLogin\",\"data\":\"" + Role.Anonymous.name() + "\"}"); + "{\"action\":\"onLogin\",\"status\":\"verify sign failed\"," + + "\"data\":\"" + Role.Anonymous.name() + "\"}"); + } } @@ -163,7 +166,7 @@ public class UserManagerAction { Map ret = new HashMap<>(); ret.put("kv", kv); ret.put("time", time); - ReplyUtil.simpleReply(resultCallback,"onListUnAuthRole",ret); + ReplyUtil.simpleReply(resultCallback, "onListUnAuthRole", ret); } @Action(userPermission = 1 << 11) @@ -173,7 +176,7 @@ public class UserManagerAction { Map ret = new HashMap<>(); ret.put("kv", kv); ret.put("time", time); - ReplyUtil.simpleReply(resultCallback,"onListAllAuthRole",ret); + ReplyUtil.simpleReply(resultCallback, "onListAllAuthRole", ret); } @Action(userPermission = 1L << 11) @@ -210,7 +213,7 @@ public class UserManagerAction { map.put("ContractProvider", cp); map.put("ContractInstanceManager", cm); map.put("ContractUser", cp); - ReplyUtil.simpleReply(resultCallback,"onCountRole",map); + ReplyUtil.simpleReply(resultCallback, "onCountRole", map); } @Action(userPermission = 1 << 10) diff --git a/src/main/java/org/bdware/server/executor/consistency/PBFTExecutor.java b/src/main/java/org/bdware/server/executor/consistency/PBFTExecutor.java index 0833b37..b8ac817 100644 --- a/src/main/java/org/bdware/server/executor/consistency/PBFTExecutor.java +++ b/src/main/java/org/bdware/server/executor/consistency/PBFTExecutor.java @@ -11,7 +11,11 @@ import org.bdware.sc.bean.ContractRequest; import org.bdware.sc.conn.Node; import org.bdware.sc.conn.OnHashCallback; import org.bdware.sc.conn.ResultCallback; -import org.bdware.sc.sequencing.*; +import org.bdware.sc.consistency.Committer; +import org.bdware.sc.consistency.pbft.PBFTAlgorithm; +import org.bdware.sc.consistency.pbft.PBFTMember; +import org.bdware.sc.consistency.pbft.PBFTMessage; +import org.bdware.sc.consistency.pbft.PBFTType; import org.bdware.sc.units.*; import org.bdware.sc.util.JsonUtil; import org.bdware.server.GlobalConf; diff --git a/src/main/java/org/bdware/units/consensus/ConsensusAlgorithm.java b/src/main/java/org/bdware/units/consensus/ConsensusAlgorithm.java index 9feef18..2f10c57 100644 --- a/src/main/java/org/bdware/units/consensus/ConsensusAlgorithm.java +++ b/src/main/java/org/bdware/units/consensus/ConsensusAlgorithm.java @@ -1,7 +1,7 @@ package org.bdware.units.consensus; import org.bdware.sc.conn.Node; -import org.bdware.sc.sequencing.Committer; +import org.bdware.sc.consistency.Committer; import org.bdware.sc.units.TrustfulExecutorConnection; public interface ConsensusAlgorithm { diff --git a/src/main/java/org/bdware/units/consensus/PBFTCenter.java b/src/main/java/org/bdware/units/consensus/PBFTCenter.java index 080017f..9e355c7 100644 --- a/src/main/java/org/bdware/units/consensus/PBFTCenter.java +++ b/src/main/java/org/bdware/units/consensus/PBFTCenter.java @@ -1,6 +1,6 @@ package org.bdware.units.consensus; -import org.bdware.sc.sequencing.PBFTType; +import org.bdware.sc.consistency.pbft.PBFTType; import org.bdware.sc.util.JsonUtil; import org.bdware.server.GlobalConf; import org.bdware.units.beans.MultiPointContractInfo; diff --git a/src/main/java/org/bdware/units/consensus/SingleCenter.java b/src/main/java/org/bdware/units/consensus/SingleCenter.java index 3ab6631..f1b288e 100644 --- a/src/main/java/org/bdware/units/consensus/SingleCenter.java +++ b/src/main/java/org/bdware/units/consensus/SingleCenter.java @@ -1,6 +1,6 @@ package org.bdware.units.consensus; -import org.bdware.sc.sequencing.PBFTType; +import org.bdware.sc.consistency.pbft.PBFTType; import org.bdware.sc.util.JsonUtil; import org.bdware.server.GlobalConf; import org.bdware.units.beans.MultiPointContractInfo;