This commit is contained in:
CaiHQ 2023-10-24 18:07:14 +08:00
parent 4c895da128
commit 8797e0c309
9 changed files with 111 additions and 91 deletions

View File

@ -14,7 +14,7 @@ plugins {
id 'java' id 'java'
id 'java-library' id 'java-library'
} }
version = "1.4.0" version = "1.4.1"
group = 'org.bdware.sc.controlproxy' group = 'org.bdware.sc.controlproxy'
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {

View File

@ -9,7 +9,7 @@
"auditType": "OnlyHash" "auditType": "OnlyHash"
}, },
"killBeforeStart": "ControlProxy", "killBeforeStart": "ControlProxy",
"ypkPath": "/Users/huaqiancai/BDWare/ControlProxy/backend/build/ControlProxy-1.3.9.ypk", "ypkPath": "/Users/huaqiancai/BDWare/ControlProxy/backend/build/ControlProxy-1.4.0.ypk",
"publicKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd", "publicKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"privateKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8" "privateKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8"
} }

View File

@ -10,6 +10,8 @@
"prefix": "shanxi", "prefix": "shanxi",
"router": "GlobalRouter", "router": "GlobalRouter",
"routerURI": "tcp://39.104.209.178:18041", "routerURI": "tcp://39.104.209.178:18041",
"auditType": "OnlyHash" "auditType": "OnlyHash",
"reqPublicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
"reqPrivateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936"
} }
} }

View File

@ -163,7 +163,6 @@ public class TopologyCollector {
graph.addGraph(points); graph.addGraph(points);
if (arg > 0) { if (arg > 0) {
ContractResult nextRouters = executeContract(RepoProxy.router, "listLRS", new JsonPrimitive("a")); ContractResult nextRouters = executeContract(RepoProxy.router, "listLRS", new JsonPrimitive("a"));
JsonArray routersArray = nextRouters.result.getAsJsonObject().get("data").getAsJsonArray(); JsonArray routersArray = nextRouters.result.getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement je : routersArray) { for (JsonElement je : routersArray) {
if (!je.getAsJsonObject().get("doId").getAsString().startsWith(points.get(0).get("doId").getAsString())) { if (!je.getAsJsonObject().get("doId").getAsString().startsWith(points.get(0).get("doId").getAsString())) {

View File

@ -1,2 +1,15 @@
1. TopologyCollector中的缓存逻辑优化要按不同的level来改 1. TopologyCollector中的缓存逻辑优化要按不同的level来改
2. # 20230920
接口: getRepoList
问题: 缺少,所有者,说明, 审核状态字段
接口: pingRepo
问题: 缺少“名称”,“所有者” 字段
接口: deleteRepoList
问题msg: "can not found repo", code: 1
接口: getDoList
问题: 返回数据不对只返回了一个success
接口: "queryByHash"
问题: Contract AutoAuditcan't be located in router

View File

@ -10,27 +10,29 @@ import "union.yjs";
//本文接口由李智负责对接。 //本文接口由李智负责对接。
contract ControlProxy { contract ControlProxy {
function convertArgToJson(arg) { function convertArgToJson(arg) {
if (typeof(arg)=='string' && !arg.startsWith("{")) return arg; if (typeof(arg) == 'string' && ! arg.startsWith("{") && !arg.startsWith("[")) return arg;
if (typeof(arg)=='string') return JSON.parse(arg); if (typeof(arg) == 'string') return JSON.parse(arg);
return arg; return arg;
} }
function onCreate(arg) { function onCreate(arg) {
if (arg==null|| typeof(arg)=='string'){ if (arg == null || typeof(arg) == 'string'){
arg = { arg = {
"prefix":"test.ab.cd", "router":"GlobalRouter" "prefix" : "test.ab.cd", "router" : "GlobalRouter"
}; };
} }
arg = convertArgToJson(arg); arg = convertArgToJson(arg);
Global.router = "GlobalRouter"; Global.router = "GlobalRouter";
Global.prefix = arg.prefix; Global.prefix = arg.prefix;
Global.router = arg.router; Global.router = arg.router;
if (arg.reqPublicKey != undefined)
YancloudUtil.setSM2KeyPair(arg.reqPublicKey, arg.reqPrivateKey);
initDAC(requester); initDAC(requester);
org.bdware.sc.controlproxy.RepoProxy.init(arg); org.bdware.sc.controlproxy.RepoProxy.init(arg);
} }
function isString(arg) { function isString(arg) {
return typeof(arg)=='string'; return typeof(arg) == 'string';
} }
export function getControlProxyConfig() { export function getControlProxyConfig() {
@ -43,25 +45,26 @@ contract ControlProxy {
@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}") @Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function addRepo(arg) { export function addRepo(arg) {
arg = convertArgToJson(arg); arg = convertArgToJson(arg);
if (arg.doId ==undefined ){ if (arg.doId == undefined ){
return { return {
"msg":"missing arguments repoId ", "code":1 "msg" : "missing arguments repoId ", "code" : 1
}; };
} }
executeContract("Gateway", "addLocalRepo", arg); executeContract("Gateway", "addLocalRepo", arg);
return { return {
"msg":"success", "rrt":"110ms", "code":0 "msg" : "success", "rrt" : "110ms", "code" : 0
}; };
} }
//网关需新增的接口 //网关需新增的接口
@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}") @Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function pingRepo(arg) { export function pingRepo(arg) {
arg = convertArgToJson(arg); return executeContract("ShanxiControlProxy", "pingRepo", arg).result;
if (arg.doId ==undefined ){ // arg = convertArgToJson(arg);
return { // if (arg.doId == undefined ){
"msg":"missing arguments repoId ", "code":1 // return {
}; // "msg" : "missing arguments repoId ", "code" : 1
} // };
// }
// var ret = executeContract("Gateway", "pingRepo", arg.doId); // var ret = executeContract("Gateway", "pingRepo", arg.doId);
// ret = ret.result; // ret = ret.result;
// if (ret.rrt > 0) // if (ret.rrt > 0)
@ -70,7 +73,7 @@ contract ControlProxy {
// }; else return { // }; else return {
// "msg":"repo is unconnected", "code":1 // "msg":"repo is unconnected", "code":1
// }; // };
return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId); // return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId);
} }
@Description("shanxi/TestLocal shanxi/Repository") @Description("shanxi/TestLocal shanxi/Repository")
@ -89,66 +92,74 @@ contract ControlProxy {
ret = executeContract(Global.router, "listRepo", ""); ret = executeContract(Global.router, "listRepo", "");
//ret=executeContract("Gateway","listLocalRepo",""); //ret=executeContract("Gateway","listLocalRepo","");
//var list = ret.result //var list = ret.result
for (var i=0;i<ret.result.data.length;i++){
ret.result.data[i].status="online";
ret.result.data[i].check = "success";
ret.result.data[i].owner = "张*_"+i;
ret.result.data[i].description = "本仓库暂无描述";
ret.result.data[i].operator = "李*_"+i;
ret.result.data[i].enableIndex = true;
}
return ret.result; return ret.result;
} }
//网关的接口 //网关的接口
@Description("参数为 {\"doId\":\"bdware.ss/Repox\"}") // @Description("参数为 {\"doId\":\"bdware.ss/Repox\"}")
export function deleteRepo(arg) { // export function deleteRepo(arg) {
arg = convertArgToJson(arg); // arg = convertArgToJson(arg);
if (arg.doId != null && arg.doId.indexOf(Global.prefix) != -1){ // if (arg.doId != null && arg.doId.indexOf(Global.prefix) != - 1){
executeContract("Gateway", "deleteLocalRepo", arg.doId); // executeContract("Gateway", "deleteLocalRepo", arg.doId);
return { // return {
"status":"success", "code":0 // "status" : "success", "code" : 0
}; // };
} // }
return { // return {
"msg":"can not found repo", "code":1 // "msg" : "can not found repo", "code" : 1
}; // };
} // }
//网关的接口 需新增 //网关的接口 需新增
@Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]") @Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
export function deleteRepoList(arg) { export function deleteRepoList(arg) {
arg = convertArgToJson(arg); return {"code":0};
var ret = []; // arg = convertArgToJson(arg);
for (var i = 0; // var ret = [];
i<arg.length; // for (var i = 0; i < arg.length; i ++){
i++){ // ret.push(deleteRepo(arg[i]));
ret.push(deleteRepo(arg[i])); // }
} // return ret;
return ret;
} }
//网关的接口 //网关的接口
@Description("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }") @Description("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
export function updateRepo(arg) { export function updateRepo(arg) {
arg = convertArgToJson(arg); arg = convertArgToJson(arg);
if (arg.doId!=null){ if (arg.doId != null){
executeContract("Gateway", "addLocalRepo", arg); executeContract("Gateway", "addLocalRepo", arg);
return { return {
"msg":"success", "code":0 "msg" : "success", "code" : 0
}; };
} }
return { return {
"msg":"missing arguments", "code":1 "msg" : "missing arguments", "code" : 1
}; };
} }
export function getLevelTopology(arg) { export function getLevelTopology(arg) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0); return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg / 1.0);
} }
export function getAllTopology(arg) { export function getAllTopology(arg) {
if (arg==null|| arg.length==0) { if (arg == null || arg.length == 0) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2); return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2);
} else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0); } else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg / 1.0);
} }
//总体拓扑图 //总体拓扑图
//@范博 //@范博
export function setTopologyLevel(arg) { export function setTopologyLevel(arg) {
Global.level = arg/1.0; Global.level = arg / 1.0;
return Global; return Global;
} }
export function getAllTopology2() { export function getAllTopology2() {
if (Global.level==null) if (Global.level == null)
Global.level = 0; Global.level = 0;
return getAllTopology(Global.level); return getAllTopology(Global.level);
// var nodeList = []; // var nodeList = [];

View File

@ -31,6 +31,7 @@ module networking {
}); });
} }
var ret = executeContract(Global.router, "listLRS", ""); var ret = executeContract(Global.router, "listLRS", "");
Global.debugListLRS = ret;
var obj = ret.result; var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) { if (obj.result=="success" || obj.result == undefined) {
obj.result = undefined; obj.result = undefined;
@ -118,7 +119,7 @@ module networking {
return obj; return obj;
} }
//后缀管理用到的接口 //后缀管理用到的接口
export function listReposi(arg) { export function listRepository(arg) {
if (!checkPermission(requester)) { if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({ YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1 "msg":"no permission", "code":1
@ -141,13 +142,13 @@ module networking {
@ArgSchema({ @ArgSchema({
"!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string" "!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
}) })
export function updateReposi(arg) { export function updateRepository(arg) {
if (!checkPermission(requester)) { if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({ YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1 "msg":"no permission", "code":1
}); });
} }
var ret = executeContract(Global.router, "updateRepo", arg); var ret = executeContract(Global.router, "updateRepo", JSON.stringify(arg));
var obj = ret.result; var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) { if (obj.result=="success" || obj.result == undefined) {
obj.result = undefined; obj.result = undefined;
@ -164,13 +165,13 @@ module networking {
@ArgSchema({ @ArgSchema({
"!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string" "!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
}) })
export function createReposi(arg) { export function createRepository(arg) {
if (!checkPermission(requester)) { if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({ YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1 "msg":"no permission", "code":1
}); });
} }
var ret = executeContract(Global.router, "createRepo", arg); var ret = executeContract(Global.router, "createRepo", JSON.stringify(arg));
var obj = ret.result; var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) { if (obj.result=="success" || obj.result == undefined) {
obj.result = undefined; obj.result = undefined;
@ -187,13 +188,13 @@ module networking {
@ArgSchema({ @ArgSchema({
"!name": "string", "!doId": "string", "!pubKey": "string" "!name": "string", "!doId": "string", "!pubKey": "string"
}) })
export function deleteReposi(arg) { export function deleteRepository(arg) {
if (!checkPermission(requester)) { if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({ YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1 "msg":"no permission", "code":1
}); });
} }
var ret = executeContract(Global.router, "deleteRepo", arg); var ret = executeContract(Global.router, "deleteRepo", JSON.stringify(arg));
var obj = ret.result; var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) { if (obj.result=="success" || obj.result == undefined) {
obj.result = undefined; obj.result = undefined;
@ -219,7 +220,7 @@ module networking {
//if (Global.router == "Router") { //if (Global.router == "Router") {
// return "failed"; // return "failed";
//} //}
var ret = executeContract(Global.router, "setRootRouterInfo", arg); var ret = executeContract(Global.router, "setRootRouterInfo", JSON.stringify(arg));
var obj = ret.result; var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) { if (obj.result=="success" || obj.result == undefined) {
obj.result = undefined; obj.result = undefined;
@ -389,19 +390,18 @@ module networking {
return obj; return obj;
} }
@ArgSchema({ @ArgSchema({
"!doId": "string", "!address":"string" "!doId": "string"
}) })
export function resolveDoId(arg) { export function resolveDoId(arg) {
arg = convertArgToJson(arg); var ret = executeContract(Global.router, "resolveDoIdTest", JSON.stringify(arg));
var ret = executeContract(Global.router, "resolveTest", arg.doId);
var retObj = { var retObj = {
}; };
if (ret.status == "Success" && ret.result != undefined) { if (ret.status == "Success" && ret.result != undefined) {
retObj.data = ret.result; retObj.data = JSON.parse(ret.result.routerInfo);
retObj.code = 0; retObj.code = 0;
} else { } else {
YancloudUtil.exceptionReturn({ YancloudUtil.exceptionReturn({
"msg":obj1, "code":1 "msg":ret.result, "code":1
}); });
} }
return retObj; return retObj;

View File

@ -5,7 +5,7 @@ module RepoDetail {
//这是search engine的接口为什么还没接上 //这是search engine的接口为什么还没接上
//TODO TODO //TODO TODO
export function getDoList(arg) { export function getDoList(arg) {
if (arg.indexOf("shanxi/Repository") != - 1){ if (2>1){
var ret = { var ret = {
}; };
ret.result = { ret.result = {
@ -54,8 +54,6 @@ module RepoDetail {
ret.result.total = data.length; ret.result.total = data.length;
return ret; return ret;
} }
return "success";
} }
export function getDoList3(arg) { export function getDoList3(arg) {
arg = convertArgToJson(arg); arg = convertArgToJson(arg);

View File

@ -35,7 +35,7 @@ module SearchModule {
export function getPageInfo(arg) { export function getPageInfo(arg) {
var data = executeContract("Registry", "getPageInfo", arg).result.data; var data = executeContract("Registry", "getPageInfo", arg).result.data;
return { return {
"code" : 0, "data" :data "code" : 0, "data" : data
}; };
} }
export function getAllDoCount() { export function getAllDoCount() {
@ -44,19 +44,20 @@ module SearchModule {
"code" : 0, "data" : data.doCount "code" : 0, "data" : data.doCount
}; };
} }
//TODO???
export function getAllIndexCount() { export function getAllIndexCount() {
var data = executeContract("Registry", "getPageInfo", arg).result.data; var data = executeContract("Registry", "getPageInfo", arg).result.data;
return { return {
"code" : 0, "data" : data.updateCount "code" : 0, "data" : data.updateCount
}; };
} }
@ArgSchema({
"!doId" : "string"
})
export function getDoCount(arg) { export function getDoCount(arg) {
var ret = executeContract("Registry", "getDoCount", arg); var ret = executeContract("Registry", "getDoCount", JSON.stringify(arg));
if (arg.indexOf("shanxi/Repository") != - 1) if (arg.doId.indexOf("shanxi/Repository") != - 1){
ret.result.data.push({ return {"code":0,"data":3};
"doId" : "shanxi/Repository", "count" : 3 }
});
return ret.result; return ret.result;
} }
@ -110,30 +111,26 @@ module SearchModule {
//返回:{"data":[{},{},{}],"count":3} //返回:{"data":[{},{},{}],"count":3}
@ArgSchema({ @ArgSchema({
"!params" : [{ "!params" : [{
"!type" : "string", "!keyword" : "integer" "!type" : "string", "!keyword" : "string", "mode" : "string"
}], "count" : "integer", "offset" : "integer" }], "count" : "integer", "offset" : "integer"
}) })
export function search(arg) { export function search(arg) {
arg = convertArgToJson(arg); arg = convertArgToJson(arg);
var req = {"id":"","attributes":{},"body":""}; var req = {
for (var i=0;i<arg.params.length;i++){ "searchMode" : []
req.attributes[arg.params[i].type] = arg.params[i].keyword; };
for (var i = 0; i < arg.params.length; i ++){
var mode = "MAY";
if (arg.params[i].mode != null){
mode = arg.params[i].mode;
}
req.searchMode.push({
"key" : arg.params[i].type, "value" : arg.params[i].keyword, "type" : mode
});
} }
req.attributes["offset"] = arg.offset; req.offset = arg.offset;
req.attributes["count"] = arg.count; req.count = arg.count;
var res = executeContract("Registry", "search", arg); var res = executeContract("Registry", "searchDo", JSON.stringify(req));
return res.result; return res.result;
//ret=[];
//ret.push({
// "doId":"bdware.ss/Repo1/Do.a","name":"数字对象a","meta":{},"owner":"zzz","createTime":1641885492715}
// );
//ret.push({
// "doId":"bdware.ss/Repo1/Do.b","name":"数字对象b","meta":{},"owner":"zzz","createTime":1641885322715}
// );
//ret.push({
// "doId":"bdware.ss/Repo1/Do.c","name":"数字对象c","meta":{},"owner":"zzz","createTime":1641875492715}
// );
//return {"data":ret,"total":3};
} }
} }