Merge branch 'dev' into test
commit
7de40e37f5
@ -0,0 +1,11 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.common;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/7/22 15:38
|
||||
* @Modify:
|
||||
**/
|
||||
public class GroovyCommonUtil {
|
||||
}
|
@ -1,147 +1,149 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.common;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/6/17 13:37
|
||||
* @Modify:
|
||||
**/
|
||||
public class HttpUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
||||
|
||||
// trust-https start
|
||||
private static void trustAllHosts(HttpsURLConnection connection) {
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
SSLSocketFactory newFactory = sc.getSocketFactory();
|
||||
|
||||
connection.setSSLSocketFactory(newFactory);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
connection.setHostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[]{};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
}
|
||||
}};
|
||||
// trust-https end
|
||||
|
||||
|
||||
/**
|
||||
* post
|
||||
*
|
||||
* @param url
|
||||
* @param timeout
|
||||
* @param requestObj
|
||||
* @return
|
||||
*/
|
||||
public static ReturnT postBody(String url, int timeout, Object requestObj) {
|
||||
HttpURLConnection connection = null;
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
// connection
|
||||
URL realUrl = new URL(url);
|
||||
connection = (HttpURLConnection) realUrl.openConnection();
|
||||
|
||||
// trust-https
|
||||
boolean useHttps = url.startsWith("https");
|
||||
if (useHttps) {
|
||||
HttpsURLConnection https = (HttpsURLConnection) connection;
|
||||
trustAllHosts(https);
|
||||
}
|
||||
|
||||
// connection setting
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setReadTimeout(timeout * 1000);
|
||||
connection.setConnectTimeout(3 * 1000);
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
|
||||
|
||||
// do connection
|
||||
connection.connect();
|
||||
|
||||
// write requestBody
|
||||
if (requestObj != null) {
|
||||
String requestBody = GsonTool.toJson(requestObj);
|
||||
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream());
|
||||
dataOutputStream.write(requestBody.getBytes("UTF-8"));
|
||||
dataOutputStream.flush();
|
||||
dataOutputStream.close();
|
||||
}
|
||||
|
||||
// valid StatusCode
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) {
|
||||
|
||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "rpc remoting fail, StatusCode(" + statusCode + ") invalid. for url : " + url);
|
||||
}
|
||||
|
||||
// result
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
String resultJson = result.toString();
|
||||
// parse returnT
|
||||
try {
|
||||
return GsonTool.fromJson(resultJson, ReturnT.class);
|
||||
} catch (Exception e) {
|
||||
logger.error("rpc remoting (url=" + url + ") response content invalid(" + resultJson + ").", e);
|
||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "rpc remoting (url=" + url + ") response content invalid(" + resultJson + ").");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "rpc remoting error(" + e.getMessage() + "), for url : " + url);
|
||||
} finally {
|
||||
try {
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
logger.error(e2.getMessage(), e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package cn.estsh.i3plus.pojo.bsp.common;
|
||||
//
|
||||
//import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//import javax.net.ssl.*;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.DataOutputStream;
|
||||
//import java.io.InputStreamReader;
|
||||
//import java.net.HttpURLConnection;
|
||||
//import java.net.URL;
|
||||
//import java.security.cert.CertificateException;
|
||||
//import java.security.cert.X509Certificate;
|
||||
//
|
||||
///**
|
||||
// * @Description :
|
||||
// * @Reference :
|
||||
// * @Author : Castle
|
||||
// * @CreateDate : 2021/6/17 13:37
|
||||
// * @Modify:
|
||||
// **/
|
||||
//public class HttpUtils {
|
||||
// private static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
|
||||
//
|
||||
// // trust-https start
|
||||
// private static void trustAllHosts(HttpsURLConnection connection) {
|
||||
// try {
|
||||
// SSLContext sc = SSLContext.getInstance("TLS");
|
||||
// sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
// SSLSocketFactory newFactory = sc.getSocketFactory();
|
||||
//
|
||||
// connection.setSSLSocketFactory(newFactory);
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
// connection.setHostnameVerifier(new HostnameVerifier() {
|
||||
// @Override
|
||||
// public boolean verify(String hostname, SSLSession session) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private static final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
|
||||
// @Override
|
||||
// public X509Certificate[] getAcceptedIssuers() {
|
||||
// return new X509Certificate[]{};
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
// }
|
||||
// }};
|
||||
// // trust-https end
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * post
|
||||
// *
|
||||
// * @param url
|
||||
// * @param timeout
|
||||
// * @param requestObj
|
||||
// * @return
|
||||
// */
|
||||
// public static ResultBean postBody(String url, int timeout, Object requestObj) {
|
||||
// HttpURLConnection connection = null;
|
||||
// BufferedReader bufferedReader = null;
|
||||
// try {
|
||||
// // connection
|
||||
// URL realUrl = new URL(url);
|
||||
// connection = (HttpURLConnection) realUrl.openConnection();
|
||||
//
|
||||
// // trust-https
|
||||
// boolean useHttps = url.startsWith("https");
|
||||
// if (useHttps) {
|
||||
// HttpsURLConnection https = (HttpsURLConnection) connection;
|
||||
// trustAllHosts(https);
|
||||
// }
|
||||
//
|
||||
// // connection setting
|
||||
// connection.setRequestMethod("POST");
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
// connection.setUseCaches(false);
|
||||
// connection.setReadTimeout(timeout * 1000);
|
||||
// connection.setConnectTimeout(3 * 1000);
|
||||
// connection.setRequestProperty("connection", "Keep-Alive");
|
||||
// connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
// connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
|
||||
//
|
||||
// // do connection
|
||||
// connection.connect();
|
||||
//
|
||||
// // write requestBody
|
||||
// if (requestObj != null) {
|
||||
// String requestBody = GsonTool.toJson(requestObj);
|
||||
//
|
||||
// DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream());
|
||||
// dataOutputStream.write(requestBody.getBytes("UTF-8"));
|
||||
// dataOutputStream.flush();
|
||||
// dataOutputStream.close();
|
||||
// }
|
||||
//
|
||||
// // valid StatusCode
|
||||
// int statusCode = connection.getResponseCode();
|
||||
// if (statusCode != 200) {
|
||||
// return ResultBean.fail("rpc remoting fail, StatusCode(" + statusCode + ") invalid. for url : " + url);
|
||||
//// return new BaseResultBean().errorMsg("rpc remoting fail, StatusCode(" + statusCode + ") invalid. for url : " + url);
|
||||
//// return new ReturnT<String>(ReturnT.FAIL_CODE, "rpc remoting fail, StatusCode(" + statusCode + ") invalid. for url : " + url);
|
||||
// }
|
||||
//
|
||||
// // result
|
||||
// bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// String line;
|
||||
// while ((line = bufferedReader.readLine()) != null) {
|
||||
// result.append(line);
|
||||
// }
|
||||
// String resultJson = result.toString();
|
||||
// // parse returnT
|
||||
// try {
|
||||
// return GsonTool.fromJson(resultJson, BaseResultBean.class);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("rpc remoting (url=" + url + ") response content invalid(" + resultJson + ").", e);
|
||||
// return ResultBean.fail("rpc remoting fail, StatusCode(" + statusCode + ") invalid. for url : " + url);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// return ResultBean.fail("rpc remoting fail, error message(" + e.getMessage() + ") invalid. for url : " + url);
|
||||
// } finally {
|
||||
// try {
|
||||
// if (bufferedReader != null) {
|
||||
// bufferedReader.close();
|
||||
// }
|
||||
// if (connection != null) {
|
||||
// connection.disconnect();
|
||||
// }
|
||||
// } catch (Exception e2) {
|
||||
// logger.error(e2.getMessage(), e2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
@ -1,56 +1,56 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Castle
|
||||
*/
|
||||
public class ReturnT<T> implements Serializable {
|
||||
public static final long serialVersionUID = 42L;
|
||||
|
||||
public static final int SUCCESS_CODE = 200;
|
||||
public static final int FAIL_CODE = 500;
|
||||
|
||||
public static final ReturnT<String> SUCCESS = new ReturnT<String>(null);
|
||||
public static final ReturnT<String> FAIL = new ReturnT<String>(FAIL_CODE, null);
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private T content;
|
||||
|
||||
public ReturnT(){}
|
||||
public ReturnT(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ReturnT(T content) {
|
||||
this.code = SUCCESS_CODE;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public T getContent() {
|
||||
return content;
|
||||
}
|
||||
public void setContent(T content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
|
||||
}
|
||||
|
||||
}
|
||||
//package cn.estsh.i3plus.pojo.bsp.common;
|
||||
//
|
||||
//import java.io.Serializable;
|
||||
//
|
||||
///**
|
||||
// * @author Castle
|
||||
// */
|
||||
//public class ReturnT<T> implements Serializable {
|
||||
// public static final long serialVersionUID = 42L;
|
||||
//
|
||||
// public static final int SUCCESS_CODE = 200;
|
||||
// public static final int FAIL_CODE = 500;
|
||||
//
|
||||
// public static final ReturnT<String> SUCCESS = new ReturnT<String>(null);
|
||||
// public static final ReturnT<String> FAIL = new ReturnT<String>(FAIL_CODE, null);
|
||||
//
|
||||
// private int code;
|
||||
// private String msg;
|
||||
// private T content;
|
||||
//
|
||||
// public ReturnT(){}
|
||||
// public ReturnT(int code, String msg) {
|
||||
// this.code = code;
|
||||
// this.msg = msg;
|
||||
// }
|
||||
//
|
||||
// public ReturnT(T content) {
|
||||
// this.code = SUCCESS_CODE;
|
||||
// this.content = content;
|
||||
// }
|
||||
//
|
||||
// public int getCode() {
|
||||
// return code;
|
||||
// }
|
||||
// public void setCode(int code) {
|
||||
// this.code = code;
|
||||
// }
|
||||
// public String getMsg() {
|
||||
// return msg;
|
||||
// }
|
||||
// public void setMsg(String msg) {
|
||||
// this.msg = msg;
|
||||
// }
|
||||
// public T getContent() {
|
||||
// return content;
|
||||
// }
|
||||
// public void setContent(T content) {
|
||||
// this.content = content;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.server.bean.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description : 查询方法组使用的model
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/7/30 9:36
|
||||
* @Modify:
|
||||
**/
|
||||
@ApiModel("查询方法组")
|
||||
@Data
|
||||
public class MethodGroupListModel {
|
||||
|
||||
@ApiModelProperty("方法组名字")
|
||||
private String methodGroupName;
|
||||
|
||||
@ApiModelProperty("方法组分类")
|
||||
private String classify;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.server.bean.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/7/29 10:14
|
||||
* @Modify:
|
||||
**/
|
||||
@Data
|
||||
@ApiModel("分页查询方法列表")
|
||||
public class MethodListModel {
|
||||
|
||||
@ApiModelProperty(name = "执行器名")
|
||||
private String appName;
|
||||
@ApiModelProperty(name = "方法的版本号")
|
||||
private String version;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.server.bean.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description :路由参数
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/7/5 14:02
|
||||
* @Modify:
|
||||
**/
|
||||
@Data
|
||||
@ApiModel("路由参数")
|
||||
public class RouteParam {
|
||||
|
||||
@ApiModelProperty(value = "执行方法Id")
|
||||
private Long methodId;
|
||||
@ApiModelProperty(value = "路由的权重配置")
|
||||
private Map<String,Integer> weightConfig;
|
||||
@ApiModelProperty(value = "执行器地址列表")
|
||||
private List<String> addressList;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.estsh.i3plus.pojo.bsp.server.repository;
|
||||
|
||||
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
|
||||
import cn.estsh.i3plus.pojo.bsp.client.bean.po.EngineScriptPersistence;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : Castle
|
||||
* @CreateDate : 2021/7/22 13:51
|
||||
* @Modify:
|
||||
**/
|
||||
public interface ScriptRepository extends BaseRepository<EngineScriptPersistence,Long> {
|
||||
}
|
Loading…
Reference in New Issue