intial commit

This commit is contained in:
CaiHQ 2022-04-19 09:26:59 +08:00
parent a536e8e11f
commit c29538179f
15 changed files with 2011 additions and 48 deletions

View File

@ -1,6 +1,6 @@
buildscript {
dependencies {
classpath files("buildlibs/simpleypkpacker.jar")
classpath files("buildlibs/simple-ypk-packer-0.1.0.jar")
}
}
@ -36,8 +36,11 @@ sourceSets {
dependencies {
api 'org.apache.logging.log4j:log4j-core:2.14.1'
api 'org.apache.logging.log4j:log4j-api:2.14.1'
api 'com.google.code.gson:gson:2.8.8'
implementation fileTree(dir: 'cplibs', include: '*.jar')
implementation fileTree(dir: 'cplibs/lib/', include: '*.jar')
implementation 'org.bdware.doip:doip-audit-tool:0.9.0'
testImplementation 'junit:junit:4.13.2'
}
@ -59,15 +62,7 @@ task copyAssets(type: Copy) {
from "../front"
into "./build/output/assets/"
}
task mergeJar(dependsOn: ["sourcesJar", "jar"]) {
doLast {
org.bdware.datanet.YPKPacker.mergeJar("./backend/build/libs/$project.name-${project.version}.jar",
"./backend/build/libs/$project.name-${project.version}-sources.jar",
"./backend/build/libs/$project.name-${project.version}-all.jar")
}
}
task copyJar(type: Copy, dependsOn: ["mergeJar", ":backend:copyLibs"]) {
task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) {
from "./build/libs/$project.name-${project.version}-all.jar"
into "./build/output"
rename { String fileName -> "sc-example.jar" }
@ -79,12 +74,12 @@ task copyJar(type: Copy, dependsOn: ["mergeJar", ":backend:copyLibs"]) {
task buildZip(type: Zip, dependsOn: ["copyAssets", "copyJar", "copyYJS"]) {
from './build/output/'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName = 'contractexample.zip'
archiveFileName = 'ControlProxy.zip'
destinationDirectory = file('build/')
}
task buildYPK(dependsOn: ["buildZip"]) {
doLast {
org.bdware.datanet.YPKPacker.staticPack("./backend/build/contractexample.zip", "./backend/build/contractexample.ypk")
org.bdware.datanet.YPKPacker.staticPack("./backend/build/ControlProxy.zip", "./backend/build/ControlProxy-${project.version}.ypk")
}
}

View File

@ -1,26 +0,0 @@
package org.bdware.sc.contractexample;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.sc.ContractProcess;
import org.bdware.sc.boundry.JavaScriptEntry;
public class Hello {
private static final Logger LOGGER = LogManager.getLogger(Hello.class);
public static void main(String[] args) {
LOGGER.info("abc");
}
public static String call() {
return "hello..dafdskf";
}
public static String callYJSInSameCP() {
return ContractProcess.instance.executeContract("{\"action\":\"getOwner\"\",\"arg\":\"\"}");
}
public static Object callYJSInOtherCP() {
return JavaScriptEntry.executeContract("cid", "action", "arg");
}
}

View File

@ -0,0 +1,74 @@
package org.bdware.sc.controlproxy.Hello;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.audit.client.AuditDoipClient;
import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.audit.config.TempConfigStorage;
import org.bdware.doip.audit.writer.AuditConfig;
import org.bdware.doip.audit.writer.AuditType;
import org.bdware.doip.auditrepo.AutoAuditDO;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.ClientConfig;
import org.bdware.irp.exception.IrpClientException;
import org.bdware.irp.stateinfo.StateInfoBase;
import org.bdware.sc.engine.JSONTool;
public class Hello {
private static final Logger LOGGER = LogManager.getLogger(Hello.class);
public static void main(String[] args) {
LOGGER.info("abc");
}
static EndpointConfig endpointConfig;
public static void init(Object obj) {
String defaultConfg= "{\"routerURI\":\"127.0.0.1:2041\"}";
if (obj==null){
return;
}
if (obj instanceof String) {
if (!((String) obj).startsWith("{")){
}
TempConfigStorage storage = new TempConfigStorage((String) obj);
endpointConfig = storage.loadAsEndpointConfig();
} else {
JsonElement je = JSONTool.convertMirrorToJson(obj);
TempConfigStorage storage = new TempConfigStorage(je.toString());
endpointConfig = storage.loadAsEndpointConfig();
}
}
public static String getConfig() {
return new Gson().toJson(endpointConfig);
}
public static String call() {
return "hello..dafdskf";
}
public static String getAuditType(String doid) {
AuditIrpClient irpClient = new AuditIrpClient(endpointConfig);
AuditConfig auditConfig = irpClient.getAuditConfig();
AuditDoipClient client = new AuditDoipClient(auditConfig);
ClientConfig config = null;
try {
StateInfoBase result = irpClient.resolve(doid);
config = new ClientConfig(result.getValues("address"));
} catch (IrpClientException e) {
e.printStackTrace();
}
client.connect(config);
DoipMessage msg = client.sendMessageSync(AutoAuditDO.getRepoAuditType(doid));
AuditType type = AutoAuditDO.getAuditTypeFromRespMessage(msg);
LOGGER.info(type);
return type.toString();
}
}

140
backend/yjs/ControlProxy.yjs Executable file
View File

@ -0,0 +1,140 @@
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;
}
export 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.controlyproxy.Hello.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<arg.length;i++){
ret.push(deleteRepo(arg[i]));
}
return ret;
}
//网关的接口
@Descripton("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
export function updateRepo(arg){
arg = convertArgToJson(arg);
if (arg.doId!=null){
executeContract("Gateway","addLocalRepo",arg);
return {
"msg":"success","code":0};
}
return {
"msg":"missing arguments","code":1};
}
//总体拓扑图
//@范博
export function getAllTopology(){
var nodeList = [];
nodeList.push({
"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}
);
nodeList.push({
"name":"太原内部共享网关","doId":"bdware.ss/Gateway1","previousNode":["bdware/Gateway1", "bdware/Gateway2"]}
);
nodeList.push({
"name":"太原对外开放网关","doId":"bdware.ss/Gateway2", "previousNode":["bdware/Gateway1"]}
);
nodeList.push({
"name":"山西内部共享网关","doId":"bdware/Gateway1"}
);
nodeList.push({
"name":"山西内部共享网关2","doId":"bdware/Gateway2"}
);
return nodeList;
}
}

1048
backend/yjs/ControlProxy接口.md Executable file

File diff suppressed because it is too large Load Diff

49
backend/yjs/DAC.yjs Executable file
View File

@ -0,0 +1,49 @@
module NaiveDAC{
function initDAC(req){
// Global.acceptList = {
// };
// Global.applyList = {
// };
Global.owner = req;
}
function checkPermission(req){
return (req==Global.owner);
}
// export function hasPermission(arg){
// return (Global.acceptList[requester]!=undefined);
// }
// export function accept(req){
// if (requester==Global.owner){
// Global.acceptList[req] = Global.applyList[req];
// if (Global.applyList[req] != undefined)
// Global.applyList[req] = undefined;
// return true;
// }
// return false;
// }
// export function cancel(req){
// if (requester==Global.owner){
// Global.applyList[req] = Global.acceptList[req];
// if (Global.acceptList[req] != undefined)
// Global.acceptList[req] = undefined;
// return true;
// }
// return false;
// }
// export function apply(remark){
// if (remark != undefined && requester !=undefined){
// Global.applyList[requester] = remark;
// return "success";
// }
// return "failed"
// }
// export function isOwner(arg){
// return Global.owner==requester;
// }
// export function getApplyList(arg){
// return JSON.stringify(Global.applyList);
// }
// export function getAcceptList(arg){
// return JSON.stringify(Global.acceptList);
// }
}

86
backend/yjs/README.md Executable file
View File

@ -0,0 +1,86 @@
# 函数名addRepo
## 参数
可接收JSON或是JSON字符串格式如下
```
{"doId":"bdware.ss/Repox"}
```
## 返回结果
code为0表示成功为1表示失败。msg为失败原因。
```
{"msg":"success","rrt":"110ms","code":0}
```
# 函数名pingRepo
## 参数
可接收JSON或是JSON字符串格式如下
```
{"doId":"bdware.ss/Repox"}
```
## 返回结果
code为0表示成功为1表示失败。msg为失败原因。
成功的时候会返回rrt表示ping所花的时间。
```
{"msg":"success","rrt":"110ms","code":0}
```
# 函数名getRepoList
## 参数
```
无参数
```
## 返回结果
```
[
{
"doId":"bdware.ss/Repo13",
"address":"tcp://127.0.0.1:20513",
"owner":"user13",
"version":"2.1",
"descritpion":"这是bdware.ss的第13号数字对象仓库",
"createDate":"2022-01-03"
},
{
"doId":"bdware.ss/Repo14",
"address":"tcp://127.0.0.1:20514",
"owner":"user14",
"version":"2.1",
"descritpion":"这是bdware.ss的第14号数字对象仓库",
"createDate":"2022-01-03"
}]
```
# 函数名deleteRepo
## 参数
```
{"doId":"bdware.ss/Repox"}
```
## 返回结果
```
{"msg":"success","code":0}
```
# 函数名deleteRepoList
## 参数
```
[{"doId":"bdware.ss/Repox"},{"doId":"bdware.ss/Repoy"}]
```
## 返回结果
```
{"msg":"success","code":0}
```
# 函数名updateRepo
## 参数
```
{
"doId":"bdware.ss/Repo14",
"address":"tcp://127.0.0.1:20514",
"owner":"user14",
"version":"2.1",
"descritpion":"这是bdware.ss的第14号数字对象仓库",
}
```
## 返回结果
```
{"msg":"success","code":0}
```

BIN
backend/yjs/assets/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

13
backend/yjs/audit.yjs Executable file
View File

@ -0,0 +1,13 @@
module Audit{
export function getDoipAction(){
return [
{ value: 2048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 380, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 100, name: 'Video Ads' },
]
}
}

12
backend/yjs/manifest.json Normal file → Executable file
View File

@ -1,9 +1,9 @@
{
"main": "main.yjs",
"memory": "kill,init",
"doi": "Contract_1172400934",
"main": "ControlProxy.yjs",
"doi": "Contract_245931211",
"insnLimit": 0,
"buildTime": 1635385270646,
"builder": "ContractEngine",
"startAtUnpack": true
"buildTime": 1650245588814,
"builder": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926",
"startAtUnpack": true,
"sourcePath": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926/ControlProxy"
}

307
backend/yjs/networking.yjs Executable file
View File

@ -0,0 +1,307 @@
//@范博
//以下接口都要给出示例参数
//类似于 @Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
module networking{
//前缀管理用到的接口 listLRS updateLRS createLRS deleteLRS
export function getRouterInfo(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"getRouterInfo",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
export function listLRS(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"listLRS","");
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"路由器\",\"oldDoId\": \"bdwaretest.loccall.next0\",\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!date": "number","!oldName": "string","!oldDoId": "string","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function updateLRS(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"updateLRS",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!date": "number","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function createLRS(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"createLRS",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!name": "string","!doId": "string","!pubKey": "string"})
export function deleteLRS(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"deleteLRS",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
//后缀管理用到的接口
export function listReposi(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"listRepo","");
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"Repo0\",\"oldDoId\": \"bdwaretest.loccall/Repo0\",\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!date": "number","!oldName": "string","!oldDoId": "string","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function updateReposi(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"updateRepo",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!date": "number","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function createReposi(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"createRepo",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!name": "string","!doId": "string","!pubKey": "string"})
export function deleteReposi(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"deleteRepo",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({"!date": "number","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function setRootRouterInfo(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
//if (Global.router == "Router") {
// return "failed";
//}
var ret=executeContract(Global.router,"setRootRouterInfo",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
//return "success";
}
export function reInit(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
if (Global.router == "GlobalRouter") {
return "failed";
}
var ret=executeContract(Global.router,"reInit","");
var obj = ret.result;
if (obj.result=="verify and start server success" || obj.result == undefined) {
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.result,"code":1});
}
return obj;
}
@ArgSchema({"!pubKey": "string"})
export function setPubKey(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"setPubKey",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@ArgSchema({"!upperIP": "string"})
export function setUpperIP(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"setUpperIP",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@ArgSchema({"!upperPort": "string"})
export function setUpperPort(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"setUpperPort",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
export function getUpperIP(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"getUpperIP","");
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
export function getUpperPort(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"getUpperPort","");
return ret.result;
}
@ArgSchema({"!signature": "string"})
export function setSignature(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"setSignature",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@ArgSchema({"!name": "string"})
export function setName(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
}
var ret=executeContract(Global.router,"setName",arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
@ArgSchema({"!doId": "string","!address":"string"})
export function resolveDoId(arg){
var ret=executeContract(Global.router,"resolveDoId",arg);
var obj = ret.result;
var obj1 = obj.data;
var obj2 = JSON.parse(obj1);
if (obj.result=="success" || obj.result == undefined) {
if (obj2.name != "NotFound") {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
return obj;
}
}

135
backend/yjs/repodetail.yjs Executable file
View File

@ -0,0 +1,135 @@
module RepoDetail{
export function getControlProxyConfig(){
return org.bdware.sc.controlyproxy.Hello.getConfig();
}
//@wyq 通过DOIP请求
export function getAuditRule(arg){
// {"repoId":"xxx"}
var ret = [];
ret.push({"displayName":"原始数据存证","desc":"原始数据存证到指定数据库,哈希数据存证","type":2});
ret.push({"displayName":"哈希数据存证","desc":"仅哈希数据存证","type":1});
ret.push({"displayName":"不存证","desc":"不存证","type":0 });
return ret;
}
//@wyq TODO TODO
// 这个通过DOIPUtil去调用
// DOIP的接口。
export function getDoAuditRule(arg){
//repo的doId
//arg={"doId":"xxx","offset":xx,"count":xx}
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
var ret = {"data":[{"doId":"abc.124/Repo","auditRule":{"type":0}},
{"doId":"abc.125/Repo","auditRule":{"type":1}},
{"doId":"abc.128/Repo","auditRule":{"type":1}}],
total:3};
return ret;
//abc.124/Repo/67899-6789789dafd-8909
}
//@wyq
export function setDoAuditRule(arg){
///arg={"doIdList":["dd","ddd.xx/xxx",...],"type":1}
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
return {"msg":"success","code":0};
}
//宏伟
//如果有指定repo那就是指定repo的DOlist。
//如果没指定repo那就是全部的。
//这是search engine的接口为什么还没接上
//TODO TODO
export function getDoList(arg){
arg = convertArgToJson(arg);
//if (arg.doId == null)
// return {
// "msg":"missing arguments doId", "code":1, params: arg
// };
//if (arg.count>1000)
// return {
// "msg":"request to much!", "code":1
// };
var ret = [];
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
for (var i=arg.offset; i<arg.offset/1.0+arg.count/1.0;i++){
var fakeDo = {
};
fakeDo.doId="bdware.ss/Repo1/abc"+i;
fakeDo.originalData={doid:fakeDo.doId,info:"ddddd", tag: ["aaa", "bbb", "ccc"]}
fakeDo.enableIndex = true
ret.push(fakeDo);
}
return {data: ret, total: 100};
}
//
export function getRepoTopology(arg){
arg = convertArgToJson(arg);
if (arg.doId == null)
return {
"msg":"missing arguments doId", "code":1};
var nodeList = [];
nodeList.push({
"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}
);
nodeList.push({
"name":"太原内部共享网关","doId":"bdware.ss/Gateway1","previousNode":["bdware/Gateway1", "bdware/Gateway2"]}
);
nodeList.push({
"name":"太原对外开放网关","doId":"bdware.ss/Gateway2", "previousNode":["bdware/Gateway1"]}
);
nodeList.push({
"name":"山西内部共享网关","doId":"bdware/Gateway1"}
);
nodeList.push({
"name":"山西内部共享网关2","doId":"bdware/Gateway2"}
);
return nodeList;
}
//指标1 获取某个repo的DO数量。
//使用search.yjs里的getDoCount
//指标2 获取某个repo的操作次数。使用search.yjs中的
//countRecordByDate
//参数格式为:
//{"repoId":"xxx.xxx/xxx","startTime":1641454745128, "endTime":1641454746128,"interval":5000, "eventPrefix":["abc"]}"
//比如查询总搜索次数参数格式为eventPrefix:["doip_search"]
//查询调用统计参数格式为eventPrefix:[""]然后interval/startTime/fromTime传对了就行。
//索引统计,暂时还没有。
export function getStaticIndex(arg){
arg = convertArgToJson(arg);
if (arg.from==undefined)
return {
"msg":"missing arguments: from", "code":1};
if (arg.to==undefined)
return {
"msg":"missing arguments: to", "code":1};
if (arg.interval==undefined)
return {
"msg":"missing arguments: interval", "code":1};
switch(arg.tag){
case "search":
case "index":
case "call":
return fakeList(from, to, interval);
}
return {
"msg":"unreconized tag", "code":1};
}
function fakeList(from, to, interval){
var ret =[];
for (i=from;i<to;i++){
ret.push(Math.floor(Math.random()*200+20));
}
return ret;
}
}

140
backend/yjs/search.yjs Executable file
View File

@ -0,0 +1,140 @@
//@张宏伟
module SearchModule{
//获取DO的数量 该接口可以用于主页的DO数量
//也可用于全领监管->总体情况概览 里面的“仓库数量”“DO数量” “DO分布情况”三项。
//可以增加一个参数用于过滤返回结果?比如模糊匹配上的就加到返回列表里。
//str.contains(arg..)
//输入参数doId如bdware.txte/Repo
//返回结果一个数组里面是doId"contains"这个参数的列表。
export function getAllRepoCount() {
return executeContract("SearchEngine","getAllRepoCount",arg).result;
//return Global.allRepoCount;
}
export function getAllUserCount() {
return executeContract("SearchEngine","getAllUserCount",arg).result;
//return Global.allRepoCount;
}
export function getAllSearchCount() {
return executeContract("SearchEngine","getAllSearchCount",arg).result;
//return Global.allRepoCount;
}
export function getAllUpdateCount() {
return executeContract("SearchEngine","getAllUpdateCount",arg).result;
//return Global.allRepoCount;
}
export function getAllDoCount() {
return executeContract("SearchEngine","getAllDoCount",arg).result;
//return Global.allRepoCount;
}
//不确定
//{"open":51,"close":49}
export function getAllIndexCount() {
return executeContract("SearchEngine","getAllIndexCount",arg).result;
//return Global.allRepoCount;
}
export function getDoCount(arg){
return executeContract("SearchEngine","getDoCount",arg);
//return {
//"data":[{
// "doId":"bdware.txte/Repo1","count":10}
// ,{
// "doId":"bdware.txte/Repo2","count":12}
// ]};
}
//通过AuditProxy实现 @董瑞 需实现支持多标签索引的put接口。
//======在全领监管->总体情况概览
//使用以下参数获取DO数量变化趋势
// interval=1周/1月/1年。。 eventPrefix的数组里为"irp_register"
//使用以下参数获取操作数量统计
// interavl= endTime-startTime eventPrefix的数组里为""
// 使用以下参数数字对象操作统计
//eventPrefix为["doip","irp"] 已完成√
// 使用以下参数获取doip操作统计
//exentPrefix为["doip_create","doip_update","doip_delete","doip_retrieve","doip_hello","doip_list_operations","doip_search"] 已完成√
// 使用以下参数获取irp操作统计
//exentPrefix为["irp_create","irp_delete","irp_update","irp_batch_create","irp_resolution"] 已完成√
// 使用以下参数获取doip、irp的成功率
//exentPrefix为["irp_op_success","irp_op_failed"]
//exentPrefix为["doip_op_success","doip_op_failed"]
//======在全领监管->总体情况概览
@Description("{\"doId\":\"86.20.100/repo4/bcrs\",\"startTime\":1644390000000, \"endTime\":1644404400000,\"interval\":3600000, \"eventPrefix\":[\"doip_retrieve\", \"doip_update\", \"doip_search\", \"doip_delete\"]}")
export function countRecordByDate(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","countRecordByDate",arg).result;
}
export function testCount(arg){
return {"data":"key"};
}
//=====全域监管:数字对象溯源 针对单个DO的通过SQL查询来实现。
//根据 doId --> 找到“数字对象世系”
//86.500.1/Repo.1/Doab
//根据 doId+时间范围+interval+protocol --> 不同operation的统计数据 AuditProxy)
//countDORecordByDate()
//{"doId":xxxx,"startTime","endTime","interval","eventPrefix":["doip_create","doip_update"]}
//{"eventxxx":[1,2,3],"event2":[1,2,3]}
//根据 doId +查找条件(时间范围 protocol operation user?) +offset/count -->总数+指定条数的数组AuditProxy)
// queryDoRecordByDate
//{"doId":xxxx,"startTime","endTime","eventPrefix":["doip_create","doip_update"]}
//{"count":xx, "data":[{doip_request的某一行。},]}
// queryDoRecordByOffset
//{"doId":xxxx,"offset","count","eventPrefix":["doip_create","doip_update"]}
//{"total":xx,"count":xx, "data":[{doip_request的某一行。},]}
//==============
//DO的元数据
//{
// "date": "...",
// "owner": "...",
// "type": "...",
// "description": "...",
// "schema": "...",
//}
//做成可以根据创建时间范围;标识模糊
//{"type":"creatTime","count":10,"offset":"0","from":"1141363811328","to":"1941363811328"}
export function getDoFilter(arg){
var res=executeContract("SearchEngine","searchByRange",arg);
return res.result;
}
//支持模糊查询、按创建时间查询。
//输入参数:
//type要查询的字段
//keyword:要查询的关键字
//count可选项缺省为20
//offset可选项缺省为0
////{"params":[{"type":"owner","keyword":"说明"},{"type":"doid","keyword":"aibd"}],"count":"10","offset":"0"}
//返回:{"data":[{},{},{}],"count":3}
@ArgSchema({"!params":[{"!type":"string","!keyword":"integer"}],"count":"integer","offset":"integer"})
export function search(arg){
arg = convertArgToJson(arg);
var res=executeContract("SearchEngine","searchByMultiTag",arg);
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};
}
export function queryByHash(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","queryByHash",arg.hash).result;
}
export function queryByHashOriginal(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","queryByHashOriginal",arg.hash).result;
}
}

View File

@ -2,8 +2,8 @@ plugins {
id 'java'
id 'idea'
}
def currVersion = "1.0.0"
ext.projectIds = ['group': 'org.bdware.sc.contractexample', 'version': currVersion]
def currVersion = "0.8.2"
ext.projectIds = ['group': 'org.bdware.sc.controlproxy', 'version': currVersion]
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:none'
@ -12,11 +12,13 @@ tasks.withType(JavaCompile) {
repositories {
mavenCentral()
}
project(':backend') {
group = "org.bdware.sc.example"
group = "org.bdware.sc.controlproxy"
version = projectIds.version
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
mavenLocal()
}
}

View File

@ -1,2 +1,2 @@
rootProject.name = 'ContractJavaExample'
rootProject.name = 'ControlProxy'
include 'backend'