import "repodetail.yjs" import "search.yjs" import "audit.yjs" import "networking.yjs" import "DAC.yjs" //网关为Gateway //路由器改名为Resolver,中文名为标识解析系统 //搜索引擎改名为为Registry,中文名为注册表系统 //本文接口由李智负责对接。 contract ControlProxy{ 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 isOwner(){ return checkPermission(requester); } @Descripton("参数为,{\"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}; } //网关需新增的接口 @Descripton("参数为,{\"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}; } //网关的接口 export function getCCCCCCCCCCCCConfInfo(){ return Global; } @Descripton("无参数") export function getRepoList(arg){ //use configed arg.routerId; //TODO!! ret = executeContract(Global.router,"listRepo",""); //ret=executeContract("Gateway","listLocalRepo",""); //var list = ret.result return ret.result; } //网关的接口 @Descripton("参数为 {\"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}; } //网关的接口 需新增 @Descripton("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]") export function deleteRepoList(arg){ arg = convertArgToJson(arg); var ret = []; for (var i=0;i