mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 11:58:01 +08:00
fix core
This commit is contained in:
parent
ca6a6e5b1a
commit
be3c886e80
@ -177,7 +177,7 @@
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>jiangzeyin</name>
|
||||
<name>bwcx_jzy</name>
|
||||
<email>bwcx_jzy@163.com</email>
|
||||
<organization>bwcx_jzy</organization>
|
||||
</developer>
|
||||
|
@ -28,10 +28,10 @@ import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.keepbx.jpom.JpomAppType;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.common.JpomAppType;
|
||||
import org.dromara.jpom.common.ServerOpenApi;
|
||||
import org.dromara.jpom.common.Type;
|
||||
import org.dromara.jpom.system.AgentStartInit;
|
||||
import org.springframework.boot.Banner;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@ -41,7 +41,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
/**
|
||||
* jpom 启动类
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/9/14.
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = {"org.dromara.jpom"})
|
||||
|
@ -25,7 +25,7 @@ package org.dromara.jpom.common;
|
||||
/**
|
||||
* 插件端配置
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public class AgentConst {
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
/**
|
||||
* 全局异常处理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/04/17
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
|
@ -38,7 +38,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* agent 端
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
public abstract class BaseAgentController extends BaseJpomController {
|
||||
|
@ -34,7 +34,7 @@ import java.io.File;
|
||||
/**
|
||||
* 系统监控命令
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public abstract class AbstractSystemCommander {
|
||||
|
@ -34,7 +34,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -31,7 +31,7 @@ import java.io.File;
|
||||
/**
|
||||
* windows 系统查询命令
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public class WindowsSystemCommander extends AbstractSystemCommander {
|
||||
|
@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* 授权拦截
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@Configuration
|
||||
|
@ -27,7 +27,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 不需要授权
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@Documented
|
||||
|
@ -55,7 +55,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@RestController
|
||||
@ -81,7 +81,7 @@ public class IndexController extends BaseAgentController {
|
||||
public JsonMessage<JSONObject> info() {
|
||||
|
||||
JpomManifest instance = JpomManifest.getInstance();
|
||||
RemoteVersion remoteVersion = RemoteVersion.cacheInfo();
|
||||
cn.keepbx.jpom.RemoteVersion remoteVersion = RemoteVersion.cacheInfo();
|
||||
//
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("manifest", instance);
|
||||
@ -136,13 +136,13 @@ public class IndexController extends BaseAgentController {
|
||||
processName = StrUtil.emptyToDefault(processName, "java");
|
||||
List<JSONObject> processes = OshiUtils.getProcesses(processName, Convert.toInt(count, 20));
|
||||
processes = processes.stream()
|
||||
.peek(jsonObject -> {
|
||||
int processId = jsonObject.getIntValue("processId");
|
||||
String port = AbstractProjectCommander.getInstance().getMainPort(processId);
|
||||
jsonObject.put("port", port);
|
||||
//
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.peek(jsonObject -> {
|
||||
int processId = jsonObject.getIntValue("processId");
|
||||
String port = AbstractProjectCommander.getInstance().getMainPort(processId);
|
||||
jsonObject.put("port", port);
|
||||
//
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return JsonMessage.success("ok", processes);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* 编辑项目
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@RestController
|
||||
|
@ -73,7 +73,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 项目文件管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@RestController
|
||||
|
@ -41,7 +41,7 @@ import java.util.List;
|
||||
/**
|
||||
* 管理的信息获取接口
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@RestController
|
||||
|
@ -47,7 +47,7 @@ import java.util.List;
|
||||
/**
|
||||
* 项目文件管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@RestController
|
||||
|
@ -43,7 +43,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@RestController
|
||||
|
@ -59,7 +59,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 脚本管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@RestController
|
||||
|
@ -24,10 +24,10 @@ package org.dromara.jpom.controller.system;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.keepbx.jpom.event.ICacheTask;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.common.BaseAgentController;
|
||||
import org.dromara.jpom.common.ICacheTask;
|
||||
import org.dromara.jpom.common.JpomManifest;
|
||||
import org.dromara.jpom.common.JsonMessage;
|
||||
import org.dromara.jpom.common.commander.AbstractProjectCommander;
|
||||
|
@ -61,7 +61,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* nginx 列表
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@RestController
|
||||
|
@ -29,6 +29,7 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.common.*;
|
||||
import org.dromara.jpom.system.AgentConfig;
|
||||
@ -121,8 +122,8 @@ public class SystemUpdateController extends BaseAgentController {
|
||||
* @see RemoteVersion
|
||||
*/
|
||||
@PostMapping(value = "check_version.json", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public JsonMessage<RemoteVersion> checkVersion() {
|
||||
RemoteVersion remoteVersion = RemoteVersion.loadRemoteInfo();
|
||||
public JsonMessage<cn.keepbx.jpom.RemoteVersion> checkVersion() {
|
||||
cn.keepbx.jpom.RemoteVersion remoteVersion = RemoteVersion.loadRemoteInfo();
|
||||
return JsonMessage.success("", remoteVersion);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@RestController
|
||||
|
@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 项目配置信息实体
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -34,7 +34,7 @@ import java.io.File;
|
||||
/**
|
||||
* 脚本模板
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@Data
|
||||
|
@ -28,7 +28,7 @@ import org.dromara.jpom.model.BaseJsonModel;
|
||||
/**
|
||||
* 网络端口信息实体
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/10
|
||||
*/
|
||||
public class NetstatModel extends BaseJsonModel {
|
||||
|
@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* 脚本执行
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/25
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -35,7 +35,7 @@ import java.io.FileNotFoundException;
|
||||
/**
|
||||
* 公共文件操作Service
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/1/16
|
||||
*/
|
||||
public abstract class BaseDataService {
|
||||
|
@ -35,7 +35,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* 标准操作Service
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/14
|
||||
*/
|
||||
public abstract class BaseOperService<T extends BaseModel> extends BaseDataService {
|
||||
|
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 白名单服务
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/2/28
|
||||
*/
|
||||
@Service
|
||||
|
@ -31,9 +31,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 控制台
|
||||
* Created by jiangzeyin on 2018/9/28.
|
||||
* Created by bwcx_jzy on 2018/9/28.
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
@Service
|
||||
public class ConsoleService {
|
||||
|
@ -34,7 +34,7 @@ import java.io.File;
|
||||
/**
|
||||
* 项目管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
@Service
|
||||
public class ProjectInfoService extends BaseWorkspaceOptService<NodeProjectInfoModel> {
|
||||
|
@ -45,7 +45,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 脚本模板管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@Service
|
||||
|
@ -38,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* 文件跟随器
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
||||
/**
|
||||
* 插件端socket 配置
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/19
|
||||
*/
|
||||
@Configuration
|
||||
|
@ -50,7 +50,7 @@ import java.nio.charset.Charset;
|
||||
/**
|
||||
* 插件端,控制台socket
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@ServerEndpoint(value = "/console")
|
||||
|
@ -40,7 +40,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* 脚本模板socket
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@ServerEndpoint(value = "/script_run")
|
||||
|
@ -44,7 +44,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* 系统日志
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@ServerEndpoint(value = "/tomcat_log")
|
||||
|
@ -23,13 +23,13 @@
|
||||
package org.dromara.jpom.socket;
|
||||
|
||||
import cn.hutool.core.lang.Tuple;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.common.Const;
|
||||
import org.dromara.jpom.common.JpomManifest;
|
||||
import org.dromara.jpom.common.JsonMessage;
|
||||
import org.dromara.jpom.common.Type;
|
||||
import org.dromara.jpom.model.AgentFileModel;
|
||||
import org.dromara.jpom.model.UploadFileModel;
|
||||
import org.dromara.jpom.model.WebSocketMessageModel;
|
||||
|
@ -45,7 +45,7 @@ import static javax.websocket.CloseReason.CloseCodes.CANNOT_ACCEPT;
|
||||
/**
|
||||
* 插件端socket 基类
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -45,7 +45,7 @@ import java.io.File;
|
||||
/**
|
||||
* agent 端授权账号信息
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -36,10 +36,10 @@ import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.keepbx.jpom.event.ISystemTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.common.ILoadEvent;
|
||||
import org.dromara.jpom.common.ISystemTask;
|
||||
import org.dromara.jpom.common.RemoteVersion;
|
||||
import org.dromara.jpom.common.commander.AbstractProjectCommander;
|
||||
import org.dromara.jpom.cron.CronUtils;
|
||||
@ -63,7 +63,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 自动备份控制台日志,防止日志文件过大
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/17
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
/**
|
||||
* 根据执行KEY 多线程锁
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/8/24.
|
||||
*/
|
||||
public class KeyLock<K> {
|
||||
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* socket 会话对象
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/9/29
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -35,7 +35,7 @@ import java.nio.file.Paths;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Created by jiangzeyin on 2019/4/22.
|
||||
* Created by bwcx_jzy on 2019/4/22.
|
||||
*/
|
||||
public class TestFile {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
@ -92,6 +92,12 @@
|
||||
<version>1.22</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.keepbx.jpom</groupId>
|
||||
<artifactId>jpom-core-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
@ -30,11 +30,11 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.keepbx.jpom.JpomAppType;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.common.Const;
|
||||
import org.dromara.jpom.common.JpomAppType;
|
||||
import org.dromara.jpom.common.JpomManifest;
|
||||
import org.dromara.jpom.common.Type;
|
||||
import org.dromara.jpom.system.ExtConfigBean;
|
||||
import org.dromara.jpom.util.CommandUtil;
|
||||
import org.dromara.jpom.util.FileUtils;
|
||||
@ -55,7 +55,7 @@ import java.util.function.Function;
|
||||
/**
|
||||
* Jpom
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -53,7 +53,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* controller
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
@ -307,7 +307,7 @@ public abstract class BaseJpomController {
|
||||
*
|
||||
* @param name name
|
||||
* @return str
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
public String getSessionAttribute(String name) {
|
||||
return Objects.toString(getSessionAttributeObj(name), "");
|
||||
@ -327,7 +327,7 @@ public abstract class BaseJpomController {
|
||||
* 移除session 值
|
||||
*
|
||||
* @param name name
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
public void removeSessionAttribute(String name) {
|
||||
getRequestAttributes().removeAttribute(name, RequestAttributes.SCOPE_SESSION);
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
/**
|
||||
* 刷新缓存
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2023/3/20
|
||||
*/
|
||||
public interface ICacheTask {
|
||||
|
||||
/**
|
||||
* 刷新缓存
|
||||
*/
|
||||
void refreshCache();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
/**
|
||||
* 系统定时任务
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2023/2/19
|
||||
*/
|
||||
public interface ISystemTask {
|
||||
|
||||
/**
|
||||
* 执行
|
||||
*/
|
||||
void executeTask();
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2022/12/8
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface JpomAppType {
|
||||
|
||||
Type value();
|
||||
}
|
@ -33,6 +33,10 @@ import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import cn.keepbx.jpom.event.ICacheTask;
|
||||
import cn.keepbx.jpom.event.ISystemTask;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@ -73,7 +77,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* 启动 、关闭监听
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/7
|
||||
*/
|
||||
@Slf4j
|
||||
@ -117,7 +121,7 @@ public class JpomApplicationEvent implements ApplicationListener<ApplicationEven
|
||||
file = FileUtil.createTempFile("jpom", ".temp", file, true);
|
||||
} catch (Exception e) {
|
||||
log.error(StrUtil.format("Jpom Failed to create data directory, directory location:{}," +
|
||||
"Please check whether the current user has permission to this directory or modify the configuration file:{} jpom.path in is the path where the directory can be created", path, extConfigPath), e);
|
||||
"Please check whether the current user has permission to this directory or modify the configuration file:{} jpom.path in is the path where the directory can be created", path, extConfigPath), e);
|
||||
asyncExit(-1);
|
||||
}
|
||||
FileUtil.del(file);
|
||||
@ -333,6 +337,12 @@ public class JpomApplicationEvent implements ApplicationListener<ApplicationEven
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
//
|
||||
File file = FileUtil.file(JpomApplication.getInstance().getDataPath(), Const.REMOTE_VERSION);
|
||||
SystemUtil.set("JPOM_REMOTE_VERSION_CACHE_FILE", file.getAbsolutePath());
|
||||
SystemUtil.set("JPOM_IS_DEBUG", String.valueOf(JpomManifest.getInstance().isDebug()));
|
||||
SystemUtil.set("JPOM_TYPE", JpomManifest.getInstance().getType().name());
|
||||
SystemUtil.set("JPOM_VERSION", JpomManifest.getInstance().getVersion());
|
||||
// 检查目录权限
|
||||
this.checkPath();
|
||||
this.install();
|
||||
@ -341,15 +351,15 @@ public class JpomApplicationEvent implements ApplicationListener<ApplicationEven
|
||||
// 开始加载子模块
|
||||
Map<String, ILoadEvent> loadEventMap = applicationContext.getBeansOfType(ILoadEvent.class);
|
||||
loadEventMap.values()
|
||||
.stream()
|
||||
.sorted((o1, o2) -> CompareUtil.compare(o1.getOrder(), o2.getOrder()))
|
||||
.forEach(iLoadEvent -> {
|
||||
try {
|
||||
iLoadEvent.afterPropertiesSet(applicationContext);
|
||||
} catch (Exception e) {
|
||||
throw Lombok.sneakyThrow(e);
|
||||
}
|
||||
});
|
||||
.stream()
|
||||
.sorted((o1, o2) -> CompareUtil.compare(o1.getOrder(), o2.getOrder()))
|
||||
.forEach(iLoadEvent -> {
|
||||
try {
|
||||
iLoadEvent.afterPropertiesSet(applicationContext);
|
||||
} catch (Exception e) {
|
||||
throw Lombok.sneakyThrow(e);
|
||||
}
|
||||
});
|
||||
// 检查更新文件
|
||||
this.checkUpdate();
|
||||
// 开始异常加载
|
||||
|
@ -37,6 +37,7 @@ import cn.hutool.http.useragent.UserAgentInfo;
|
||||
import cn.hutool.system.JavaInfo;
|
||||
import cn.hutool.system.OsInfo;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
@ -61,7 +62,7 @@ import java.util.zip.ZipFile;
|
||||
/**
|
||||
* Jpom 的运行信息
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/7
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -23,6 +23,7 @@
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.keepbx.jpom.BaseJsonMessage;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONFactory;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
@ -30,26 +31,22 @@ import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
|
||||
import com.alibaba.fastjson2.writer.ObjectWriterProvider;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 通用的json 数据格式
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/2/6.
|
||||
* @since 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class JsonMessage<T> implements Serializable {
|
||||
public static final String CODE = "code";
|
||||
public static final String MSG = "msg";
|
||||
public static final String DATA = "data";
|
||||
|
||||
public static int DEFAULT_SUCCESS_CODE = 200;
|
||||
public class JsonMessage<T> extends BaseJsonMessage<T> {
|
||||
|
||||
static {
|
||||
ObjectWriterProvider writerProvider = JSONFactory.getDefaultObjectWriterProvider();
|
||||
@ -64,25 +61,15 @@ public class JsonMessage<T> implements Serializable {
|
||||
JSON.config(JSONWriter.Feature.WriteEnumsUsingName);
|
||||
}
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
|
||||
public JsonMessage(int code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
super(code, msg, data);
|
||||
}
|
||||
|
||||
public JsonMessage(int code, String msg) {
|
||||
this(code, msg, null);
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return this.code == DEFAULT_SUCCESS_CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将data 转换为对应实体
|
||||
*
|
||||
@ -96,7 +83,7 @@ public class JsonMessage<T> implements Serializable {
|
||||
|
||||
/**
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -120,7 +107,7 @@ public class JsonMessage<T> implements Serializable {
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
public static String getString(int code, String msg) {
|
||||
return getString(code, msg, null);
|
||||
@ -143,7 +130,7 @@ public class JsonMessage<T> implements Serializable {
|
||||
* @param msg msg
|
||||
* @param data data
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
*/
|
||||
public static String getString(int code, String msg, Object data) {
|
||||
return toJson(code, msg, data).toString();
|
||||
|
@ -22,28 +22,19 @@
|
||||
*/
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.model.BaseJsonModel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@ -64,206 +55,12 @@ import java.util.function.Consumer;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Slf4j
|
||||
public class RemoteVersion extends BaseJsonModel {
|
||||
public class RemoteVersion extends cn.keepbx.jpom.RemoteVersion {
|
||||
|
||||
/**
|
||||
* 主 url 用于拉取远程版本信息
|
||||
* <p>
|
||||
* 1. <a href="https://jpom.top/docs/release-versions.json">https://jpom.top/docs/release-versions.json</a>
|
||||
*/
|
||||
private static final String DEFAULT_URL = "https://jpom.top/docs/release-versions.json";
|
||||
private static final String BETA_URL = "https://jpom.top/docs/beta-versions.json";
|
||||
private static String remoteVersionUrl;
|
||||
/**
|
||||
* 检查间隔时间
|
||||
*/
|
||||
private static final int CHECK_INTERVAL = 24;
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
private String tagName;
|
||||
/**
|
||||
* 插件端下载地址
|
||||
*/
|
||||
private String agentUrl;
|
||||
/**
|
||||
* 服务端下载地址
|
||||
*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 更新日志 (远程url)
|
||||
*/
|
||||
private String changelogUrl;
|
||||
/**
|
||||
* 更新日志
|
||||
*/
|
||||
private String changelog;
|
||||
/**
|
||||
* 上次获取时间
|
||||
*/
|
||||
private Long lastTime;
|
||||
|
||||
/**
|
||||
* 是否有新版本
|
||||
*/
|
||||
private Boolean upgrade;
|
||||
/**
|
||||
* 是否为 beta 版本
|
||||
*/
|
||||
private Boolean beta;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
public static void setRemoteVersionUrl(String remoteVersionUrl) {
|
||||
RemoteVersion.remoteVersionUrl = remoteVersionUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 版本检查的 url
|
||||
*
|
||||
* @return 远程地址
|
||||
*/
|
||||
private static String loadDefaultUrl() {
|
||||
boolean beta = betaRelease();
|
||||
return beta ? BETA_URL : DEFAULT_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前是否加入 beta 计划
|
||||
*
|
||||
* @return true 已经加入 false 未加入
|
||||
*/
|
||||
public static boolean betaRelease() {
|
||||
String betaRelease = SystemPropsUtil.get("JOIN_JPOM_BETA_RELEASE", StrUtil.EMPTY);
|
||||
return Convert.toBool(betaRelease, false);
|
||||
}
|
||||
|
||||
public static void changeBetaRelease(String beta) {
|
||||
SystemPropsUtil.set("JOIN_JPOM_BETA_RELEASE", beta);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取远程最新版本
|
||||
*
|
||||
* @return 版本信息
|
||||
*/
|
||||
public static RemoteVersion loadRemoteInfo() {
|
||||
String body = StrUtil.EMPTY;
|
||||
try {
|
||||
String remoteVersionUrl = StrUtil.emptyToDefault(RemoteVersion.remoteVersionUrl, loadDefaultUrl());
|
||||
remoteVersionUrl = Validator.isUrl(remoteVersionUrl) ? remoteVersionUrl : loadDefaultUrl();
|
||||
// 获取缓存中到信息
|
||||
RemoteVersion remoteVersion = RemoteVersion.loadTransitUrl(remoteVersionUrl);
|
||||
if (remoteVersion == null || StrUtil.isEmpty(remoteVersion.getTagName())) {
|
||||
// 没有版本信息
|
||||
return null;
|
||||
}
|
||||
// 缓存信息
|
||||
RemoteVersion.cacheLoadTime(remoteVersion);
|
||||
return remoteVersion;
|
||||
} catch (Exception e) {
|
||||
log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第一层信息,用于中转
|
||||
*
|
||||
* @param remoteVersionUrl 请url
|
||||
* @return 中转URL
|
||||
*/
|
||||
private static RemoteVersion loadTransitUrl(String remoteVersionUrl) {
|
||||
String body = StrUtil.EMPTY;
|
||||
try {
|
||||
log.debug("use remote version url: {}", remoteVersionUrl);
|
||||
HttpRequest request = HttpUtil.createGet(remoteVersionUrl, true);
|
||||
request.timeout(10 * 1000);
|
||||
try (HttpResponse execute = request.execute()) {
|
||||
body = execute.body();
|
||||
}
|
||||
//
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
RemoteVersion remoteVersion = jsonObject.toJavaObject(RemoteVersion.class);
|
||||
if (StrUtil.isAllNotEmpty(remoteVersion.getTagName(), remoteVersion.getAgentUrl(), remoteVersion.getServerUrl(), remoteVersion.getServerUrl())) {
|
||||
return remoteVersion;
|
||||
}
|
||||
String jumpUrl = jsonObject.getString("url");
|
||||
if (StrUtil.isEmpty(jumpUrl)) {
|
||||
return null;
|
||||
}
|
||||
return loadTransitUrl(jumpUrl);
|
||||
} catch (Exception e) {
|
||||
log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存信息
|
||||
*
|
||||
* @param remoteVersion 远程版本信息
|
||||
*/
|
||||
private static void cacheLoadTime(RemoteVersion remoteVersion) {
|
||||
remoteVersion = ObjectUtil.defaultIfNull(remoteVersion, new RemoteVersion());
|
||||
remoteVersion.setLastTime(SystemClock.now());
|
||||
// 判断是否可以升级
|
||||
JpomManifest instance = JpomManifest.getInstance();
|
||||
if (!instance.isDebug()) {
|
||||
String version = instance.getVersion();
|
||||
String tagName = remoteVersion.getTagName();
|
||||
tagName = StrUtil.removePrefixIgnoreCase(tagName, "v");
|
||||
remoteVersion.setUpgrade(StrUtil.compareVersion(version, tagName) < 0);
|
||||
} else {
|
||||
remoteVersion.setUpgrade(false);
|
||||
}
|
||||
// 检查是否存在下载地址
|
||||
Type type = instance.getType();
|
||||
String remoteUrl = type.getRemoteUrl(remoteVersion);
|
||||
if (StrUtil.isEmpty(remoteUrl)) {
|
||||
remoteVersion.setUpgrade(false);
|
||||
}
|
||||
// 获取 changelog
|
||||
String changelogUrl = remoteVersion.getChangelogUrl();
|
||||
if (StrUtil.isNotEmpty(changelogUrl)) {
|
||||
try (HttpResponse execute = HttpUtil.createGet(changelogUrl, true).execute()) {
|
||||
String body = execute.body();
|
||||
remoteVersion.setChangelog(body);
|
||||
}
|
||||
}
|
||||
//
|
||||
FileUtil.writeUtf8String(remoteVersion.toString(), getFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前缓存中的 远程版本信息
|
||||
*
|
||||
* @return RemoteVersion
|
||||
*/
|
||||
public static RemoteVersion cacheInfo() {
|
||||
if (!FileUtil.isFile(getFile())) {
|
||||
return null;
|
||||
}
|
||||
RemoteVersion remoteVersion = null;
|
||||
String fileStr = StrUtil.EMPTY;
|
||||
try {
|
||||
fileStr = FileUtil.readUtf8String(getFile());
|
||||
if (StrUtil.isEmpty(fileStr)) {
|
||||
return null;
|
||||
}
|
||||
remoteVersion = JSONObject.parseObject(fileStr, RemoteVersion.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析远程版本信息失败:{} {}", e.getMessage(), fileStr);
|
||||
}
|
||||
// 判断上次获取时间
|
||||
Long lastTime = remoteVersion == null ? 0 : remoteVersion.getLastTime();
|
||||
lastTime = ObjectUtil.defaultIfNull(lastTime, 0L);
|
||||
long interval = SystemClock.now() - lastTime;
|
||||
return interval >= TimeUnit.HOURS.toMillis(CHECK_INTERVAL) ? null : remoteVersion;
|
||||
return JSONObject.toJSONString(cn.keepbx.jpom.RemoteVersion.cacheInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -276,7 +73,7 @@ public class RemoteVersion extends BaseJsonModel {
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
public static Tuple download(String savePath, Type type, boolean checkRepeat) throws IOException {
|
||||
RemoteVersion remoteVersion = loadRemoteInfo();
|
||||
cn.keepbx.jpom.RemoteVersion remoteVersion = loadRemoteInfo();
|
||||
Assert.notNull(remoteVersion, "没有可用的新版本升级:-1");
|
||||
// 检查是否存在下载地址
|
||||
String remoteUrl = type.getRemoteUrl(remoteVersion);
|
||||
@ -335,13 +132,4 @@ public class RemoteVersion extends BaseJsonModel {
|
||||
}
|
||||
JpomApplication.restart();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存的文件
|
||||
*
|
||||
* @return file
|
||||
*/
|
||||
private static File getFile() {
|
||||
return FileUtil.file(JpomApplication.getInstance().getDataPath(), Const.REMOTE_VERSION);
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.common;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Jpom 程序类型
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@Getter
|
||||
public enum Type {
|
||||
/**
|
||||
* 插件端
|
||||
*/
|
||||
Agent("org.dromara.jpom.JpomAgentApplication", RemoteVersion::getAgentUrl, "JPOM_AGENT_APPLICATION"),
|
||||
/**
|
||||
* 中心服务端
|
||||
*/
|
||||
Server("org.dromara.jpom.JpomServerApplication", RemoteVersion::getServerUrl, "JPOM_SERVER_APPLICATION"),
|
||||
;
|
||||
|
||||
private final Function<RemoteVersion, String> remoteUrl;
|
||||
private final String applicationClass;
|
||||
private final String tag;
|
||||
|
||||
Type(String applicationClass, Function<RemoteVersion, String> remoteUrl, String tag) {
|
||||
this.applicationClass = applicationClass;
|
||||
this.remoteUrl = remoteUrl;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getRemoteUrl(RemoteVersion remoteVersion) {
|
||||
return remoteUrl.apply(remoteVersion);
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ import java.util.*;
|
||||
/**
|
||||
* 文件上传builder
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/10/23
|
||||
*/
|
||||
public class MultipartFileBuilder {
|
||||
|
@ -28,7 +28,7 @@ import cn.hutool.system.UserInfo;
|
||||
/**
|
||||
* 上传文件保存路径
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/10/25
|
||||
*/
|
||||
public class MultipartFileConfig {
|
||||
|
@ -25,7 +25,7 @@ package org.dromara.jpom.common.validator;
|
||||
/**
|
||||
* 错误条件
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/12/25
|
||||
*/
|
||||
public enum ErrorCondition {
|
||||
|
@ -48,7 +48,7 @@ import java.lang.reflect.Method;
|
||||
* <p>
|
||||
* 配置方法
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/8/21.
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -29,7 +29,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 字段验证配置
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/8/21.
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
|
@ -27,7 +27,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 验证规则
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/8/21
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
|
@ -25,7 +25,7 @@ package org.dromara.jpom.common.validator;
|
||||
/**
|
||||
* 验证规则
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/8/21.
|
||||
*/
|
||||
public enum ValidatorRule {
|
||||
@ -68,13 +68,13 @@ public enum ValidatorRule {
|
||||
/**
|
||||
* 小数
|
||||
*
|
||||
* @see ParameterInterceptor#validatorNumber(cn.jiangzeyin.common.validator.ValidatorItem, String)
|
||||
* @see ParameterInterceptor#validatorNumber(cn.bwcx_jzy.common.validator.ValidatorItem, String)
|
||||
*/
|
||||
DECIMAL,
|
||||
/**
|
||||
* 数字
|
||||
*
|
||||
* @see ParameterInterceptor#validatorNumber(cn.jiangzeyin.common.validator.ValidatorItem, String)
|
||||
* @see ParameterInterceptor#validatorNumber(cn.bwcx_jzy.common.validator.ValidatorItem, String)
|
||||
*/
|
||||
NUMBERS,
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* 基础枚举接口
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/19
|
||||
*/
|
||||
public interface BaseEnum {
|
||||
|
@ -28,7 +28,7 @@ import lombok.EqualsAndHashCode;
|
||||
/**
|
||||
* 基础实体(带id)
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2022/01/24
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -30,7 +30,7 @@ import java.io.Serializable;
|
||||
/**
|
||||
* json方法基础类
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/10
|
||||
*/
|
||||
public abstract class BaseJsonModel implements Serializable {
|
||||
|
@ -28,7 +28,7 @@ import lombok.EqualsAndHashCode;
|
||||
/**
|
||||
* 基础实体(带id)
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/14
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
@ -25,7 +25,7 @@ package org.dromara.jpom.model;
|
||||
/**
|
||||
* 项目的运行方式
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/22
|
||||
*/
|
||||
public enum RunMode {
|
||||
|
@ -47,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 白名单
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -27,7 +27,7 @@ import org.dromara.jpom.model.BaseJsonModel;
|
||||
/**
|
||||
* agent 端自动生成的密码实体
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/18
|
||||
*/
|
||||
public class AgentAutoUser extends BaseJsonModel {
|
||||
|
@ -27,9 +27,9 @@ import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.keepbx.jpom.log.ILogRecorder;
|
||||
import org.dromara.jpom.JpomApplication;
|
||||
import org.dromara.jpom.common.Const;
|
||||
import org.dromara.jpom.util.ILogRecorder;
|
||||
import org.dromara.jpom.util.LogRecorder;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -25,7 +25,7 @@ package org.dromara.jpom.socket;
|
||||
/**
|
||||
* 控制台socket 操作枚举
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public enum ConsoleCommandOp {
|
||||
|
@ -27,7 +27,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
/**
|
||||
* 日志接口
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/19
|
||||
*/
|
||||
public interface AopLogInterface {
|
||||
|
@ -52,7 +52,7 @@ import java.util.function.Function;
|
||||
/**
|
||||
* 外部资源配置
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -27,7 +27,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
/**
|
||||
* Jpom 运行错误
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public class JpomRuntimeException extends RuntimeException {
|
||||
|
@ -39,7 +39,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* 自动记录日志
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/5/11
|
||||
*/
|
||||
@Aspect
|
||||
|
@ -43,7 +43,7 @@ import java.util.function.BiConsumer;
|
||||
/**
|
||||
* 命令行工具
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/15
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -47,7 +47,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 文件工具
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/28
|
||||
*/
|
||||
public class FileUtils {
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.util;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2023/2/11
|
||||
*/
|
||||
public interface ILogRecorder {
|
||||
|
||||
/**
|
||||
* 记录单行日志
|
||||
*
|
||||
* @param info 日志
|
||||
* @param vals 变量参数
|
||||
* @return 格式化后的字符串
|
||||
*/
|
||||
String info(String info, Object... vals);
|
||||
|
||||
/**
|
||||
* 记录单行日志
|
||||
*
|
||||
* @param info 日志
|
||||
* @param vals 变量参数
|
||||
* @return 格式化后的字符串
|
||||
*/
|
||||
String system(String info, Object... vals);
|
||||
|
||||
/**
|
||||
* 记录单行日志
|
||||
*
|
||||
* @param info 日志
|
||||
* @param vals 变量参数
|
||||
* @return 格式化后的字符串
|
||||
*/
|
||||
String systemError(String info, Object... vals);
|
||||
|
||||
/**
|
||||
* 记录单行日志
|
||||
*
|
||||
* @param info 日志
|
||||
* @param vals 变量参数
|
||||
* @return 格式化后的字符串
|
||||
*/
|
||||
String systemWarning(String info, Object... vals);
|
||||
}
|
@ -38,7 +38,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
/**
|
||||
* json 文件读写工具
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/5/15
|
||||
*/
|
||||
public class JsonFileUtil {
|
||||
|
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* jvm jmx 工具
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/13
|
||||
*/
|
||||
public class JvmUtil {
|
||||
|
@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
/**
|
||||
* 定长队列
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/16
|
||||
*/
|
||||
public class LimitQueue<E> extends ConcurrentLinkedDeque<E> {
|
||||
|
@ -29,6 +29,7 @@ import cn.hutool.core.io.file.FileWriter;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.keepbx.jpom.log.ILogRecorder;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* main 方法运行参数工具
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @see SimpleCommandLinePropertySource
|
||||
* @since 2019/4/7
|
||||
*/
|
||||
|
@ -27,9 +27,9 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.keepbx.jpom.JpomAppType;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.common.JpomAppType;
|
||||
import org.dromara.jpom.common.Type;
|
||||
import org.dromara.jpom.model.data.SystemIpConfigModel;
|
||||
import org.dromara.jpom.service.system.SystemParametersServer;
|
||||
import org.dromara.jpom.service.user.UserService;
|
||||
@ -41,7 +41,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
/**
|
||||
* jpom 启动类
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/9/14
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = {"org.dromara.jpom"})
|
||||
|
@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* Jpom server 端
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
public abstract class BaseServerController extends BaseJpomController {
|
||||
|
@ -33,7 +33,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
/**
|
||||
* 全局异常处理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/04/17
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
|
@ -77,7 +77,7 @@ import java.util.function.Function;
|
||||
/**
|
||||
* 节点请求转发
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -27,7 +27,7 @@ import lombok.Getter;
|
||||
/**
|
||||
* agent 端的请求地址枚举
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@Getter
|
||||
|
@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 登录拦截器
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/2/4.
|
||||
*/
|
||||
@Configuration
|
||||
|
@ -27,7 +27,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 游客可以访问的Controller 标记
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2017/5/9.
|
||||
*/
|
||||
@Documented
|
||||
|
@ -49,7 +49,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* 权限拦截器
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/03/16.
|
||||
*/
|
||||
@Configuration
|
||||
|
@ -50,7 +50,7 @@ import java.util.List;
|
||||
/**
|
||||
* 初始化程序
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/2/22
|
||||
*/
|
||||
@RestController
|
||||
|
@ -55,7 +55,7 @@ import java.util.List;
|
||||
/**
|
||||
* 节点管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@RestController
|
||||
|
@ -50,7 +50,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 节点管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/16
|
||||
*/
|
||||
@RestController
|
||||
|
@ -27,6 +27,7 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.keepbx.jpom.Type;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -104,7 +105,7 @@ public class NodeUpdateController extends BaseServerController {
|
||||
*/
|
||||
@GetMapping(value = "check_version.json", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public JsonMessage<JSONObject> checkVersion() {
|
||||
RemoteVersion remoteVersion = RemoteVersion.cacheInfo();
|
||||
cn.keepbx.jpom.RemoteVersion remoteVersion = RemoteVersion.cacheInfo();
|
||||
AgentFileModel agentFileModel = systemParametersServer.getConfig(AgentFileModel.ID, AgentFileModel.class, agentFileModel1 -> {
|
||||
if (agentFileModel1 == null || !FileUtil.exist(agentFileModel1.getSavePath())) {
|
||||
return null;
|
||||
|
@ -46,7 +46,7 @@ import java.util.List;
|
||||
/**
|
||||
* 项目管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2018/9/29
|
||||
*/
|
||||
@RestController
|
||||
|
@ -44,7 +44,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* 控制台日志备份管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/3/7
|
||||
*/
|
||||
@Controller
|
||||
|
@ -47,7 +47,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 脚本管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/24
|
||||
*/
|
||||
@RestController
|
||||
|
@ -48,7 +48,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 白名单目录
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/2/28
|
||||
*/
|
||||
@RestController
|
||||
|
@ -64,7 +64,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 分发控制
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/20
|
||||
*/
|
||||
@RestController
|
||||
|
@ -74,7 +74,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 分发文件管理
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/21
|
||||
*/
|
||||
@RestController
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user