import "DAC.yjs"; import "union.yjs"; import "ShanxiAuditPRoxy.yjs"; import "ShanxiDataRepo.yjs"; import "ShanxiGlobalRouter.yjs"; import "ShanxiRegistry.yjs"; //网关为Gateway //路由器改名为Resolver,中文名为标识解析系统 //搜索引擎改名为为Registry,中文名为注册表系统 //本文接口由李智负责对接。 contract ShanxiControlProxy { function convertArgToJson(arg) { if (typeof(arg)=='string' && !arg.startsWith("{")) return arg; if (typeof(arg)=='string') return JSON.parse(arg); return arg; } function onCreate(arg) { if (arg==null|| typeof(arg)=='string'){ arg = { "prefix":"test.ab.cd", "router":"GlobalRouter" }; } arg = convertArgToJson(arg); Global.router = "GlobalRouter"; Global.prefix = arg.prefix; Global.router = arg.router; initDAC(requester); org.bdware.sc.controlproxy.RepoProxy.init(arg); } function isString(arg) { return typeof(arg)=='string'; } export function getControlProxyConfig() { return org.bdware.sc.controlproxy.RepoProxy.getConfig(); } export function isOwner() { return checkPermission(requester); } @Description("参数为,{\"doId\":\"bdware.ss/Repox\"}") export function addRepo(arg) { arg = convertArgToJson(arg); if (arg.doId ==undefined ){ return { "msg":"missing arguments repoId ", "code":1 }; } executeContract("Gateway", "addLocalRepo", arg); return { "msg":"success", "rrt":"110ms", "code":0 }; } //网关需新增的接口 //@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}") //export function pingRepo(arg) { //arg = convertArgToJson(arg); //if (arg.doId ==undefined ){ // return { // "msg":"missing arguments repoId ", "code":1 // }; //} // var ret = executeContract("Gateway", "pingRepo", arg.doId); // ret = ret.result; // if (ret.rrt > 0) // return { // "msg":"success", "rrt":ret.rrt, "code":0, "repoInfo":JSON.parse(ret.repoInfo) // }; else return { // "msg":"repo is unconnected", "code":1 // }; //return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId); //} @Description("shanxi/TestLocal shanxi/Repository") export function testPingRepo(arg) { return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg); } @Description("shanxi/TestLocal shanxi/Repository") export function testRepoStatistics(arg) { return org.bdware.sc.controlproxy.RepoProxy.getRepoStatistics(arg); } //网关的接口 //@Description("无参数") //export function getRepoList(arg) { //use configed arg.routerId; // ret = executeContract(Global.router, "listRepo", ""); //ret=executeContract("Gateway","listLocalRepo",""); //var list = ret.result // return ret.result; //} //网关的接口 @Description("参数为 {\"doId\":\"bdware.ss/Repox\"}") export function deleteRepo(arg) { arg = convertArgToJson(arg); if (arg.doId != null && arg.doId.indexOf(Global.prefix) != -1){ executeContract("Gateway", "deleteLocalRepo", arg.doId); return { "status":"success", "code":0 }; } return { "msg":"can not found repo", "code":1 }; } //网关的接口 需新增 //@Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]") //export function deleteRepoList(arg) { // arg = convertArgToJson(arg); // var ret = []; // for (var i = 0; // i