mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
feat: 增强应用和文件API功能
主要更新: - AppInfo: 添加了icon、os、type等字段的详细文档说明 - AppTypeConstant: 新增应用类型分类工具类,支持按类型、操作系统、分类筛选应用 - Confidential: 实现文件密级管理功能,包括获取密级列表和标密操作 - JHAppApiExecution: 重构getWebSessionUrl方法,改为通过API获取会话URL - JHFileApiExecution: 新增getConfList和markConf方法支持文件密级功能 - 优化代码格式,规范注释和文档 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@ public class JHApiExecutionManage {
|
||||
|
||||
/**
|
||||
* 创建一个带有默认HTTP客户端的API执行管理器
|
||||
*
|
||||
*
|
||||
* @param appformBaseUrl 景行API的URL
|
||||
*/
|
||||
public JHApiExecutionManage(String appformBaseUrl) {
|
||||
@@ -32,7 +32,7 @@ public class JHApiExecutionManage {
|
||||
|
||||
/**
|
||||
* 创建一个带有自定义HTTP客户端的API执行管理器
|
||||
*
|
||||
*
|
||||
* @param httpClient 自定义HTTP客户端
|
||||
* @param appformBaseUrl 景行API的URL
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ public class JHApiExecutionManage {
|
||||
|
||||
/**
|
||||
* 配置API执行器
|
||||
*
|
||||
*
|
||||
* @param configurator API执行器配置器
|
||||
*/
|
||||
public void configureApiExecution(ApiExecutionConfigurator configurator) {
|
||||
@@ -70,7 +70,7 @@ public class JHApiExecutionManage {
|
||||
|
||||
/**
|
||||
* 注册自定义的执行器
|
||||
*
|
||||
*
|
||||
* @param execution 自定义的执行器实例
|
||||
*/
|
||||
public void registerApiExecution(JHApiExecution execution) {
|
||||
@@ -80,7 +80,7 @@ public class JHApiExecutionManage {
|
||||
|
||||
/**
|
||||
* 获取一个特定的执行器用于调用接口
|
||||
*
|
||||
*
|
||||
* @param <T> 执行器的类型
|
||||
* @param clazz 执行器的类
|
||||
* @return 执行器实例
|
||||
@@ -92,11 +92,11 @@ public class JHApiExecutionManage {
|
||||
/**
|
||||
* API执行器配置器接口,用于配置API执行器的参数
|
||||
*/
|
||||
public static interface ApiExecutionConfigurator {
|
||||
public interface ApiExecutionConfigurator {
|
||||
|
||||
/**
|
||||
* 配置API执行器的参数
|
||||
*
|
||||
*
|
||||
* @param execution API执行器实例
|
||||
*/
|
||||
void configure(JHRequestExecution execution);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.jhinno.sdk.openapi.api.app;
|
||||
|
||||
import com.jhinno.sdk.openapi.api.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -29,6 +31,24 @@ public class AppInfo {
|
||||
|
||||
/**
|
||||
* 应用图标
|
||||
*
|
||||
* <p>
|
||||
* 示例数据:/appform/images/apps/app_fluent.png
|
||||
* <p>
|
||||
* 需要使用 {@link JHApiClient#getUrl(String)} 拼接景行的服务器地址;使用Spring,JHApiClient在容器中,可以使用注入的方式获得
|
||||
*
|
||||
* <pre>{@code
|
||||
* @Autoward
|
||||
* private JHApiClient apiClient;
|
||||
*
|
||||
* public String getIconUrl(String icon){
|
||||
* return apiClient.getUrl(icon);
|
||||
* }
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* 拼接后的示例数据:https://192.168.87.24/appform/images/apps/app_fluent.png
|
||||
*/
|
||||
private String icon;
|
||||
private String copyAppClass;
|
||||
@@ -67,6 +87,18 @@ public class AppInfo {
|
||||
|
||||
private String mode;
|
||||
|
||||
/**
|
||||
* 操作系统类型
|
||||
* <ul>
|
||||
* <li>空:系统应用,如:我的会话、我的作业、应用仓库等。</li>
|
||||
* <li>linux: 应用是Linux应用</li>
|
||||
* <li>windows: 应用是Windows应用</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see AppTypeConstant.AppOsType 定义了 os 可能的值
|
||||
* <p>
|
||||
* 如果需要获取特定分类的应用列表,可以使用 {@link AppTypeConstant.AppOsType#getAppList(List)}
|
||||
*/
|
||||
private String os;
|
||||
|
||||
private String showin;
|
||||
@@ -77,16 +109,31 @@ public class AppInfo {
|
||||
|
||||
/**
|
||||
* 应用类型
|
||||
*
|
||||
* <ul>
|
||||
* <li>空:系统应用,如:我的会话、我的作业、应用仓库等。</li>
|
||||
* <li>batch: 计算应用,如:通用计算、Fluent等</li>
|
||||
* <li>desktop: 图形应用。如:Windows桌面、Linux桌面、Notepad等</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see AppTypeConstant.AppType 定义了 os 可能的值
|
||||
* <p>
|
||||
* 如果需要获取特定分类的应用列表,可以使用 {@link AppTypeConstant.AppType#getAppList(List)}
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 应用分类
|
||||
* <p>
|
||||
* 系统应用返回system,其他为空字符串
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 应用协议
|
||||
* <p>
|
||||
* 图形会话返回jhapp,其他应用为空字符串
|
||||
* </p>
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
@@ -156,4 +203,19 @@ public class AppInfo {
|
||||
private String cwd;
|
||||
|
||||
|
||||
private String apiKey;
|
||||
|
||||
/**
|
||||
* 应用状态
|
||||
*/
|
||||
private String appStatus;
|
||||
|
||||
/**
|
||||
* 应用描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
|
||||
private Boolean used;
|
||||
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class AppPathConstant {
|
||||
/**
|
||||
* WEB启动会话URL
|
||||
*/
|
||||
public static final String WEB_SESSION_URL_PATH = "/pageapi/apps/webclient/gui/{desktopId}";
|
||||
public static final String WEB_SESSION_URL_PATH = "/appform/ws/api/apps/webclient/{sessionId}/connect";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.jhinno.sdk.openapi.api.app;
|
||||
|
||||
import com.jhinno.sdk.openapi.utils.CollectionUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AppTypeConstant {
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AppType {
|
||||
/**
|
||||
* 系统应用
|
||||
*/
|
||||
SYSTEM_APP(StringUtils.EMPTY),
|
||||
BATCH_APP("batch"),
|
||||
DESKTOP_APP("desktop"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
|
||||
public List<AppInfo> getAppList(List<AppInfo> list) {
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return list;
|
||||
}
|
||||
return list.stream()
|
||||
.filter(t -> StringUtils.equals(t.getType(), this.type))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AppOsType {
|
||||
SYSTEM(StringUtils.EMPTY),
|
||||
LINUX("linux"),
|
||||
WINDOWS("windows"),
|
||||
;
|
||||
|
||||
private final String os;
|
||||
|
||||
public List<AppInfo> getAppList(List<AppInfo> list) {
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return list;
|
||||
}
|
||||
return list.stream()
|
||||
.filter(t -> StringUtils.equals(t.getOs(), this.os))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AppCategory {
|
||||
SYSTEM("system"),
|
||||
APP(StringUtils.EMPTY);
|
||||
|
||||
private final String category;
|
||||
|
||||
public List<AppInfo> getAppList(List<AppInfo> list) {
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return list;
|
||||
}
|
||||
return list.stream()
|
||||
.filter(t -> StringUtils.equals(t.getCategory(), this.category))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package com.jhinno.sdk.openapi.api.app;
|
||||
|
||||
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.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.api.ResponseResult;
|
||||
@@ -23,13 +21,7 @@ import java.util.Map;
|
||||
* @author yanlongqi
|
||||
* @date 2024/2/1 16:26
|
||||
*/
|
||||
public class JHAppApiExecution implements JHApiExecution {
|
||||
|
||||
private JHRequestExecution execution;
|
||||
|
||||
public void init(JHRequestExecution execution) {
|
||||
this.execution = execution;
|
||||
}
|
||||
public class JHAppApiExecution extends JHRequestExecution {
|
||||
|
||||
/**
|
||||
* 启动一个会话
|
||||
@@ -48,20 +40,20 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
* <li>使用HTML的iframe标签的src</li>
|
||||
* </ul>
|
||||
* 以下是使用的伪代码:
|
||||
*
|
||||
* <pre class="code">
|
||||
*
|
||||
* <pre>{@code
|
||||
* // 使用a标签实例代码
|
||||
* var a = document.createElement("a");
|
||||
* a.href = "{@link AppStartedInfo#getJhappUrl()}";
|
||||
* a.click();
|
||||
* </pre>
|
||||
*
|
||||
* <pre class="code">
|
||||
* }</pre>
|
||||
*
|
||||
* <pre>{@code
|
||||
* // 使用iframe标签实例代码
|
||||
* var iframe = document.createElement("iframe");
|
||||
* iframe.style.display = "none";
|
||||
* iframe.src = "{@link AppStartedInfo#getJhappUrl()}";
|
||||
* </pre>
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* 注意:如果使用JHAppClient启动应用的,并且没有做浏览器端和服务器没有做时间同步,
|
||||
@@ -69,10 +61,10 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
* 并使用js生产的时间,具体的参数见 {@link AppStartRequest#setCurrentTimestamp(String)}
|
||||
*
|
||||
* <h4>通过浏览器启动</h4>
|
||||
*
|
||||
* <pre class="code">
|
||||
*
|
||||
* <pre>{@code
|
||||
* window.open("{@link AppStartedInfo#getWebSessionUrl()}}")
|
||||
* </pre>
|
||||
* }</pre>
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param appId 应用拆
|
||||
@@ -81,7 +73,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
*/
|
||||
public AppStartedInfo desktopStart(String username, String appId, AppStartRequest appStartRequest) {
|
||||
String path = AppPathConstant.APPS_START_PATH.replace("{appId}", appId);
|
||||
List<AppStartedInfo> data = execution.post(path, username, appStartRequest,
|
||||
List<AppStartedInfo> data = this.post(path, username, appStartRequest,
|
||||
new TypeReference<ResponseResult<List<AppStartedInfo>>>() {
|
||||
});
|
||||
if (CollectionUtil.isEmpty(data)) {
|
||||
@@ -92,21 +84,14 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
return appStartedInfo;
|
||||
}
|
||||
|
||||
public String getWebSessionUrl(String username, String desktopId) {
|
||||
String webSessionUrlPath = AppPathConstant.WEB_SESSION_URL_PATH.replace("{desktopId}", desktopId);
|
||||
String url = execution.getJhApiClient().getUrl(webSessionUrlPath);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
AuthType authType = execution.getAuthType();
|
||||
if (authType == AuthType.TOKEN_MODE) {
|
||||
params.put(CommonConstant.TOKEN, execution.getToken(username));
|
||||
} else if (authType == AuthType.ACCESS_SECRET_MODE) {
|
||||
params.put(CommonConstant.USERNAME, username);
|
||||
params.put(CommonConstant.ACCESS_KEY, execution.getAccessKey());
|
||||
String currentTimeMillis = execution.getCurrentTimeMillis();
|
||||
params.put(CommonConstant.CURRENT_TIME_MILLIS, currentTimeMillis);
|
||||
params.put(CommonConstant.SIGNATURE, execution.getsSignature(username, currentTimeMillis));
|
||||
public String getWebSessionUrl(String username, String sessionId) {
|
||||
String webSessionUrlPath = AppPathConstant.WEB_SESSION_URL_PATH.replace("{sessionId}", sessionId);
|
||||
Map<String, String> result = this.get(webSessionUrlPath, username, new TypeReference<ResponseResult<Map<String, String>>>() {
|
||||
});
|
||||
if (CollectionUtil.isEmpty(result)) {
|
||||
return null;
|
||||
}
|
||||
return JHApiClient.getUrl(url, params);
|
||||
return result.get("url");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +116,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
* @return 会话列表
|
||||
*/
|
||||
public List<SessionInfo> getDesktopList(String username) {
|
||||
return execution.get(AppPathConstant.APPS_SESSIONS_ALL_PATH, username,
|
||||
return this.get(AppPathConstant.APPS_SESSIONS_ALL_PATH, username,
|
||||
new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
});
|
||||
}
|
||||
@@ -157,7 +142,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
params.put("sessionName", sessionName);
|
||||
}
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_PATH, params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
return this.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,7 +163,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
}
|
||||
params.put("sessionIds", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, ids));
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_IDS_PATH, params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
return this.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -200,7 +185,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
}
|
||||
params.put("sessionName", sessionName);
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_NAME_PATH, params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
return this.get(path, username, new TypeReference<ResponseResult<List<SessionInfo>>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -219,7 +204,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
* @param isTransfer 是否传递操作权(不确定,需要咨询产品,非必填)
|
||||
*/
|
||||
public void shareDesktop(String username, String sessionId, List<String> observers, List<String> interacts,
|
||||
String isTransfer) {
|
||||
String isTransfer) {
|
||||
if (StringUtils.isBlank(sessionId)) {
|
||||
throw new ArgsException("sessionId为必填字段");
|
||||
}
|
||||
@@ -235,7 +220,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
}
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APPS_SESSIONS_SHARE_PATH.replace("{sessionId}", sessionId),
|
||||
params);
|
||||
execution.post(path, username);
|
||||
this.post(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +238,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
throw new ArgsException("sessionId为必填字段");
|
||||
}
|
||||
String path = AppPathConstant.APPS_SESSIONS_CANCEL_SHARE_PATH.replace("{sessionId}", sessionId);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +263,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
params.put("interact", interact);
|
||||
path = JHApiClient.getUrl(path, params);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +278,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
throw new ArgsException("sessionId为必填字段");
|
||||
}
|
||||
String path = AppPathConstant.APPS_SESSIONS_CONNECT_JHAPP_PATH.replace("{sessionId}", sessionId);
|
||||
List<AppStartedInfo> list = execution.get(path, username,
|
||||
List<AppStartedInfo> list = this.get(path, username,
|
||||
new TypeReference<ResponseResult<List<AppStartedInfo>>>() {
|
||||
});
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
@@ -319,7 +304,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
throw new ArgsException("sessionId为必填字段");
|
||||
}
|
||||
String path = AppPathConstant.APPS_SESSIONS_DISCONNECT_PATH.replace("{sessionId}", sessionId);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +323,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
Map<String, Object> 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);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +340,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
throw new ArgsException("sessionId为必填字段");
|
||||
}
|
||||
String path = AppPathConstant.APPS_SESSIONS_DESTROY_PATH.replace("{sessionId}", sessionId);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +356,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
Map<String, Object> 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);
|
||||
execution.put(path, username);
|
||||
this.put(path, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +366,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
* @return 应用列表
|
||||
*/
|
||||
public List<AppInfo> getAppList(String username) {
|
||||
return execution.get(AppPathConstant.APPS_LIST_PATH, username,
|
||||
return this.get(AppPathConstant.APPS_LIST_PATH, username,
|
||||
new TypeReference<ResponseResult<List<AppInfo>>>() {
|
||||
});
|
||||
}
|
||||
@@ -398,7 +383,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
throw new ArgsException("appName为必填字段");
|
||||
}
|
||||
String path = AppPathConstant.APPS_GET_URL_PATH.replace("{appName}", appName);
|
||||
List<Map<String, String>> apps = execution.get(path, username,
|
||||
List<Map<String, String>> apps = this.get(path, username,
|
||||
new TypeReference<ResponseResult<List<Map<String, String>>>>() {
|
||||
});
|
||||
if (CollectionUtil.isEmpty(apps)) {
|
||||
@@ -431,7 +416,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
params.put("suffixes", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, suffixes));
|
||||
}
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APPS_SUFFIXES_PATH, params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<List<AppstoreAppInfo>>>() {
|
||||
return this.get(path, username, new TypeReference<ResponseResult<List<AppstoreAppInfo>>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -459,7 +444,7 @@ public class JHAppApiExecution implements JHApiExecution {
|
||||
params.put("use_labels", String.join(CommonConstant.NORMAL_CHARACTER_COMMA, labels));
|
||||
}
|
||||
String path = JHApiClient.getUrl(AppPathConstant.APP_USE_LABEL_PATH, params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<List<UseLabelInfo>>>() {
|
||||
return this.get(path, username, new TypeReference<ResponseResult<List<UseLabelInfo>>>() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jhinno.sdk.openapi.api.file;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Confidential {
|
||||
|
||||
/**
|
||||
* 密级key
|
||||
*/
|
||||
private String conf;
|
||||
|
||||
/**
|
||||
* 密级英文名
|
||||
*/
|
||||
private String confEn;
|
||||
|
||||
/**
|
||||
* 密级中文名
|
||||
*/
|
||||
private String confCn;
|
||||
|
||||
/**
|
||||
* 密级权重
|
||||
*/
|
||||
private int confLevel;
|
||||
|
||||
}
|
||||
@@ -64,4 +64,9 @@ public class FilePathConstant {
|
||||
*/
|
||||
public static final String FILE_UNCOMPRESS_PATH = "/appform/ws/api/files/uncompress";
|
||||
|
||||
/**
|
||||
* 密级相关请求路径
|
||||
*/
|
||||
public static final String FILE_CONF_PATH = "/appform/ws/api/file/conf";
|
||||
|
||||
}
|
||||
|
||||
@@ -473,4 +473,32 @@ public class JHFileApiExecution implements JHApiExecution {
|
||||
public void uncompress(String username, String sourceFilePath, String targetDirPath) {
|
||||
uncompress(username, sourceFilePath, targetDirPath, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取可用的文件吗密级列表
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 密级列表
|
||||
*/
|
||||
public List<Confidential> getConfList(String username) {
|
||||
return execution.get(FilePathConstant.FILE_CONF_PATH, username, new TypeReference<ResponseResult<List<Confidential>>>() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件表表标密
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param conf 密级使用{@link JHFileApiExecution#getConfList(String)}返回的{@link Confidential#conf}
|
||||
* @param path 文件路径
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void markConf(String username, String conf, String path) {
|
||||
Map<String, Object> body = new HashMap<>(2);
|
||||
body.put("conf", conf);
|
||||
body.put("path", path);
|
||||
execution.post(FilePathConstant.FILE_CONF_PATH, username, body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ public class JHClientConfig {
|
||||
* 创建一个API执行器管理器
|
||||
*/
|
||||
public static final JHApiExecutionManage API_EXECUTRON_MANAGE = new JHApiExecutionManage(
|
||||
"https://192.168.87.24");
|
||||
"https://172.20.0.200");
|
||||
|
||||
public static final String ACCESS_KEY = "e2544957e53b4377bb4f8203a094e50b";
|
||||
public static final String ACCESS_KEY = "8147c7470bfd4a27952fe750c6bc7cef";
|
||||
|
||||
public static final String ACCESS_KEY_SECRET = "52d18cf7163047b78ea48756b8b40d28";
|
||||
public static final String ACCESS_KEY_SECRET = "899b13f590394c3daafc6468fed4b1df";
|
||||
|
||||
static {
|
||||
API_EXECUTRON_MANAGE.configureApiExecution(t -> {
|
||||
// 默认为使用Token模式,如何使用的Token模式,则不需要配置ACCESS_KEY和ACCESS_KEY SECRET
|
||||
t.setAuthType(AuthType.ACCESS_SECRET_MODE);
|
||||
t.setAuthType(AuthType.ACCESS_SECRET_MODE);
|
||||
t.setAccessKey(ACCESS_KEY);
|
||||
t.setAccessKeySecret(ACCESS_KEY_SECRET);
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jhinno.sdk.openapi.test.app;
|
||||
|
||||
import com.jhinno.sdk.openapi.api.app.*;
|
||||
import com.jhinno.sdk.openapi.test.JHClientConfig;
|
||||
import com.jhinno.sdk.openapi.utils.JsonUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -13,7 +14,6 @@ import java.util.List;
|
||||
* @author yanlongqi
|
||||
* @date 2024/2/1 16:47
|
||||
*/
|
||||
|
||||
public class AppApiTest {
|
||||
|
||||
/**
|
||||
@@ -29,8 +29,10 @@ public class AppApiTest {
|
||||
public void testStartApp() {
|
||||
AppStartRequest appStartRequest = new AppStartRequest();
|
||||
appStartRequest.setStartNew(true);
|
||||
AppStartedInfo appStartedInfo = jhAppApiExecution.desktopStart("jhadmin", "linux_desktop", appStartRequest);
|
||||
System.out.println(appStartedInfo);
|
||||
AppStartedInfo appStartedInfo = jhAppApiExecution.desktopStart("yanlongqi", "linux_desktop", appStartRequest);
|
||||
System.out.println("会话ID:" + appStartedInfo.getDesktopId());
|
||||
System.out.println("JhAppURL:" + appStartedInfo.getJhappUrl());
|
||||
System.out.println("WebURL:" + appStartedInfo.getWebSessionUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,8 +151,22 @@ public class AppApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGetAppList() {
|
||||
List<AppInfo> appList = jhAppApiExecution.getAppList("jhadmin");
|
||||
System.out.println(appList);
|
||||
List<AppInfo> appList = jhAppApiExecution.getAppList("yanlongqi");
|
||||
System.out.println("全部列表" + JsonUtil.objectToString(appList));
|
||||
|
||||
// 类型获取
|
||||
System.out.println("系统应用" + JsonUtil.objectToString(AppTypeConstant.AppType.SYSTEM_APP.getAppList(appList)));
|
||||
System.out.println("计算应用" + JsonUtil.objectToString(AppTypeConstant.AppType.BATCH_APP.getAppList(appList)));
|
||||
System.out.println("图形应用" + JsonUtil.objectToString(AppTypeConstant.AppType.DESKTOP_APP.getAppList(appList)));
|
||||
|
||||
// 操作系统分类
|
||||
System.out.println("系统应用" + JsonUtil.objectToString(AppTypeConstant.AppOsType.SYSTEM.getAppList(appList)));
|
||||
System.out.println("Linux应用" + JsonUtil.objectToString(AppTypeConstant.AppOsType.LINUX.getAppList(appList)));
|
||||
System.out.println("Windows应用" + JsonUtil.objectToString(AppTypeConstant.AppOsType.WINDOWS.getAppList(appList)));
|
||||
|
||||
// 应用分类
|
||||
System.out.println("系统应用" + JsonUtil.objectToString(AppTypeConstant.AppCategory.SYSTEM.getAppList(appList)));
|
||||
System.out.println("景行发布应用" + JsonUtil.objectToString(AppTypeConstant.AppCategory.APP.getAppList(appList)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.jhinno.sdk.openapi.test.file;
|
||||
|
||||
import com.jhinno.sdk.openapi.api.file.Confidential;
|
||||
import com.jhinno.sdk.openapi.api.file.FileInfo;
|
||||
import com.jhinno.sdk.openapi.api.file.JHFileApiExecution;
|
||||
import com.jhinno.sdk.openapi.test.JHClientConfig;
|
||||
import com.jhinno.sdk.openapi.utils.JsonUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import java.io.File;
|
||||
@@ -105,7 +108,7 @@ public class FileApiTest {
|
||||
public void testUploadFileConf() throws IOException {
|
||||
File file = new File("C:\\Users\\yanlongqi\\Desktop\\Hash.exe");
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
execution.uploadFile("lqyan", fileInputStream, file.getName(), "$HOME/temp111", false,"public");
|
||||
execution.uploadFile("lqyan", fileInputStream, file.getName(), "$HOME/temp111", false, "public");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,4 +137,15 @@ public class FileApiTest {
|
||||
public void testUncompress() {
|
||||
execution.uncompress("jhadmin", "$HOME/temp.zip", "$HOME/test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfList() {
|
||||
List<Confidential> confList = execution.getConfList("yanlongqi");
|
||||
System.out.println(JsonUtil.objectToString(confList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkConf() {
|
||||
execution.markConf("yanlongqi", "999999998", "/home/yanlongqi/test.sh");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jhinno.sdk.openapi.test.job;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class JobTooltipDTO {
|
||||
|
||||
/**
|
||||
* 可用cpu核数
|
||||
*/
|
||||
private Integer slotsAvail;
|
||||
|
||||
/**
|
||||
* 等待作业数
|
||||
*/
|
||||
private Integer totalPendJobs;
|
||||
|
||||
/**
|
||||
* 调试信息
|
||||
*/
|
||||
private String debugMessage;
|
||||
}
|
||||
@@ -21,20 +21,35 @@ public class JHFileApiExtendExecution implements JHApiExecution {
|
||||
this.execution = execution;
|
||||
}
|
||||
|
||||
public static String GET_FILE_ENV_PATH = "/appform/ws/api/files/path/{env}";
|
||||
|
||||
public FilePath getFileEnvPath(String username, FileEnvType env, FileSystemType type) {
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
if (StringUtils.isNotBlank(type.getType())) {
|
||||
params.put("type", type.getType());
|
||||
}
|
||||
String url = JHApiClient.getUrl(GET_FILE_ENV_PATH.replace("{env}", env.getEnv()), params);
|
||||
return execution.get(url, username, new TypeReference<ResponseResult<FilePath>>() {
|
||||
/**
|
||||
* 删除作业
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param jobId 作业ID
|
||||
*/
|
||||
public void deleteJob(String username, String jobId) {
|
||||
execution.delete("/appform/ws/api/jobs/" + jobId, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集群的应用的CPU核数和排队作业数
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param jobQueue 队列,没有要求就填写normal
|
||||
* @param jobPlatform 作业查询条件,如:type==LINUX64
|
||||
* @param appName 应用ID,如:common_sub
|
||||
* @return
|
||||
*/
|
||||
public JobTooltipDTO getJobTooltipInfo(String username, String jobQueue, String jobPlatform, String appName) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("jobQueue", jobQueue);
|
||||
params.put("jobPlatform", jobPlatform);
|
||||
params.put("isTestApp", false);
|
||||
params.put("appName", appName);
|
||||
String path = JHApiClient.getUrl("/appform/ws/api/jobs/tooltip", params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<JobTooltipDTO>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public FilePath getFileHomeEnvPath(String username, FileSystemType type) {
|
||||
return getFileEnvPath(username, FileEnvType.HOME_ENV, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user