>() {
+ });
if (StringUtils.equals(result.getResult(), CommonConstant.FAILED)) {
throw new ServiceException(path, result.getCode(), result.getMessage());
}
}
-
/**
* 退出用户的登录,释放许可,当用户退出登录后,建议清除用户的token信息
*
diff --git a/jhinno-openapi-java-sdk/src/main/java/com/jhinno/sdk/openapi/api/app/JHAppApiExecution.java b/jhinno-openapi-java-sdk/src/main/java/com/jhinno/sdk/openapi/api/app/JHAppApiExecution.java
index f7f67e0..20e9b6a 100644
--- a/jhinno-openapi-java-sdk/src/main/java/com/jhinno/sdk/openapi/api/app/JHAppApiExecution.java
+++ b/jhinno-openapi-java-sdk/src/main/java/com/jhinno/sdk/openapi/api/app/JHAppApiExecution.java
@@ -4,8 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.jhinno.sdk.openapi.ArgsException;
import com.jhinno.sdk.openapi.AuthType;
import com.jhinno.sdk.openapi.CommonConstant;
+import com.jhinno.sdk.openapi.JHApiExecution;
import com.jhinno.sdk.openapi.ServiceException;
-import com.jhinno.sdk.openapi.api.JHApiExecution;
+import com.jhinno.sdk.openapi.api.JHRequestExecution;
import com.jhinno.sdk.openapi.api.ResponseResult;
import com.jhinno.sdk.openapi.client.JHApiClient;
import com.jhinno.sdk.openapi.utils.CollectionUtil;
@@ -23,16 +24,12 @@ import java.util.Map;
* @author yanlongqi
* @date 2024/2/1 16:26
*/
-@NoArgsConstructor
-public class JHAppApiExecution extends JHApiExecution {
+public class JHAppApiExecution implements JHApiExecution {
- /**
- * 获取一个执行器的实例
- *
- * @param jhApiClient 请求的客户端
- */
- public JHAppApiExecution(JHApiClient jhApiClient) {
- super(jhApiClient);
+ private JHRequestExecution execution;
+
+ public void init(JHRequestExecution execution) {
+ this.execution = execution;
}
/**
@@ -47,17 +44,19 @@ public class JHAppApiExecution extends JHApiExecution {
*
* 开发阶段,主要有一下几种方式:
*
- * - 使用js的 `window.open("{@link AppStartedInfo#getJhappUrl()}")`
- * - 使用HTML的a标签的href
- * - 使用HTML的iframe标签的src
+ * - 使用js的 `window.open("{@link AppStartedInfo#getJhappUrl()}")`
+ * - 使用HTML的a标签的href
+ * - 使用HTML的iframe标签的src
*
* 以下是使用的伪代码:
+ *
*
* // 使用a标签实例代码
* var a = document.createElement("a");
* a.href = "{@link AppStartedInfo#getJhappUrl()}";
* a.click();
*
+ *
*
* // 使用iframe标签实例代码
* var iframe = document.createElement("iframe");
@@ -71,6 +70,7 @@ public class JHAppApiExecution extends JHApiExecution {
* 并使用js生产的时间,具体的参数见 {@link AppStartRequest#setCurrentTimestamp(String)}
*
* 通过浏览器启动
+ *
*
* window.open("{@link AppStartedInfo#getWebSessionUrl()}}")
*
@@ -82,8 +82,9 @@ public class JHAppApiExecution extends JHApiExecution {
*/
public AppStartedInfo desktopStart(String username, String appId, AppStartRequest appStartRequest) {
String path = AppPathConstant.APPS_START_PATH.replace("{appId}", appId);
- List data = post(path, username, appStartRequest, new TypeReference>>() {
- });
+ List data = execution.post(path, username, appStartRequest,
+ new TypeReference>>() {
+ });
if (CollectionUtil.isEmpty(data)) {
throw new ServiceException(path, 500, "获取到的会话信息为空");
}
@@ -94,17 +95,17 @@ public class JHAppApiExecution extends JHApiExecution {
public String getWebSessionUrl(String username, String desktopId) {
String webSessionUrlPath = AppPathConstant.WEB_SESSION_URL_PATH.replace("{desktopId}", desktopId);
- String url = getJhApiClient().getUrl(webSessionUrlPath);
+ String url = execution.getJhApiClient().getUrl(webSessionUrlPath);
Map params = new HashMap<>();
- AuthType authType = getAuthType();
+ AuthType authType = execution.getAuthType();
if (authType == AuthType.TOKEN_MODE) {
- params.put(CommonConstant.TOKEN, getToken(username));
+ params.put(CommonConstant.TOKEN, execution.getToken(username));
} else if (authType == AuthType.ACCESS_SECRET_MODE) {
params.put(CommonConstant.USERNAME, username);
- params.put(CommonConstant.ACCESS_KEY, getAccessKey());
- String currentTimeMillis = getCurrentTimeMillis();
+ params.put(CommonConstant.ACCESS_KEY, execution.getAccessKey());
+ String currentTimeMillis = execution.getCurrentTimeMillis();
params.put(CommonConstant.CURRENT_TIME_MILLIS, currentTimeMillis);
- params.put(CommonConstant.SIGNATURE, getsSignature(username, currentTimeMillis));
+ params.put(CommonConstant.SIGNATURE, execution.getsSignature(username, currentTimeMillis));
}
return JHApiClient.getUrl(url, params);
}
@@ -131,16 +132,16 @@ public class JHAppApiExecution extends JHApiExecution {
* @return 会话列表
*/
public List getDesktopList(String username) {
- return get(AppPathConstant.APPS_SESSIONS_ALL_PATH, username, new TypeReference>>() {
- });
+ return execution.get(AppPathConstant.APPS_SESSIONS_ALL_PATH, username,
+ new TypeReference>>() {
+ });
}
-
/**
* 使用参数查询会话列表
*
- * - sessionIds 和 sessionName 不能同时为空
- * - 开启密级后,仅能查看比自己密级低以及和自己密级一致的会话
+ * - sessionIds 和 sessionName 不能同时为空
+ * - 开启密级后,仅能查看比自己密级低以及和自己密级一致的会话
*
*
* @param username 用户名
@@ -157,11 +158,10 @@ public class JHAppApiExecution extends JHApiExecution {
params.put("sessionName", sessionName);
}
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_PATH, params);
- return get(path, username, new TypeReference>>() {
+ return execution.get(path, username, new TypeReference>>() {
});
}
-
/**
* 根据会话列表查询会话列表
*
@@ -179,7 +179,7 @@ public class JHAppApiExecution extends JHApiExecution {
}
params.put("sessionIds", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, ids));
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_IDS_PATH, params);
- return get(path, username, new TypeReference>>() {
+ return execution.get(path, username, new TypeReference>>() {
});
}
@@ -201,16 +201,16 @@ public class JHAppApiExecution extends JHApiExecution {
}
params.put("sessionName", sessionName);
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_NAME_PATH, params);
- return get(path, username, new TypeReference>>() {
+ return execution.get(path, username, new TypeReference>>() {
});
}
/**
* 会话共享
*
- * - 调用该接口需要打开景行会话共享的功能
- * - observers 和 interacts 不能同时为空
- * - 会话共享有密级限制,仅能将会话共享给比会话密级高的用户
+ * - 调用该接口需要打开景行会话共享的功能
+ * - observers 和 interacts 不能同时为空
+ * - 会话共享有密级限制,仅能将会话共享给比会话密级高的用户
*
*
* @param username 用户名
@@ -219,7 +219,8 @@ public class JHAppApiExecution extends JHApiExecution {
* @param interacts 协作者列表 (非必填)
* @param isTransfer 是否传递操作权(不确定,需要咨询产品,非必填)
*/
- public void shareDesktop(String username, String sessionId, List observers, List interacts, String isTransfer) {
+ public void shareDesktop(String username, String sessionId, List observers, List interacts,
+ String isTransfer) {
if (StringUtils.isBlank(sessionId)) {
throw new ArgsException("sessionId为必填字段");
}
@@ -233,16 +234,16 @@ public class JHAppApiExecution extends JHApiExecution {
if (StringUtils.isBlank(isTransfer)) {
params.put("isTransfer", isTransfer);
}
- String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_SHARE_PATH.replace("{sessionId}", sessionId), params);
- post(path, username);
+ String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_SHARE_PATH.replace("{sessionId}", sessionId),
+ params);
+ execution.post(path, username);
}
-
/**
* 取消会话共享
*
- * - 调用该接口需要打开景行会话共享的功能
- * - 开启密级后,仅能操作比自己密级低或者和自己密级一致的会话
+ * - 调用该接口需要打开景行会话共享的功能
+ * - 开启密级后,仅能操作比自己密级低或者和自己密级一致的会话
*
*
* @param username 用户名
@@ -253,14 +254,14 @@ public class JHAppApiExecution extends JHApiExecution {
throw new ArgsException("sessionId为必填字段");
}
String path = AppPathConstant.APPS_SESSIONS_CANCEL_SHARE_PATH.replace("{sessionId}", sessionId);
- put(path, username);
+ execution.put(path, username);
}
/**
* 传递会话操作权
*
- * - 调用该接口需要打开景行会话共享的功能
- * - 开启密级后,仅能操作比自己密级低或者和自己密级一致的会话
+ * - 调用该接口需要打开景行会话共享的功能
+ * - 开启密级后,仅能操作比自己密级低或者和自己密级一致的会话
*
*
* @param username 用户名
@@ -278,10 +279,9 @@ public class JHAppApiExecution extends JHApiExecution {
Map params = new HashMap<>(1);
params.put("interact", interact);
path = JHApiClient.getUrl(path, params);
- put(path, username);
+ execution.put(path, username);
}
-
/**
* 连接会话
*
@@ -294,8 +294,9 @@ public class JHAppApiExecution extends JHApiExecution {
throw new ArgsException("sessionId为必填字段");
}
String path = AppPathConstant.APPS_SESSIONS_CONNECT_JHAPP_PATH.replace("{sessionId}", sessionId);
- List list = get(path, username, new TypeReference>>() {
- });
+ List list = execution.get(path, username,
+ new TypeReference>>() {
+ });
if (CollectionUtil.isEmpty(list)) {
throw new ServiceException(path, 500, "获取到的会话信息为空");
}
@@ -305,7 +306,6 @@ public class JHAppApiExecution extends JHApiExecution {
return appStartedInfo;
}
-
/**
* 断开会话连接(作业/应用)
*
@@ -320,10 +320,9 @@ public class JHAppApiExecution extends JHApiExecution {
throw new ArgsException("sessionId为必填字段");
}
String path = AppPathConstant.APPS_SESSIONS_DISCONNECT_PATH.replace("{sessionId}", sessionId);
- put(path, username);
+ execution.put(path, username);
}
-
/**
* 通过应用id批量断开会话(作业/应用)
*
@@ -340,10 +339,9 @@ public class JHAppApiExecution extends JHApiExecution {
Map params = new HashMap<>(1);
params.put("sessionIds", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, sessionIds));
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_DISCONNECT_IDS_PATH, params);
- put(path, username);
+ execution.put(path, username);
}
-
/**
* 注销会话
*
@@ -358,10 +356,9 @@ public class JHAppApiExecution extends JHApiExecution {
throw new ArgsException("sessionId为必填字段");
}
String path = AppPathConstant.APPS_SESSIONS_DESTROY_PATH.replace("{sessionId}", sessionId);
- put(path, username);
+ execution.put(path, username);
}
-
/**
* 批量注销会话
*
@@ -375,10 +372,9 @@ public class JHAppApiExecution extends JHApiExecution {
Map params = new HashMap<>(1);
params.put("sessionIds", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, sessionIds));
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_DESTROY_IDS_PATH, params);
- put(path, username);
+ execution.put(path, username);
}
-
/**
* 获取当前用户的应用列表
*
@@ -386,11 +382,11 @@ public class JHAppApiExecution extends JHApiExecution {
* @return 应用列表
*/
public List getAppList(String username) {
- return get(AppPathConstant.APPS_LIST_PATH, username, new TypeReference>>() {
- });
+ return execution.get(AppPathConstant.APPS_LIST_PATH, username,
+ new TypeReference>>() {
+ });
}
-
/**
* 获取应用链接
*
@@ -403,8 +399,9 @@ public class JHAppApiExecution extends JHApiExecution {
throw new ArgsException("appName为必填字段");
}
String path = AppPathConstant.APPS_GET_URL_PATH.replace("{appName}", appName);
- List