import "repodetail.yjs"; import "search.yjs"; import "audit.yjs"; import "networking.yjs"; import "DAC.yjs"; import "union.yjs"; //网关为Gateway //路由器改名为Resolver,中文名为标识解析系统 //搜索引擎改名为为Registry,中文名为注册表系统 //本文接口由李智负责对接。 contract ControlProxy { function convertArgToJson(arg) { if (typeof(arg) == 'string' && ! arg.startsWith("{") && !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; if (arg.reqPublicKey != undefined) YancloudUtil.setSM2KeyPair(arg.reqPublicKey, arg.reqPrivateKey); 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) { return executeContract("ShanxiControlProxy", "pingRepo", arg).result; // 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 for (var i=0;i