This commit is contained in:
bwcx_jzy 2022-12-08 19:37:11 +08:00
parent a7da8f839d
commit a219d7f60c
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
37 changed files with 340 additions and 2999 deletions

View File

@ -1,4 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

View File

@ -1,77 +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.
*/
///*
// * 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 io.jpom.common;
//
//import cn.jiangzeyin.common.interceptor.DefaultHandlerMethodArgumentResolver;
//
///**
// * 解析 参数 url 编码
// *
// * @author bwcx_jzy
// * @since 2021/10/25
// */
//public class UrlDecodeHandlerMethodArgumentResolver extends DefaultHandlerMethodArgumentResolver {
//
//// @Override
//// public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
//// Object argument = super.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
//// if (argument instanceof String) {
//// // 解码
//// return URLUtil.decode(argument.toString());
//// } else if (argument instanceof BaseJsonModel) {
//// // 解码对象属性
//// Field[] fields = ReflectUtil.getFields(argument.getClass());
//// for (Field field : fields) {
//// Class<?> type = field.getType();
//// if (type == String.class) {
//// String fieldValue = (String) ReflectUtil.getFieldValue(argument, field);
//// fieldValue = URLUtil.decode(fieldValue);
//// ReflectUtil.setFieldValue(argument, field, fieldValue);
//// }
//// }
//// }
//// return argument;
//// }
//}

View File

@ -1,148 +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.
*/
///*
// * 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 io.jpom.common.commander;
//
//import cn.hutool.core.thread.ThreadUtil;
//import cn.hutool.http.HttpRequest;
//import cn.hutool.http.HttpResponse;
//import cn.hutool.system.SystemUtil;
//import io.jpom.common.commander.impl.LinuxTomcatCommander;
//import io.jpom.common.commander.impl.WindowsTomcatCommander;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.system.JpomRuntimeException;
//import lombok.extern.slf4j.Slf4j;
//
//import java.io.IOException;
//import java.util.concurrent.TimeUnit;
//
///**
// * tomcat命令执行工具类
// *
// * @author LF
// */
//@Slf4j
//public abstract class AbstractTomcatCommander {
//
// private static AbstractTomcatCommander abstractTomcatCommander;
//
// public static AbstractTomcatCommander getInstance() {
// if (abstractTomcatCommander != null) {
// return abstractTomcatCommander;
// }
// if (SystemUtil.getOsInfo().isLinux()) {
// // Linux系统
// abstractTomcatCommander = new LinuxTomcatCommander();
// } else if (SystemUtil.getOsInfo().isWindows()) {
// // Windows系统
// abstractTomcatCommander = new WindowsTomcatCommander();
// } else if (SystemUtil.getOsInfo().isMac()) {
// abstractTomcatCommander = new LinuxTomcatCommander();
// } else {
// throw new JpomRuntimeException("不支持的:" + SystemUtil.getOsInfo().getName());
// }
// return abstractTomcatCommander;
// }
//
// /**
// * 执行tomcat命令
// *
// * @param tomcatInfoModel tomcat信息
// * @param cmd 执行的命令包括start stop
// * @return 返回tomcat启动结果
// */
// public abstract String execCmd(TomcatInfoModel tomcatInfoModel, String cmd);
//
// /**
// * 检查tomcat状态
// *
// * @param tomcatInfoModel tomcat信息
// * @param cmd 操作命令
// * @return 状态结果
// */
// protected String getStatus(TomcatInfoModel tomcatInfoModel, String cmd) {
// String strReturn = "start".equals(cmd) ? "stopped" : "started";
// int i = 0;
// while (i < 10) {
// int result = 0;
// String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
// HttpRequest httpRequest = new HttpRequest(url);
// // 设置超时时间为3秒
// httpRequest.setConnectionTimeout(3000);
// try (HttpResponse response = httpRequest.execute()) {
// result = 1;
// } catch (Exception ignored) {
// }
//
// i++;
// if ("start".equals(cmd) && result == 1) {
// strReturn = "started";
// break;
// }
// if ("stop".equals(cmd) && result == 0) {
// strReturn = "stopped";
// break;
// }
// ThreadUtil.sleep(1000);
// }
// return strReturn;
// }
//
// protected void exec(String command, boolean close) {
// log.info(command);
// try {
// // 执行命令
// Process process = Runtime.getRuntime().exec(command);
// process.getInputStream().close();
// process.getErrorStream().close();
// process.getOutputStream().close();
// process.waitFor(5, TimeUnit.SECONDS);
// if (close) {
// process.destroy();
// }
// } catch (IOException | InterruptedException e) {
// log.error("tomcat执行名称失败", e);
// }
// }
//}

View File

@ -1,102 +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.
*/
///*
// * 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 io.jpom.common.commander.impl;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.text.StrSplitter;
//import cn.hutool.core.util.NumberUtil;
//import cn.hutool.core.util.StrUtil;
//import io.jpom.common.commander.AbstractTomcatCommander;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.util.CommandUtil;
//
//import java.util.List;
//
///**
// * tomcat的linux管理命令
// *
// * @author LF
// */
//public class LinuxTomcatCommander extends AbstractTomcatCommander {
//
// @Override
// public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
// String tomcatPath = tomcatInfoModel.pathAndCheck();
// if (StrUtil.isBlank(tomcatPath)) {
// return "tomcat path blank";
// }
// String command = null;
// if ("stop".equals(cmd)) {
// String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
// List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
// for (String item : list) {
// //路径格式转换
// String msg = FileUtil.normalize(item + StrUtil.SLASH);
// //判断集合中元素是否包含指定Tomcat路径
// boolean w = msg.contains(tomcatInfoModel.getPath());
// if (w) {
// //截取TomcatPid
// if (msg.indexOf(" ") > 1) {
// String tmPid = msg.substring(0, msg.indexOf(" "));
// //判断截取的PID是否为纯数字
// if (NumberUtil.isInteger(tmPid)) {
// command = String.format("kill -9 %s", tmPid);
// exec(command, false);
// }
// }
// }
// }
// } else {
// command = String.format("/bin/sh -c %s/bin/startup.sh", tomcatPath);
// //
// exec(command, false);
// }
// if (StrUtil.isBlank(tomcatPath)) {
// return "tomcat path blank";
// }
// // 查询操作结果并返回
// return getStatus(tomcatInfoModel, cmd);
// }
//}

View File

@ -1,112 +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.
*/
///*
// * 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 io.jpom.common.commander.impl;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.text.StrSplitter;
//import cn.hutool.core.util.NumberUtil;
//import cn.hutool.core.util.StrUtil;
//import io.jpom.common.commander.AbstractTomcatCommander;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.util.CommandUtil;
//
//import java.util.List;
//
///**
// * tomcat的Windows管理命令
// *
// * @author LF
// */
//public class WindowsTomcatCommander extends AbstractTomcatCommander {
//
// /**
// * windows下执行tomcat命令
// *
// * @param tomcatInfoModel tomcat信息
// * @param cmd 执行的命令包括start stop
// * @return 返回tomcat启动结果
// */
// @Override
// public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
// String tomcatPath = tomcatInfoModel.pathAndCheck();
// //截取盘符
// String dcPath = null;
// if (tomcatPath != null && tomcatPath.indexOf(StrUtil.SLASH) > 1) {
// dcPath = tomcatPath.substring(0, tomcatPath.indexOf(StrUtil.SLASH));
// }
// String command = null;
// if (StrUtil.isBlank(tomcatPath)) {
// return "tomcat path blank";
// }
//
// if ("stop".equals(cmd)) {
// String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
// List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
// for (String item : list) {
// //window下路径格式转换
// String msg = FileUtil.normalize(item + StrUtil.SLASH);
// //判断集合中元素是否包含指定Tomcat路径
// boolean w = msg.contains(tomcatInfoModel.getPath());
// if (w) {
// //截取TomcatPid
// if (msg.indexOf(" ") > 1) {
// String tmPid = msg.substring(0, msg.indexOf(" "));
// //判断截取的PID是否为纯数字
// if (NumberUtil.isInteger(tmPid)) {
// command = String.format("taskkill /F /PID %s", tmPid);
// exec(command, true);
// }
// }
// }
// }
// } else {
// command = String.format("cmd /k %s && cd %s/bin && start startup.bat", dcPath, tomcatPath);
// exec(command, true);
// }
//
// // 查询操作结果并返回
// return getStatus(tomcatInfoModel, cmd);
// }
//}

View File

@ -1,121 +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.
*/
///*
// * 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 io.jpom.controller.manage;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.util.IdUtil;
//import cn.hutool.core.util.StrUtil;
//import io.jpom.common.JsonMessage;
//import io.jpom.common.BaseAgentController;
//import io.jpom.model.data.JdkInfoModel;
//import io.jpom.service.manage.JdkInfoService;
//import io.jpom.util.FileUtils;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.io.File;
//import java.util.List;
//
///**
// * @author bwcx_jzy
// * @since 2019/11/1
// */
//@RestController
//@RequestMapping(value = "/manage/jdk/")
//public class JdkListController extends BaseAgentController {
//
// @Resource
// private JdkInfoService jdkInfoService;
//
// @RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String list() {
// List<JdkInfoModel> list = jdkInfoService.list();
// return JsonMessage.getString(200, "", list);
// }
//
// @RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String update(JdkInfoModel model) {
// String path = model.getPath();
// if (StrUtil.isEmpty(path)) {
// return JsonMessage.getString(400, "请填写jdk路径");
// }
// String newPath = FileUtil.normalize(path);
// File file = FileUtil.file(newPath);
// //去除bin
// if ("bin".equals(file.getName())) {
// newPath = file.getParentFile().getAbsolutePath();
// }
// if (!FileUtils.isJdkPath(newPath)) {
// return JsonMessage.getString(400, "路径错误该路径不是jdk路径");
// }
// model.setPath(newPath);
// String id = model.getId();
// String jdkVersion = FileUtils.getJdkVersion(newPath);
// model.setVersion(jdkVersion);
// String name = model.getName();
// if (StrUtil.isEmpty(name)) {
// model.setName(jdkVersion);
// }
// if (StrUtil.isEmpty(id)) {
// model.setId(IdUtil.fastSimpleUUID());
// jdkInfoService.addItem(model);
// return JsonMessage.getString(200, "添加成功");
// }
// jdkInfoService.updateItem(model);
// return JsonMessage.getString(200, "修改成功");
// }
//
// @RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String delete(String id) {
// if (StrUtil.isEmpty(id)) {
// return JsonMessage.getString(400, "删除失败");
// }
// jdkInfoService.deleteItem(id);
// return JsonMessage.getString(200, "删除成功");
// }
//}

View File

@ -1,274 +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.
*/
///*
// * 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 io.jpom.controller.monitor;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.extra.servlet.ServletUtil;
//import io.jpom.common.JsonMessage;
//import com.alibaba.fastjson.JSONObject;
//import io.jpom.common.BaseAgentController;
//import io.jpom.common.commander.AbstractProjectCommander;
//import io.jpom.common.commander.AbstractSystemCommander;
//import io.jpom.model.data.NodeProjectInfoModel;
//import io.jpom.model.system.NetstatModel;
//import io.jpom.model.system.ProcessModel;
//import io.jpom.system.AgentConfigBean;
//import io.jpom.util.CommandUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.util.List;
//
///**
// * 内存查看
// *
// * @author Administrator
// */
//@RestController
//@RequestMapping(value = "/manage/")
//@Slf4j
//public class InternalController extends BaseAgentController {
//
// /**
// * 获取内存信息
// *
// * @param tag 程序运行标识
// * @return json
// * @throws Exception 异常
// */
// @RequestMapping(value = "internal_data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getInternal(String tag, String copyId) throws Exception {
// String tagId = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
// int pid = AbstractProjectCommander.getInstance().getPid(tagId);
// if (pid <= 0) {
// return JsonMessage.getString(400, "");
// }
// JSONObject jsonObject = new JSONObject();
// ProcessModel item = AbstractSystemCommander.getInstance().getPidInfo(pid);
// jsonObject.put("process", item);
// //JSONObject beanMem = getBeanMem(tagId);
// //jsonObject.put("beanMem", beanMem);
// //获取端口信息
// List<NetstatModel> netstatModels = AbstractProjectCommander.getInstance().listNetstat(pid, false);
// jsonObject.put("netstat", netstatModels);
// return JsonMessage.getString(200, "", jsonObject);
//// return JsonMessage.getString(404, "功能已经下架");
// }
//
// /**
// * 查询监控线程列表
// *
// * @param tag 程序运行标识
// * @return json
// * @throws Exception 异常
// */
// @RequestMapping(value = "threadInfos", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getThreadInfos(String tag, String copyId) throws Exception {
//// int limit = getParameterInt("limit", 10);
//// int page = getParameterInt("page", 1);
////
//// ThreadMXBean bean = JvmUtil.getThreadMXBean(ProjectInfoModel.JavaCopyItem.getTagId(tag, copyId));
//// if (bean == null) {
//// return JsonMessage.getString(400, "未获取到对应信息");
//// }
//// //启用线程争用监视
//// bean.setThreadContentionMonitoringEnabled(true);
//// ThreadInfo[] threadInfos = bean.dumpAllThreads(false, false);
//// if (threadInfos == null || threadInfos.length <= 0) {
//// return JsonMessage.getString(404, "没有获取到任何线程");
//// }
////
//// JSONArray array = new JSONArray();
//// int index = PageUtil.getStart(page, limit);
//// int len = limit + index;
//// int length = threadInfos.length;
//// if (len > length) {
//// len = length;
//// }
//// for (int i = index; i < len; i++) {
//// ThreadInfo threadInfo = threadInfos[i];
//// Thread.State threadState = threadInfo.getThreadState();
//// JSONObject object = new JSONObject();
//// object.put("id", threadInfo.getThreadId());
//// object.put("name", threadInfo.getThreadName());
//// object.put("status", threadState);
//// object.put("waitedCount", threadInfo.getWaitedCount());
//// object.put("waitedTime", threadInfo.getWaitedTime());
//// object.put("blockedCount", threadInfo.getBlockedCount());
//// object.put("blockedTime", threadInfo.getBlockedTime());
//// object.put("isInNative", threadInfo.isInNative());
//// object.put("isSuspended", threadInfo.isSuspended());
//// array.add(object);
//// }
//// JSONObject object = new JSONObject();
//// object.put("count", length);
//// object.put("data", array);
//// return JsonMessage.getString(200, "", object);
// return JsonMessage.getString(404, "功能已经下架");
// }
//
//// /**
//// * 获取jvm内存
//// *
//// * @param tag tag
//// * @return JSONObject
//// */
//// private JSONObject getBeanMem(String tag) {
//// try {
//// MemoryMXBean bean = JvmUtil.getMemoryMXBean(tag);
//// if (bean == null) {
//// return null;
//// }
//// JSONObject jsonObject = new JSONObject();
//// jsonObject.put("mount", bean.getObjectPendingFinalizationCount());
//// //堆内存
//// MemoryUsage memory = bean.getHeapMemoryUsage();
//// //非堆内存
//// MemoryUsage nonHeapMemoryUsage = bean.getNonHeapMemoryUsage();
//// long used = memory.getUsed();
//// long max = memory.getMax();
//// //未定义
//// if (-1 == max) {
//// max = memory.getCommitted();
//// }
//// //计算使用内存占最大内存的百分比
//// double v = new BigDecimal(used).divide(new BigDecimal(max), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
//// jsonObject.put("heapUsed", FileUtil.readableFileSize(used));
//// jsonObject.put("heapProportion", String.format("%.2f", v) + "%");
//// jsonObject.put("heapCommitted", FileUtil.readableFileSize(memory.getCommitted()));
//// long nonUsed = nonHeapMemoryUsage.getUsed();
//// long nonMax = nonHeapMemoryUsage.getMax();
//// long nonCommitted = nonHeapMemoryUsage.getCommitted();
//// if (-1 == nonMax) {
//// nonMax = nonCommitted;
//// }
//// jsonObject.put("nonHeapUsed", FileUtil.readableFileSize(nonUsed));
//// double proportion = new BigDecimal(nonUsed).divide(new BigDecimal(nonMax), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
//// jsonObject.put("nonHeapProportion", String.format("%.2f", proportion) + "%");
//// jsonObject.put("nonHeapCommitted", FileUtil.readableFileSize(nonCommitted));
//// return jsonObject;
//// } catch (Exception e) {
//// log.error(e.getMessage(), e);
//// }
//// return null;
//// }
//
//
// /**
// * 导出堆栈信息
// *
// * @param tag 程序运行标识
// * @return json
// */
// @RequestMapping(value = "internal_stack", method = RequestMethod.GET)
// @ResponseBody
// public String stack(String tag, String copyId) {
// tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
// //
// String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_cpu.txt";
// fileName = FileUtil.normalize(fileName);
// try {
// int pid = AbstractProjectCommander.getInstance().getPid(tag);
// if (pid <= 0) {
// return JsonMessage.getString(400, "未运行");
// }
// String command = String.format("jstack -F %s >> %s ", pid, fileName);
// CommandUtil.execSystemCommand(command);
// downLoad(getResponse(), fileName);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
//// getResponse().sendRedirect("internal?tag=" + tag);
// }
// return JsonMessage.getString(200, "");
// }
//
// /**
// * 导出内存信息
// *
// * @param tag 程序运行标识
// * @return json
// */
// @RequestMapping(value = "internal_ram", method = RequestMethod.GET)
// @ResponseBody
// public String ram(String tag, String copyId) {
// tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
// //
// String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_ram.txt";
// fileName = FileUtil.normalize(fileName);
// try {
// int pid = AbstractProjectCommander.getInstance().getPid(tag);
// if (pid <= 0) {
// return JsonMessage.getString(400, "未运行");
// }
// String command = String.format("jmap -histo:live %s >> %s", pid, fileName);
// CommandUtil.execSystemCommand(command);
// downLoad(getResponse(), fileName);
// } catch (Exception e) {
// log.error(e.getMessage(), e);
//// getResponse().sendRedirect("internal?tag=" + tag);
// }
// return JsonMessage.getString(200, "");
// }
//
// /**
// * 下载文件
// *
// * @param response response
// * @param fileName 文件名字
// */
// private void downLoad(HttpServletResponse response, String fileName) {
// //获取项目根路径
// File file = new File(fileName);
// ServletUtil.write(response, file);
// FileUtil.del(file);
// }
//}

View File

@ -40,6 +40,7 @@ import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@ -59,44 +60,45 @@ import java.nio.charset.StandardCharsets;
@Slf4j
public class SystemConfigController extends BaseAgentController {
@RequestMapping(value = "getConfig.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String config() throws IOException {
Resource resource = ExtConfigBean.getResource();
String content = IoUtil.read(resource.getInputStream(), CharsetUtil.CHARSET_UTF_8);
JSONObject json = new JSONObject();
json.put("content", content);
json.put("file", FileUtil.getAbsolutePath(resource.getFile()));
return JsonMessage.getString(200, "ok", json);
}
@RequestMapping(value = "getConfig.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String config() throws IOException {
Resource resource = ExtConfigBean.getResource();
String content = IoUtil.read(resource.getInputStream(), CharsetUtil.CHARSET_UTF_8);
JSONObject json = new JSONObject();
json.put("content", content);
json.put("file", FileUtil.getAbsolutePath(resource.getFile()));
return JsonMessage.getString(200, "ok", json);
}
@RequestMapping(value = "save_config.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String saveConfig(String content, String restart) {
if (StrUtil.isEmpty(content)) {
return JsonMessage.getString(405, "内容不能为空");
}
try {
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
// @author hjk 前端编辑器允许使用tab键并设定为2个空格再转换为yml时要把tab键换成2个空格
ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8));
yamlPropertySourceLoader.load("test", resource);
} catch (Exception e) {
log.warn("内容格式错误,请检查修正", e);
return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage());
}
if (JpomManifest.getInstance().isDebug()) {
return JsonMessage.getString(405, "调试模式下不支持在线修改,请到resources目录下的bin目录修改extConfig.yml");
}
File resourceFile = ExtConfigBean.getResourceFile();
FileUtil.writeString(content, resourceFile, CharsetUtil.CHARSET_UTF_8);
@RequestMapping(value = "save_config.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String saveConfig(String content, String restart) throws IOException {
if (StrUtil.isEmpty(content)) {
return JsonMessage.getString(405, "内容不能为空");
}
try {
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
// @author hjk 前端编辑器允许使用tab键并设定为2个空格再转换为yml时要把tab键换成2个空格
ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8));
yamlPropertySourceLoader.load("test", resource);
} catch (Exception e) {
log.warn("内容格式错误,请检查修正", e);
return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage());
}
if (JpomManifest.getInstance().isDebug()) {
return JsonMessage.getString(405, "调试模式下不支持在线修改,请到resources目录下的bin目录修改extConfig.yml");
}
Resource resource = ExtConfigBean.getResource();
Assert.state(resource.isFile(), "当前环境下不支持在线修改配置文件");
FileUtil.writeString(content, resource.getFile(), CharsetUtil.CHARSET_UTF_8);
if (Convert.toBool(restart, false)) {
// 重启
ThreadUtil.execute(() -> {
ThreadUtil.sleep(2000);
JpomApplication.restart();
});
return JsonMessage.getString(200, Const.UPGRADE_MSG);
}
return JsonMessage.getString(200, "修改成功");
}
if (Convert.toBool(restart, false)) {
// 重启
ThreadUtil.execute(() -> {
ThreadUtil.sleep(2000);
JpomApplication.restart();
});
return JsonMessage.getString(200, Const.UPGRADE_MSG);
}
return JsonMessage.getString(200, "修改成功");
}
}

View File

@ -1,164 +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.
*/
///*
// * 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 io.jpom.controller.tomcat;
//
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.crypto.SecureUtil;
//import io.jpom.common.JsonMessage;
//import io.jpom.common.BaseAgentController;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.service.manage.TomcatEditService;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * tomcat 编辑
// *
// * @author bwcx_jzy
// * @since 2019/7/21
// */
//@RestController
//@RequestMapping(value = "/tomcat/")
//public class TomcatEditController extends BaseAgentController {
// @Resource
// private TomcatEditService tomcatEditService;
//
//
// /**
// * 列出所有的tomcat
// *
// * @return Tomcat列表
// */
// @RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String list() {
// // 查询tomcat列表
// List<TomcatInfoModel> tomcatInfoModels = tomcatEditService.list();
// return JsonMessage.getString(200, "查询成功", tomcatInfoModels);
// }
//
// /**
// * 根据Id查询Tomcat信息
// *
// * @param id Tomcat的主键
// * @return 操作结果
// */
// @RequestMapping(value = "getItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getItem(String id) {
// // 查询tomcat列表
// return JsonMessage.getString(200, "查询成功", tomcatEditService.getItem(id));
// }
//
//
// /**
// * 添加Tomcat
// *
// * @param tomcatInfoModel Tomcat信息
// * @return 操作结果
// */
// @RequestMapping(value = "add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String add(TomcatInfoModel tomcatInfoModel) {
// // 根据Tomcat名称查询tomcat是否已经存在
// String name = tomcatInfoModel.getName();
// TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
// if (tomcatInfoModelTemp != null) {
// return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
// }
// tomcatInfoModel.setId(SecureUtil.md5(DateUtil.now()));
// tomcatInfoModel.setCreator(getUserName());
//
// // 设置tomcat路径去除多余的符号
// tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
// Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
// tomcatEditService.addItem(tomcatInfoModel);
// tomcatInfoModel.initTomcat();
// return JsonMessage.getString(200, "保存成功");
// }
//
//
// /**
// * 修改Tomcat信息
// *
// * @param tomcatInfoModel Tomcat信息
// * @return 操作结果
// */
// @RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String update(TomcatInfoModel tomcatInfoModel) {
// // 根据Tomcat名称查询tomcat是否已经存在
// String name = tomcatInfoModel.getName();
// TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
// if (tomcatInfoModelTemp != null && !tomcatInfoModelTemp.getId().equals(tomcatInfoModel.getId())) {
// return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
// }
//
// tomcatInfoModel.setModifyUser(getUserName());
// // 设置tomcat路径去除多余的符号
// tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
// Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
// tomcatEditService.updateItem(tomcatInfoModel);
// tomcatInfoModel.initTomcat();
// return JsonMessage.getString(200, "修改成功");
//
// }
//
//
// /**
// * 删除tomcat
// *
// * @param id tomcat id
// * @return 操作结果
// */
// @RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String delete(String id) {
// tomcatEditService.deleteItem(id);
// return JsonMessage.getString(200, "删除成功");
// }
//}

View File

@ -1,382 +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.
*/
///*
// * 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 io.jpom.controller.tomcat;
//
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.extra.servlet.ServletUtil;
//import io.jpom.common.JsonMessage;
//
//
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import io.jpom.common.BaseAgentController;
//import io.jpom.common.commander.AbstractTomcatCommander;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.service.manage.TomcatEditService;
//import io.jpom.service.manage.TomcatManageService;
//import io.jpom.socket.AgentFileTailWatcher;
//import io.jpom.util.LayuiTreeUtil;
//import io.jpom.util.StringUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.io.File;
//import java.io.IOException;
//import java.util.concurrent.TimeUnit;
//
///**
// * @author lf
// */
//@RestController
//@RequestMapping(value = "/tomcat/")
//@Slf4j
//public class TomcatManageController extends BaseAgentController {
//
// @Resource
// private TomcatEditService tomcatEditService;
// @Resource
// private TomcatManageService tomcatManageService;
//
// /**
// * 列出所有的tomcat项目列表
// *
// * @param id 项目id
// * @return Tomcat下的项目列表
// */
// @RequestMapping(value = "getTomcatProjectList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getTomcatProjectList(String id) {
// JSONArray array = tomcatManageService.getTomcatProjectList(id);
// return JsonMessage.getString(200, "查询成功", array);
// }
//
// /**
// * 查询tomcat状态
// *
// * @param id tomcat的id
// * @return tomcat运行状态
// */
// @RequestMapping(value = "getTomcatStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getStatus(String id) {
// return JsonMessage.getString(200, "查询成功", tomcatManageService.getTomcatStatus(id));
// }
//
//
// /**
// * 启动tomcat
// *
// * @param id tomcat id
// * @return 操作结果
// */
// @RequestMapping(value = "start", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String start(String id) {
// // 查询tomcat信息
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
//
// String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
// String msg = "启动成功";
// if ("stopped".equals(result)) {
// msg = "启动失败";
// }
// return JsonMessage.getString(200, msg, result);
// }
//
//
// /**
// * 删除tomcat
// *
// * @param id tomcat id
// * @return 操作结果
// */
// @RequestMapping(value = "stop", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String stop(String id) {
// // 查询tomcat信息
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
//
// String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
// String msg = "停止成功";
// if ("started".equals(result)) {
// msg = "停止失败";
// }
// return JsonMessage.getString(200, msg, result);
// }
//
// /**
// * 重启tomcat
// *
// * @param id tomcat id
// * @return 操作结果
// */
// @RequestMapping(value = "restart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String restart(String id) {
// // 查询tomcat信息
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
//
// String stopResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
// String startResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
// return JsonMessage.getString(200, StrUtil.format("重启成功 {} {}", stopResult, startResult));
// }
//
// /**
// * tomcat项目管理
// *
// * @param id tomcat id
// * @param path 项目路径
// * @param op 执行的操作
// * @return 操作结果
// */
// @RequestMapping(value = "tomcatProjectManage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String tomcatProjectManage(String id, String path,
// @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "操作项不对") String op) {
//
// TomcatOp tomcatOp = TomcatOp.valueOf(op);
// return tomcatManageService.tomcatProjectManage(id, path, tomcatOp).toString();
// }
//
// /**
// * 获取项目文件列表
// *
// * @param id tomcat id
// * @param path 项目路径
// * @return 文件列表
// */
// @RequestMapping(value = "getFileList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String getFileList(String id, String path) {
// // 查询项目路径
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// if (tomcatInfoModel == null) {
// return JsonMessage.getString(500, "查询失败:项目不存在");
// }
// if (StrUtil.isEmptyOrUndefined(path)) {
// return JsonMessage.getString(500, "path value error");
// }
// String appBasePath = tomcatInfoModel.getAppBase();
// File fileDir = FileUtil.file(appBasePath, FileUtil.normalize(path));
// if (!fileDir.exists()) {
// return JsonMessage.getString(500, "目录不存在");
// }
// File[] filesAll = fileDir.listFiles();
// if (filesAll == null) {
// return JsonMessage.getString(500, "目录是空");
// }
//
// // JSONArray arrayFile = FileUtils.parseInfo(filesAll, false, appBasePath);
// JSONArray arrayFile = new JSONArray();
// JSONArray arrayDir = new JSONArray();
// for (File file : filesAll) {
// JSONObject jsonObject = new JSONObject();
// String parentPath = StringUtil.delStartPath(file, appBasePath, false);
// jsonObject.put("parentPath", parentPath);
// jsonObject.put("filename", file.getName());
// long mTime = file.lastModified();
// jsonObject.put("modifyTimeLong", mTime);
// jsonObject.put("modifyTime", DateUtil.date(mTime).toString());
//
// if (file.isDirectory()) {
// jsonObject.put("isDirectory", true);
// long sizeFile = FileUtil.size(file);
// jsonObject.put("fileSize", FileUtil.readableFileSize(sizeFile));
// arrayDir.add(jsonObject);
// } else {
// jsonObject.put("fileSize", FileUtil.readableFileSize(file.length()));
// arrayFile.add(jsonObject);
// }
// }
//
// JSONArray resultArray = new JSONArray();
// resultArray.addAll(arrayDir);
// resultArray.addAll(arrayFile);
// return JsonMessage.getString(200, "查询成功", resultArray);
// }
//
//
// /**
// * 上传文件
// *
// * @param id tomcat id
// * @param path 文件路径
// * @return 操作结果
// */
// @RequestMapping(value = "upload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String upload(String id, String path) {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
//
// MultipartFileBuilder multipartFileBuilder = createMultipart()
// .addFieldName("file");
//
// File dir = new File(tomcatInfoModel.getAppBase().concat(FileUtil.normalize(path)));
//
// multipartFileBuilder.setSavePath(dir.getAbsolutePath())
// .setUseOriginalFilename(true);
// // 保存
// try {
// multipartFileBuilder.save();
// } catch (IOException e) {
// return JsonMessage.getString(500, "上传异常");
// }
//
// return JsonMessage.getString(200, "上传成功");
// }
//
// /**
// * 上传war文件
// *
// * @param id tomcat id
// * @return 操作结果
// */
// @RequestMapping(value = "uploadWar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String uploadWar(String id) {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
//
// MultipartFileBuilder multipartFileBuilder = createMultipart()
// .addFieldName("file");
//
// File dir = new File(tomcatInfoModel.getAppBase());
//
// multipartFileBuilder.setSavePath(dir.getAbsolutePath())
// .setUseOriginalFilename(true);
// // 保存
// try {
// multipartFileBuilder.save();
// } catch (IOException e) {
// return JsonMessage.getString(500, "上传异常");
// }
//
// return JsonMessage.getString(200, "上传成功");
// }
//
//
// /**
// * 删除文件
// *
// * @param id tomcat id
// * @param filename 文件名
// * @param path tomcat路径
// * @return 操作结果
// */
// @RequestMapping(value = "deleteFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String deleteFile(String id, String path, String filename) {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// if (tomcatInfoModel == null) {
// return JsonMessage.getString(500, "tomcat不存在");
// }
// File file;
// if ("_tomcat_log".equals(path)) {
// //删除日志文件
// file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
// // 判断修改时间
// long modified = file.lastModified();
// if (System.currentTimeMillis() - modified < TimeUnit.DAYS.toMillis(1)) {
// return JsonMessage.getString(405, "不能删除当天的日志");
// }
// // 判断最后修改日期
// AgentFileTailWatcher.offlineFile(file);
// } else {
// file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
// }
// if (file.exists()) {
// if (file.delete()) {
// return JsonMessage.getString(200, "删除成功");
// } else {
// return JsonMessage.getString(500, "删除失败");
// }
// } else {
// return JsonMessage.getString(404, "文件不存在");
// }
// }
//
// /**
// * 下载文件
// *
// * @param id tomcat id
// * @param filename 文件名
// * @param path tomcat路径
// * @return 操作结果
// */
// @RequestMapping(value = "download", method = RequestMethod.GET)
// public String download(String id, String path, String filename) {
// filename = FileUtil.normalize(filename);
// path = FileUtil.normalize(path);
// try {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// File file;
// //下载日志文件
// if ("_tomcat_log".equals(path)) {
// file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
// } else {
// file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
// }
// if (file.isDirectory()) {
// return "暂不支持下载文件夹";
// }
// ServletUtil.write(getResponse(), file);
// } catch (Exception e) {
// log.error("下载文件异常", e);
// }
// return "下载失败。请刷新页面后重试";
// }
//
// /**
// * 获取tomcat 日志列表
// *
// * @param id tomcat id
// * @return json
// */
// @RequestMapping(value = "logList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
// public String logList(String id) {
// TomcatInfoModel item = tomcatEditService.getItem(id);
// if (item == null) {
// return JsonMessage.getString(300, "没有对应数据");
// }
// JSONArray jsonArray = LayuiTreeUtil.getTreeData(FileUtil.file(item.pathAndCheck(), "logs").getAbsolutePath());
// return JsonMessage.getString(200, "", jsonArray);
// }
//}

View File

@ -1,64 +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.
*/
///*
// * 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 io.jpom.controller.tomcat;
//
///**
// * tomcat操作
// *
// * @author bwcx_jzy
// * @since 2019/7/22
// **/
//public enum TomcatOp {
// /**
// * 启动
// */
// start,
// stop,
// reload,
// /**
// * 删除发布
// */
// undeploy
//}

View File

@ -1,82 +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.
*/
///*
// * 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 io.jpom.model.data;
//
//import io.jpom.model.BaseModel;
//
///**
// * jdk 信息
// *
// * @author bwcx_jzy
// * @since 2019/10/29
// */
//public class JdkInfoModel extends BaseModel {
//
// /**
// * jdk 路径
// */
// private String path;
//
// /**
// * jdk 版本
// */
// private String version;
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//}

View File

@ -1,222 +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.
*/
///*
// * 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 io.jpom.model.data;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.io.resource.ResourceUtil;
//import cn.hutool.core.util.CharsetUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.core.util.ZipUtil;
//import io.jpom.model.BaseModel;
//import io.jpom.system.JpomRuntimeException;
//
//import java.io.File;
//import java.io.InputStream;
//
///**
// * tomcat 对象实体
// *
// * @author lf
// */
//public class TomcatInfoModel extends BaseModel {
//
// private String path;
// private int port;
// private int status;
// private String appBase;
// private String creator;
// private String createTime;
// private String modifyUser;
// private String modifyTime;
//
// public String getPath() {
// if (path == null) {
// return null;
// }
// return FileUtil.normalize(path + StrUtil.SLASH);
// }
//
// /**
// * 检测路径是否正确
// *
// * @return path
// */
// public String pathAndCheck() {
// String path = getPath();
// if (path == null) {
// return null;
// }
// if (isTomcatRoot(path)) {
// return path;
// }
// throw new RuntimeException(String.format("没有在路径:%s 下检测到Tomcat", path));
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public int getStatus() {
// return status;
// }
//
// public void setStatus(int status) {
// this.status = status;
// }
//
// public String getAppBase() {
// if (StrUtil.isEmpty(appBase)) {
// return FileUtil.normalize(path + "/webapps/");
// }
// return FileUtil.normalize(appBase + StrUtil.SLASH);
// }
//
// public void setAppBase(String appBase) {
// this.appBase = appBase;
// }
//
// public String getCreator() {
// return creator;
// }
//
// public void setCreator(String creator) {
// this.creator = creator;
// }
//
// public String getCreateTime() {
// return createTime;
// }
//
// public void setCreateTime(String createTime) {
// this.createTime = createTime;
// }
//
// public String getModifyUser() {
// return modifyUser;
// }
//
// public void setModifyUser(String modifyUser) {
// this.modifyUser = modifyUser;
// }
//
// public String getModifyTime() {
// return modifyTime;
// }
//
// public void setModifyTime(String modifyTime) {
// this.modifyTime = modifyTime;
// }
//
//
// /**
// * 判断是否是Tomcat的根路径
// *
// * @return 返回是否是Tomcat根路径
// */
// private static boolean isTomcatRoot(String path) {
// File file = new File(path);
// if (!file.exists()) {
// return false;
// }
// if (file.isFile()) {
// return false;
// }
// File[] files = file.listFiles();
// if (files == null) {
// return false;
// }
// // 判断该目录下是否
// for (File child : files) {
// if ("bin".equals(child.getName()) && child.isDirectory()) {
// File[] binFiles = child.listFiles();
// if (binFiles == null) {
// return false;
// }
// for (File binChild : binFiles) {
// if ("bootstrap.jar".equals(binChild.getName()) && binChild.isFile()) {
// return true;
// }
// }
// }
// }
// return false;
// }
//
// /**
// * 初始化
// */
// public void initTomcat() {
// String tomcatPath = pathAndCheck();
// String appBase = getAppBase();
// if (StrUtil.isEmpty(appBase) || StrUtil.SLASH.equals(appBase)) {
// File webapps = FileUtil.file(tomcatPath, "webapps");
// setAppBase(webapps.getAbsolutePath());
// } else {
// String path = FileUtil.normalize(appBase);
// if (FileUtil.isAbsolutePath(path)) {
// // appBase如/project/D:/project/
// setAppBase(path);
// } else {
// // appBase填写的是对相路径如project/dir
// File webapps = FileUtil.file(tomcatPath, path);
// setAppBase(webapps.getAbsolutePath());
// }
// }
// InputStream inputStream = ResourceUtil.getStream("classpath:/bin/jpomAgent.zip");
// if (inputStream == null) {
// throw new JpomRuntimeException("jpomAgent.zip不存在");
// }
// // 解压代理工具到tomcat的appBase目录下
// ZipUtil.unzip(inputStream, new File(getAppBase()), CharsetUtil.CHARSET_UTF_8);
// }
//}

View File

@ -1,90 +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.
*/
///*
// * 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 io.jpom.service.manage;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.util.IdUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.system.JavaInfo;
//import cn.hutool.system.JavaRuntimeInfo;
//import io.jpom.model.data.JdkInfoModel;
//import io.jpom.service.BaseOperService;
//import io.jpom.system.AgentConfigBean;
//import org.springframework.stereotype.Service;
//
///**
// * jdk 管理
// *
// * @author Arno
// * @since 2019/11/20
// */
//@Service
//public class JdkInfoService extends BaseOperService<JdkInfoModel> {
//
// public JdkInfoService() {
// super(AgentConfigBean.JDK_CONF);
// }
//
// /**
// * 使用中的jdk
// *
// * @return JdkInfoModel
// */
// private JdkInfoModel getDefaultJdk() {
// JavaRuntimeInfo info = new JavaRuntimeInfo();
// String homeDir = info.getHomeDir();
// String version = new JavaInfo().getVersion();
// if (StrUtil.isEmpty(homeDir) || StrUtil.isEmpty(version)) {
// return null;
// }
// String path = FileUtil.normalize(homeDir.replace("jre", ""));
// JdkInfoModel jdkInfoModel = new JdkInfoModel();
// jdkInfoModel.setId(IdUtil.fastUUID());
// jdkInfoModel.setVersion(version);
// jdkInfoModel.setPath(path);
// return jdkInfoModel;
// }
//
//}

View File

@ -1,114 +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.
*/
///*
// * 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 io.jpom.service.manage;
//
//import cn.hutool.core.date.DateUtil;
//import com.alibaba.fastjson.JSONObject;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.service.BaseOperService;
//import io.jpom.system.AgentConfigBean;
//import org.springframework.stereotype.Service;
//
///**
// * @author lf
// */
//@Service
//public class TomcatEditService extends BaseOperService<TomcatInfoModel> {
//
//
// public TomcatEditService() {
// super(AgentConfigBean.TOMCAT);
// }
//
//
// /**
// * 根据tomcat名称查询tomcat信息
// *
// * @param name tomcat的名称
// * @return tomcat信息
// */
// public TomcatInfoModel getItemByName(String name) {
// JSONObject allTomcat = getJSONObject(AgentConfigBean.TOMCAT);
//
// if (allTomcat == null) {
// return null;
// }
//
// JSONObject tomcat = null;
// for (String key : allTomcat.keySet()) {
// JSONObject object = allTomcat.getJSONObject(key);
// if (name.equals(object.getString("name"))) {
// tomcat = object;
// break;
// }
// }
//
// return JSONObject.toJavaObject(tomcat, TomcatInfoModel.class);
// }
//
// /**
// * 添加Tomcat
// *
// * @param tomcatInfoModel tomcat信息
// */
// @Override
// public void addItem(TomcatInfoModel tomcatInfoModel) {
// tomcatInfoModel.setCreateTime(DateUtil.now());
// super.addItem(tomcatInfoModel);
// }
//
//
// /**
// * 修改tomcat信息
// *
// * @param tomcatInfoModel tomcat信息
// */
// @Override
// public void updateItem(TomcatInfoModel tomcatInfoModel) {
// tomcatInfoModel.setModifyTime(DateUtil.now());
// super.updateItem(tomcatInfoModel);
//
// }
//}

View File

@ -1,178 +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.
*/
///*
// * 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 io.jpom.service.manage;
//
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.http.HttpRequest;
//import cn.hutool.http.HttpResponse;
//import cn.hutool.http.HttpStatus;
//import cn.hutool.http.HttpUtil;
//import io.jpom.common.JsonMessage;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import io.jpom.controller.tomcat.TomcatOp;
//import io.jpom.model.data.TomcatInfoModel;
//import io.jpom.system.JpomRuntimeException;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//
///**
// * @author bwcx_jzy
// * @since 2019/7/21
// */
//@Service
//public class TomcatManageService {
//
// @Resource
// private TomcatEditService tomcatEditService;
//
// /**
// * 查询tomcat状态
// *
// * @param id tomcat的id
// * @return tomcat状态0表示未运行1表示运行中
// */
// public int getTomcatStatus(String id) {
// int result = 0;
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
// HttpRequest httpRequest = new HttpRequest(url);
// // 设置超时时间为3秒
// httpRequest.setConnectionTimeout(3000);
// try (HttpResponse httpResponse = httpRequest.execute()) {
//
// result = 1;
// } catch (Exception ignored) {
// }
//
// return result;
// }
//
// /**
// * 查询tomcat的项目列表
// *
// * @param id tomcat的id
// * @return tomcat的项目列表
// */
// public JSONArray getTomcatProjectList(String id) {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// String body = tomcatCmd(tomcatInfoModel, "text/list");
//
// String[] result = body.replace(StrUtil.CRLF, "$")
// .replace("\n", "$")
// .split("\\$");
//
// JSONArray jsonArray = new JSONArray();
//
// for (int i = 1; i < result.length; i++) {
// String str = result[i];
// JSONObject jsonObject = new JSONObject();
// String[] strs = str.split(StrUtil.COLON);
// if (strs[0].endsWith("jpomAgent")) {
// continue;
// }
//
// jsonObject.put("path", StrUtil.SLASH.equals(strs[0]) ? "/ROOT" : strs[0]);
// jsonObject.put("status", strs[1]);
// jsonObject.put("session", strs[2]);
//
// jsonArray.add(jsonObject);
// }
//
// return jsonArray;
// }
//
// /**
// * 访问tomcat Url
// *
// * @param tomcatInfoModel tomcat信息
// * @param cmd 命令
// * @return 访问结果
// */
// private String tomcatCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
// String url = String.format("http://127.0.0.1:%d/jpomAgent/%s", tomcatInfoModel.getPort(), cmd);
// HttpRequest httpRequest = HttpUtil.createGet(url);
// // new HttpRequest(url);
// // 设置超时时间为3秒
// httpRequest.timeout(3000);
// String body = "";
//
// try (HttpResponse httpResponse = httpRequest.execute()) {
// if (httpResponse.isOk()) {
// body = httpResponse.body();
// }
// if (httpResponse.getStatus() == HttpStatus.HTTP_NOT_FOUND) {
// // 没有插件
// tomcatInfoModel.initTomcat();
// throw new JpomRuntimeException("tomcat 未初始化,已经重新初始化请稍后再试");
// }
// } catch (JpomRuntimeException jpom) {
// throw jpom;
// } catch (Exception ignored) {
// }
//
// return body;
// }
//
// /**
// * tomcat项目管理
// *
// * @param id tomcat id
// * @param path 项目路径
// * @param tomcatOp 执行的操作 start=启动项目 stop=停止项目 relaod=重启项目
// * @return 操作结果
// */
// public JsonMessage tomcatProjectManage(String id, String path, TomcatOp tomcatOp) {
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
// String result = tomcatCmd(tomcatInfoModel, String.format("text/%s?path=%s", tomcatOp.name(), path));
//
// if (result.startsWith("OK")) {
// return new JsonMessage(200, "操作成功");
// } else {
// return new JsonMessage(500, "操作失败:" + result);
// }
// }
//}

View File

@ -1,146 +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.
*/
///*
// * 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 io.jpom;
//
//import cn.hutool.core.lang.Console;
//import cn.hutool.core.util.ObjectUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.system.SystemUtil;
//import io.jpom.util.CommandUtil;
//import io.jpom.util.JvmUtil;
//import io.jpom.util.StringUtil;
//
//import java.io.IOException;
//
///**
// * 命令行关闭Jpom
// *
// * @author jiangzeyin
// * @since 2019/4/7
// */
//public class JpomClose {
// private static JpomClose jpomManager;
//
// public void main(String[] args) throws Exception {
// String tag = StringUtil.getArgsValue(args, "jpom.applicationTag");
// if (StrUtil.isEmpty(tag)) {
// return;
// }
// // 事件
// String event = StringUtil.getArgsValue(args, "event");
// if ("stop".equalsIgnoreCase(event)) {
// String status = JpomClose.getInstance().status(tag);
// if (!status.contains(StrUtil.COLON)) {
// Console.error("Jpom并没有运行");
// } else {
// String msg = JpomClose.getInstance().stop(tag);
// Console.log(msg);
// }
// System.exit(0);
// } else if ("status".equalsIgnoreCase(event)) {
// String status = JpomClose.getInstance().status(tag);
// Console.log(status);
// System.exit(0);
// }
// }
//
// /**
// * 单利模式
// *
// * @return JpomClose
// */
// public static JpomClose getInstance() {
// if (jpomManager != null) {
// return jpomManager;
// }
// if (SystemUtil.getOsInfo().isLinux()) {
// jpomManager = new Linux();
// } else {
// jpomManager = new Windows();
// }
// return jpomManager;
// }
//
//
// public String stop(String tag) throws IOException {
// Integer pid = JvmUtil.getPidByTag(tag);
// return ObjectUtil.toString(pid);
// }
//
// public String status(String tag) throws IOException {
// Integer pid = JvmUtil.getPidByTag(tag);
// if (pid == null) {
// return "Jpom并没有运行";
// }
// return "Jpom运行中:" + pid;
// }
//
//
// private static class Windows extends JpomClose {
//
// @Override
// public String stop(String tag) throws IOException {
// String pid = super.stop(tag);
// if (pid == null) {
// return "stop";
// }
// String cmd = String.format("taskkill /F /PID %s", pid);
// return CommandUtil.execSystemCommand(cmd);
// }
// }
//
// private static class Linux extends JpomClose {
//
// @Override
// public String stop(String tag) throws IOException {
// String pid = super.stop(tag);
// if (pid == null) {
// return "stop";
// }
// String cmd = String.format("kill %s", pid);
// return CommandUtil.execSystemCommand(cmd);
// }
// }
//}

View File

@ -1,67 +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.
*/
///*
// * 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 io.jpom;
//
//import cn.hutool.core.io.IoUtil;
//import cn.hutool.core.io.resource.ResourceUtil;
//import org.springframework.boot.context.event.ApplicationReadyEvent;
//import org.springframework.context.ApplicationListener;
//
//import java.io.InputStream;
//
///**
// * load Jpom version and print Jpom logo
// *
// * @author Hotstrip
// */
//public class JpomLogo implements ApplicationListener<ApplicationReadyEvent> {
//
// @Override
// public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
// InputStream inputStream = ResourceUtil.getStream("banner.txt");
// String logo = IoUtil.readUtf8(inputStream);
// System.out.println(logo);
// }
//}

View File

@ -22,19 +22,43 @@
*/
package io.jpom.common;
import org.springframework.context.annotation.Bean;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* <a href="https://springboot.io/t/topic/3637">https://springboot.io/t/topic/3637</a>
*
* @author bwcx_jzy
* @since 2022/12/8
*/
@Configuration
public class ReplaceStreamFilter {
@Slf4j
public class ReplaceStreamFilter implements Filter {
@Bean
public CommonsRequestLoggingFilter commonsRequestLoggingFilter() {
return new CommonsRequestLoggingFilter();
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
long startTime = System.currentTimeMillis();
ContentCachingRequestWrapper wrapper = new ContentCachingRequestWrapper((HttpServletRequest) request);
chain.doFilter(wrapper, response);
long endTime = System.currentTimeMillis();
if (endTime - startTime > 1000 * 5) {
byte[] contentAsByteArray = wrapper.getContentAsByteArray();
String str = StrUtil.str(contentAsByteArray, CharsetUtil.CHARSET_UTF_8);
String reqData = Opt.ofBlankAble(str)
.map(s -> wrapper.getParameterMap())
.map(JSONObject::toJSONString)
.orElse(StrUtil.EMPTY);
log.warn("[timeout] {} {}", wrapper.getRequestURI(), reqData);
}
}
}

View File

@ -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 io.jpom.common.interceptor;
//
//import cn.jiangzeyin.common.interceptor.BaseInterceptor;
//import cn.jiangzeyin.common.interceptor.InterceptorPattens;
//import io.jpom.plugin.*;
//import org.springframework.web.method.HandlerMethod;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
///**
// * 插件方法回调拦截器
// *
// * @author bwcx_jzy
// * @since 2019/8/13
// */
//@InterceptorPattens(sort = Integer.MAX_VALUE)
//public class PluginFeatureInterceptor extends BaseInterceptor {
//
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// super.postHandle(request, response, handler, modelAndView);
// HandlerMethod handlerMethod = getHandlerMethod(handler);
// if (handlerMethod == null) {
// return;
// }
// Feature methodAnnotation = handlerMethod.getMethodAnnotation(Feature.class);
// Feature annotation = handlerMethod.getBeanType().getAnnotation(Feature.class);
// if (methodAnnotation != null && annotation != null) {
// if (methodAnnotation.method() != MethodFeature.NULL && annotation.cls() != ClassFeature.NULL) {
// List<FeatureCallback> featureCallbacks = PluginFactory.getFeatureCallbacks();
// featureCallbacks.forEach(featureCallback -> featureCallback.postHandle(request, annotation.cls(), methodAnnotation.method()));
// }
// }
// }
//}

View File

@ -42,7 +42,7 @@ import java.util.*;
* 文件上传builder
*
* @author jiangzeyin
* @date 2018/10/23
* @since 2018/10/23
*/
public class MultipartFileBuilder {

View File

@ -29,7 +29,7 @@ import cn.hutool.system.UserInfo;
* 上传文件保存路径
*
* @author jiangzeyin
* @date 2017/10/25
* @since 2017/10/25
*/
public class MultipartFileConfig {

View File

@ -26,7 +26,7 @@ package io.jpom.common.validator;
* 错误条件
*
* @author jiangzeyin
* @date 2018/12/25
* @since 2018/12/25
*/
public enum ErrorCondition {
/**

View File

@ -49,7 +49,7 @@ import java.lang.reflect.Method;
* 配置方法
*
* @author jiangzeyin
* @date 2018/8/21.
* @since 2018/8/21.
*/
@Slf4j
@Configuration

View File

@ -30,7 +30,7 @@ import java.lang.annotation.*;
* 字段验证配置
*
* @author jiangzeyin
* @date 2018/8/21.
* @since 2018/8/21.
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)

View File

@ -28,7 +28,7 @@ import java.lang.annotation.*;
* 验证规则
*
* @author jiangzeyin
* @date 2018/8/21
* @since 2018/8/21
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)

View File

@ -26,7 +26,7 @@ package io.jpom.common.validator;
* 验证规则
*
* @author jiangzeyin
* @date 2018/8/21.
* @since 2018/8/21.
*/
public enum ValidatorRule {
/**

View File

@ -1,47 +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 io.jpom.plugin;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * 功能回调
// *
// * @author bwcx_jzy
// * @since 2019/8/13
// */
//public interface FeatureCallback {
//
// /**
// * 方法执行
// *
// * @param request 请求对象
// * @param classFeature 类方法
// * @param methodFeature 方法
// * @param pars 辅助参数
// */
// void postHandle(HttpServletRequest request,
// ClassFeature classFeature,
// MethodFeature methodFeature,
// Object... pars);
//}

View File

@ -55,10 +55,7 @@ import java.util.function.Function;
@Getter
public class ExtConfigBean {
public static final String FILE_NAME = "extConfig.yml";
private static Resource resource;
public static final String FILE_NAME = "application.yml";
/**
@ -114,7 +111,6 @@ public class ExtConfigBean {
}
private static ExtConfigBean extConfigBean;
/**
@ -123,27 +119,16 @@ public class ExtConfigBean {
* @return File
*/
public static Resource getResource() {
if (resource != null) {
return resource;
}
String property = cn.hutool.extra.spring.SpringUtil.getApplicationContext().getEnvironment().getProperty(ConfigFileApplicationListener.CONFIG_LOCATION_PROPERTY);
String property = SpringUtil.getApplicationContext().getEnvironment().getProperty(ConfigFileApplicationListener.CONFIG_LOCATION_PROPERTY);
Resource configResource = Opt.ofBlankAble(property)
.map(FileSystemResource::new)
.flatMap((Function<Resource, Opt<Resource>>) resource -> resource.exists() ? Opt.of(resource) : Opt.empty())
.orElseGet(() -> {
ClassPathResource classPathResource = new ClassPathResource("application.yml");
return classPathResource.exists() ? classPathResource : new ClassPathResource("/config_default/application.yml");
ClassPathResource classPathResource = new ClassPathResource(ExtConfigBean.FILE_NAME);
return classPathResource.exists() ? classPathResource : new ClassPathResource("/config_default/" + FILE_NAME);
});
Assert.state(configResource.exists(), "均未找到配置文件");
resource = configResource;
return ExtConfigBean.resource;
}
public static File getResourceFile() {
File file = JpomManifest.getRunPath();
file = file.getParentFile().getParentFile();
file = FileUtil.file(file, FILE_NAME);
return file;
return configResource;
}
/**

View File

@ -1,86 +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 io.jpom.system;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.ClassUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import java.net.URL;
import java.util.List;
/**
* 动态读取外部配置文件
*
* @author jiangzeyin
* @since 2019/3/5
*/
public class ExtConfigEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
{
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
Resource resource = ExtConfigBean.getResource();
try {
List<PropertySource<?>> propertySources = yamlPropertySourceLoader.load(ExtConfigBean.FILE_NAME, resource);
propertySources.forEach(propertySource -> environment.getPropertySources().addLast(propertySource));
} catch (Exception e) {
Console.error(e.getMessage());
}
}
{
// 兼容一些全局默认配置属性
List<URL> resources = ClassUtil.getResources("bin/extConfigDefault.yml");
if (resources.isEmpty()) {
resources.add(ClassUtil.getResourceURL("bin/extConfigDefault.yml"));
}
for (int i = 0; i < resources.size(); i++) {
URL resource = resources.get(i);
Resource extConfigDefault = new UrlResource(resource);
if (extConfigDefault.exists()) {
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
try {
List<PropertySource<?>> propertySources = yamlPropertySourceLoader.load("extConfigDefault" + i + ".yml", extConfigDefault);
propertySources.forEach(propertySource -> environment.getPropertySources().addLast(propertySource));
} catch (Exception e) {
Console.error(e.getMessage());
}
}
}
}
}
@Override
public int getOrder() {
return ConfigDataEnvironmentPostProcessor.ORDER - 1;
}
}

View File

@ -1,81 +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.
*/
///*
// * 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 io.jpom.system.init;
//
//import cn.hutool.core.collection.CollUtil;
//import cn.hutool.core.exceptions.ExceptionUtil;
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.util.ObjectUtil;
//import cn.jiangzeyin.common.DefaultSystemLog;
//import cn.jiangzeyin.common.PreLoadClass;
//import cn.jiangzeyin.common.PreLoadMethod;
//import io.jpom.JpomApplication;
//import io.jpom.common.JpomManifest;
//import io.jpom.system.ConfigBean;
//import io.jpom.system.ExtConfigBean;
//import io.jpom.util.JvmUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.HttpMethod;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.File;
//import java.nio.file.AccessDeniedException;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Map;
//
///**
// * 数据目录权限检查
// *
// * @author jiangzeyin
// * @since 2019/3/26
// */
//@PreLoadClass(value = Integer.MIN_VALUE)
//@Slf4j
//public class CheckPath {
//
//
//}

View File

@ -29,6 +29,7 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -386,7 +387,7 @@ public class NodeForward {
// httpRequest.header(ConfigBean.JPOM_SERVER_SYSTEM_USER_ROLE, userModel.getUserRole(nodeModel).name());
}
if (StrUtil.isEmpty(nodeModel.getLoginPwd())) {
NodeService nodeService = cn.hutool.extra.spring.SpringUtil.getBean(NodeService.class);
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeModel model = nodeService.getByKey(nodeModel.getId(), false);
nodeModel.setLoginPwd(model.getLoginPwd());
nodeModel.setLoginName(model.getLoginName());
@ -431,7 +432,7 @@ public class NodeForward {
ws = "ws";
}
if (StrUtil.isEmpty(nodeModel.getLoginPwd())) {
NodeService nodeService = cn.hutool.extra.spring.SpringUtil.getBean(NodeService.class);
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeModel model = nodeService.getByKey(nodeModel.getId(), false);
nodeModel.setLoginPwd(model.getLoginPwd());
nodeModel.setLoginName(model.getLoginName());

View File

@ -1,87 +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.
*/
///*
// * 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 io.jpom.common.interceptor;
//
///**
// * 拦截器
// *
// * @author jiangzeyin
// * @since 2019/4/16
// */
//public abstract class BaseJpomInterceptor {
//
// public static final String PROXY_PATH = "Jpom-ProxyPath";
//
//// static boolean isPage(HandlerMethod handlerMethod) {
//// ResponseBody responseBody = handlerMethod.getMethodAnnotation(ResponseBody.class);
//// if (responseBody == null) {
//// RestController restController = handlerMethod.getBeanType().getAnnotation(RestController.class);
//// return restController == null;
//// }
//// return false;
//// }
//
//// public static void sendRedirects(HttpServletRequest request, HttpServletResponse response, String url) throws IOException {
//// String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url;
//// UrlRedirectUtil.sendRedirect(request, response, newUrl);
//// }
////
//// public static String getRedirect(HttpServletRequest request, String url) {
//// String newUrl = UrlRedirectUtil.getHeaderProxyPath(request, PROXY_PATH) + url;
//// String redirect = UrlRedirectUtil.getRedirect(request, newUrl);
//// return String.format("redirect:%s", redirect);
//// }
//
//// public static String getHeaderProxyPath(HttpServletRequest request) {
//// String proxyPath = ServletUtil.getHeaderIgnoreCase(request, PROXY_PATH);
//// if (StrUtil.isEmpty(proxyPath)) {
//// return StrUtil.EMPTY;
//// }
//// if (proxyPath.endsWith(StrUtil.SLASH)) {
//// proxyPath = proxyPath.substring(0, proxyPath.length() - 1);
//// }
//// return proxyPath;
//// }
//}

View File

@ -57,6 +57,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
@ -234,8 +235,9 @@ public class IndexControl extends BaseServerController {
@NotLogin
@RequestMapping(value = "check-system", produces = MediaType.APPLICATION_JSON_VALUE)
public String checkSystem() {
HttpServletRequest request = getRequest();
JSONObject data = new JSONObject();
data.put("routerBase", UrlRedirectUtil.getHeaderProxyPath(getRequest(), ServerConst.PROXY_PATH));
data.put("routerBase", UrlRedirectUtil.getHeaderProxyPath(request, ServerConst.PROXY_PATH));
//
ServerExtConfigBean instance = ServerExtConfigBean.getInstance();
data.put("name", instance.getName());

View File

@ -83,236 +83,236 @@ import java.util.zip.ZipFile;
@Slf4j
public class SshInstallAgentController extends BaseServerController {
private final SshService sshService;
private final NodeService nodeService;
private final SshService sshService;
private final NodeService nodeService;
public SshInstallAgentController(SshService sshService,
NodeService nodeService) {
this.sshService = sshService;
this.nodeService = nodeService;
}
public SshInstallAgentController(SshService sshService,
NodeService nodeService) {
this.sshService = sshService;
this.nodeService = nodeService;
}
private JSONObject getAgentFile() throws IOException {
ServerConfigBean instance = ServerConfigBean.getInstance();
File agentZipPath = instance.getAgentZipPath();
Assert.state(FileUtil.exist(agentZipPath), "插件包文件不存在,需要重新上传");
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
//
File tempAgent = FileUtil.file(tempFilePath, "temp_agent");
FileUtil.del(tempAgent);
try {
// 解析压缩包
File jarFile = JpomManifest.zipFileFind(FileUtil.getAbsolutePath(agentZipPath), Type.Agent, FileUtil.getAbsolutePath(tempAgent));
// 获取包内容
JsonMessage<Tuple> tupleJsonMessage = JpomManifest.checkJpomJar(FileUtil.getAbsolutePath(jarFile), Type.Agent, false);
private JSONObject getAgentFile() throws IOException {
ServerConfigBean instance = ServerConfigBean.getInstance();
File agentZipPath = instance.getAgentZipPath();
Assert.state(FileUtil.exist(agentZipPath), "插件包文件不存在,需要重新上传");
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
//
File tempAgent = FileUtil.file(tempFilePath, "temp_agent");
FileUtil.del(tempAgent);
try {
// 解析压缩包
File jarFile = JpomManifest.zipFileFind(FileUtil.getAbsolutePath(agentZipPath), Type.Agent, FileUtil.getAbsolutePath(tempAgent));
// 获取包内容
JsonMessage<Tuple> tupleJsonMessage = JpomManifest.checkJpomJar(FileUtil.getAbsolutePath(jarFile), Type.Agent, false);
Assert.state(tupleJsonMessage.getCode() == 200, tupleJsonMessage::getMsg);
Tuple data = tupleJsonMessage.getData();
JSONObject jsonObject = new JSONObject();
jsonObject.put("version", data.get(0));
jsonObject.put("timeStamp", data.get(1));
jsonObject.put("path", FileUtil.getAbsolutePath(agentZipPath));
return jsonObject;
} finally {
FileUtil.del(tempAgent);
}
}
Assert.state(tupleJsonMessage.getCode() == 200, tupleJsonMessage::getMsg);
Tuple data = tupleJsonMessage.getData();
JSONObject jsonObject = new JSONObject();
jsonObject.put("version", data.get(0));
jsonObject.put("timeStamp", data.get(1));
jsonObject.put("path", FileUtil.getAbsolutePath(agentZipPath));
return jsonObject;
} finally {
FileUtil.del(tempAgent);
}
}
@GetMapping(value = "get_agent.json", produces = MediaType.APPLICATION_JSON_VALUE)
@SystemPermission
public String getAgent() throws IOException {
JSONObject agentFile = this.getAgentFile();
return JsonMessage.getString(200, "", agentFile);
}
@GetMapping(value = "get_agent.json", produces = MediaType.APPLICATION_JSON_VALUE)
@SystemPermission
public String getAgent() throws IOException {
JSONObject agentFile = this.getAgentFile();
return JsonMessage.getString(200, "", agentFile);
}
@RequestMapping(value = "upload_agent.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
@SystemPermission
public String uploadAgent() throws Exception {
ServerConfigBean instance = ServerConfigBean.getInstance();
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
MultipartFileBuilder multipartFileBuilder = createMultipart()
.setFileExt("zip")
.addFieldName("file")
.setSavePath(tempFilePath);
String filePath = multipartFileBuilder.save();
File tempAgent = FileUtil.file(tempFilePath, "temp_agent");
FileUtil.del(tempAgent);
// 解析压缩包
File jarFile = JpomManifest.zipFileFind(filePath, Type.Agent, FileUtil.getAbsolutePath(tempAgent));
// 验证文件是否正确
JsonMessage<Tuple> tupleJsonMessage = JpomManifest.checkJpomJar(FileUtil.getAbsolutePath(jarFile), Type.Agent, false);
Assert.state(tupleJsonMessage.getCode() == 200, tupleJsonMessage::getMsg);
//
File outFle = FileUtil.file(tempFilePath, Type.Agent.name() + "_" + IdUtil.fastSimpleUUID());
try {
this.unZipGetTag(filePath, outFle);
// 保存插件包
File agentZipPath = instance.getAgentZipPath();
FileUtil.copy(FileUtil.file(filePath), agentZipPath, true);
return JsonMessage.getString(200, "上传成功");
} finally {
FileUtil.del(filePath);
FileUtil.del(jarFile);
}
}
@RequestMapping(value = "upload_agent.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
@SystemPermission
public String uploadAgent() throws Exception {
ServerConfigBean instance = ServerConfigBean.getInstance();
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
MultipartFileBuilder multipartFileBuilder = createMultipart()
.setFileExt("zip")
.addFieldName("file")
.setSavePath(tempFilePath);
String filePath = multipartFileBuilder.save();
File tempAgent = FileUtil.file(tempFilePath, "temp_agent");
FileUtil.del(tempAgent);
// 解析压缩包
File jarFile = JpomManifest.zipFileFind(filePath, Type.Agent, FileUtil.getAbsolutePath(tempAgent));
// 验证文件是否正确
JsonMessage<Tuple> tupleJsonMessage = JpomManifest.checkJpomJar(FileUtil.getAbsolutePath(jarFile), Type.Agent, false);
Assert.state(tupleJsonMessage.getCode() == 200, tupleJsonMessage::getMsg);
//
File outFle = FileUtil.file(tempFilePath, Type.Agent.name() + "_" + IdUtil.fastSimpleUUID());
try {
this.unZipGetTag(filePath, outFle);
// 保存插件包
File agentZipPath = instance.getAgentZipPath();
FileUtil.copy(FileUtil.file(filePath), agentZipPath, true);
return JsonMessage.getString(200, "上传成功");
} finally {
FileUtil.del(filePath);
FileUtil.del(jarFile);
}
}
private String unZipGetTag(String filePath, File outFle) throws IOException {
try (ZipFile zipFile = new ZipFile(filePath)) {
// 判断文件是否正确
ZipEntry sh = zipFile.getEntry(Type.Agent.name() + ".sh");
ZipEntry lib = zipFile.getEntry("lib" + StrUtil.SLASH);
Assert.state(sh != null && lib != null && lib.isDirectory(), "不是 Jpom 插件包");
ZipUtil.unzip(zipFile, outFle);
}
// 获取上传的tag
File shFile = FileUtil.file(outFle, Type.Agent.name() + ".sh");
List<String> lines = FileUtil.readLines(shFile, CharsetUtil.CHARSET_UTF_8);
String tag = null;
for (String line : lines) {
line = line.trim();
if (StrUtil.startWith(line, "Tag=\"") && StrUtil.endWith(line, "\"")) {
tag = line.substring(5, line.length() - 1);
break;
}
}
Assert.hasText(tag, "管理命令中不存在tag");
return tag;
}
private String unZipGetTag(String filePath, File outFle) throws IOException {
try (ZipFile zipFile = new ZipFile(filePath)) {
// 判断文件是否正确
ZipEntry sh = zipFile.getEntry(Type.Agent.name() + ".sh");
ZipEntry lib = zipFile.getEntry("lib" + StrUtil.SLASH);
Assert.state(sh != null && lib != null && lib.isDirectory(), "不是 Jpom 插件包");
ZipUtil.unzip(zipFile, outFle);
}
// 获取上传的tag
File shFile = FileUtil.file(outFle, Type.Agent.name() + ".sh");
List<String> lines = FileUtil.readLines(shFile, CharsetUtil.CHARSET_UTF_8);
String tag = null;
for (String line : lines) {
line = line.trim();
if (StrUtil.startWith(line, "Tag=\"") && StrUtil.endWith(line, "\"")) {
tag = line.substring(5, line.length() - 1);
break;
}
}
Assert.hasText(tag, "管理命令中不存在tag");
return tag;
}
@RequestMapping(value = "installAgentSubmit.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
@SystemPermission
public String installAgentSubmit(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id,
@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "节点数据") String nodeData,
@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "安装路径") String path) throws Exception {
//
SshModel sshModel = sshService.getByKey(id, false);
Objects.requireNonNull(sshModel, "没有找到对应ssh");
// 判断输入的节点信息
NodeModel nodeModel = this.getNodeModel(nodeData, sshModel);
//
ServerConfigBean instance = ServerConfigBean.getInstance();
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
JSONObject agentFile = this.getAgentFile();
String filePath = agentFile.getString("path");
//
File outFle = FileUtil.file(tempFilePath, Type.Agent.name() + "_" + IdUtil.fastSimpleUUID());
try {
String tag = this.unZipGetTag(filePath, outFle);
//
this.readNodeAuthorize(outFle, nodeModel);
// 查询远程是否运行
Assert.state(!sshService.checkSshRun(sshModel, tag), "对应服务器中已经存在 Jpom 插件端,不需要再次安装啦");
// 上传文件到服务器
sshService.uploadDir(sshModel, path, outFle);
//
String shPtah = FileUtil.normalize(path + StrUtil.SLASH + Type.Agent.name() + ".sh");
String chmod = getParameter("chmod");
if (StrUtil.isEmptyOrUndefined(chmod)) {
chmod = StrUtil.EMPTY;
} else {
chmod = StrUtil.format("{} {} && ", chmod, shPtah);
}
String command = StrUtil.format("{}bash {} start upgrade", chmod, shPtah);
String result = sshService.exec(sshModel, command);
log.debug("ssh install agent node {} {}", command, result);
// 休眠 5 , 尝试 5
int waitCount = getParameterInt("waitCount", 5);
this.loopCheck(waitCount, nodeModel, sshModel, path, result);
// 绑定关系
nodeModel.setSshId(sshModel.getId());
nodeService.insert(nodeModel);
//
return JsonMessage.getString(200, "操作成功:" + result);
} finally {
// 清理资源
FileUtil.del(outFle);
}
}
@RequestMapping(value = "installAgentSubmit.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
@SystemPermission
public String installAgentSubmit(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id,
@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "节点数据") String nodeData,
@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "安装路径") String path) throws Exception {
//
SshModel sshModel = sshService.getByKey(id, false);
Objects.requireNonNull(sshModel, "没有找到对应ssh");
// 判断输入的节点信息
NodeModel nodeModel = this.getNodeModel(nodeData, sshModel);
//
ServerConfigBean instance = ServerConfigBean.getInstance();
String tempFilePath = instance.getUserTempPath().getAbsolutePath();
JSONObject agentFile = this.getAgentFile();
String filePath = agentFile.getString("path");
//
File outFle = FileUtil.file(tempFilePath, Type.Agent.name() + "_" + IdUtil.fastSimpleUUID());
try {
String tag = this.unZipGetTag(filePath, outFle);
//
this.readNodeAuthorize(outFle, nodeModel);
// 查询远程是否运行
Assert.state(!sshService.checkSshRun(sshModel, tag), "对应服务器中已经存在 Jpom 插件端,不需要再次安装啦");
// 上传文件到服务器
sshService.uploadDir(sshModel, path, outFle);
//
String shPtah = FileUtil.normalize(path + StrUtil.SLASH + Type.Agent.name() + ".sh");
String chmod = getParameter("chmod");
if (StrUtil.isEmptyOrUndefined(chmod)) {
chmod = StrUtil.EMPTY;
} else {
chmod = StrUtil.format("{} {} && ", chmod, shPtah);
}
String command = StrUtil.format("{}bash {} start upgrade", chmod, shPtah);
String result = sshService.exec(sshModel, command);
log.debug("ssh install agent node {} {}", command, result);
// 休眠 5 , 尝试 5
int waitCount = getParameterInt("waitCount", 5);
this.loopCheck(waitCount, nodeModel, sshModel, path, result);
// 绑定关系
nodeModel.setSshId(sshModel.getId());
nodeService.insert(nodeModel);
//
return JsonMessage.getString(200, "操作成功:" + result);
} finally {
// 清理资源
FileUtil.del(outFle);
}
}
private void readNodeAuthorize(File outFle, NodeModel nodeModel) throws IOException {
// 读取授权信息
File configFile = FileUtil.file(outFle, ExtConfigBean.FILE_NAME);
if (configFile.exists()) {
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
List<PropertySource<?>> extConfig = yamlPropertySourceLoader.load(ExtConfigBean.FILE_NAME, new FileUrlResource(configFile.getAbsolutePath()));
Assert.notEmpty(extConfig, "没有加载到配置信息,或者配置信息为空");
PropertySource<?> propertySource = extConfig.get(0);
Object user = propertySource.getProperty(ConfigBean.AUTHORIZE_USER_KEY);
nodeModel.setLoginName(Convert.toStr(user, ""));
//
Object pwd = propertySource.getProperty(ConfigBean.AUTHORIZE_AUTHORIZE_KEY);
nodeModel.setLoginPwd(Convert.toStr(pwd, ""));
}
}
private void readNodeAuthorize(File outFle, NodeModel nodeModel) throws IOException {
// 读取授权信息
File configFile = FileUtil.file(outFle, "conf/" + ExtConfigBean.FILE_NAME);
if (configFile.exists()) {
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
List<PropertySource<?>> extConfig = yamlPropertySourceLoader.load(ExtConfigBean.FILE_NAME, new FileUrlResource(configFile.getAbsolutePath()));
Assert.notEmpty(extConfig, "没有加载到配置信息,或者配置信息为空");
PropertySource<?> propertySource = extConfig.get(0);
Object user = propertySource.getProperty(ConfigBean.AUTHORIZE_USER_KEY);
nodeModel.setLoginName(Convert.toStr(user, ""));
//
Object pwd = propertySource.getProperty(ConfigBean.AUTHORIZE_AUTHORIZE_KEY);
nodeModel.setLoginPwd(Convert.toStr(pwd, ""));
}
}
private void loopCheck(int waitCount, NodeModel nodeModel, SshModel sshModel, String path, String result) {
waitCount = Math.max(waitCount, 5);
//int time = 3;
while (--waitCount >= 0) {
//log.debug("there is left {} / 3 times try to get authorize info", waitCount);
ThreadUtil.sleep(5, TimeUnit.SECONDS);
if (StrUtil.hasEmpty(nodeModel.getLoginName(), nodeModel.getLoginPwd())) {
String error = this.getAuthorize(sshModel, nodeModel, path);
// 获取授权成功就不需要继续循环了
if (error == null) {
waitCount = -1;
}
// 获取授权失败且尝试次数用完
if (error != null && waitCount == 0) {
throw new IllegalStateException(StrUtil.format("{} {}", error, result));
}
} else {
break;
}
}
}
private void loopCheck(int waitCount, NodeModel nodeModel, SshModel sshModel, String path, String result) {
waitCount = Math.max(waitCount, 5);
//int time = 3;
while (--waitCount >= 0) {
//log.debug("there is left {} / 3 times try to get authorize info", waitCount);
ThreadUtil.sleep(5, TimeUnit.SECONDS);
if (StrUtil.hasEmpty(nodeModel.getLoginName(), nodeModel.getLoginPwd())) {
String error = this.getAuthorize(sshModel, nodeModel, path);
// 获取授权成功就不需要继续循环了
if (error == null) {
waitCount = -1;
}
// 获取授权失败且尝试次数用完
if (error != null && waitCount == 0) {
throw new IllegalStateException(StrUtil.format("{} {}", error, result));
}
} else {
break;
}
}
}
private String getAuthorize(SshModel sshModel, NodeModel nodeModel, String path) {
File saveFile = null;
try {
String tempFilePath = ServerConfigBean.getInstance().getUserTempPath().getAbsolutePath();
// 获取远程的授权信息
String normalize = FileUtil.normalize(StrUtil.format("{}/{}/{}", path, ConfigBean.DATA, ConfigBean.AUTHORIZE));
saveFile = FileUtil.file(tempFilePath, IdUtil.fastSimpleUUID() + ConfigBean.AUTHORIZE);
sshService.download(sshModel, normalize, saveFile);
//
String json = FileUtil.readString(saveFile, CharsetUtil.CHARSET_UTF_8);
AgentAutoUser autoUser = JSONObject.parseObject(json, AgentAutoUser.class);
nodeModel.setLoginPwd(autoUser.getAgentPwd());
nodeModel.setLoginName(autoUser.getAgentName());
} catch (Exception e) {
log.error("拉取授权信息失败:{}", e.getMessage());
return "获取授权信息失败,请检查对应的插件端运行状态" + e.getMessage();
} finally {
FileUtil.del(saveFile);
}
return null;
}
private String getAuthorize(SshModel sshModel, NodeModel nodeModel, String path) {
File saveFile = null;
try {
String tempFilePath = ServerConfigBean.getInstance().getUserTempPath().getAbsolutePath();
// 获取远程的授权信息
String normalize = FileUtil.normalize(StrUtil.format("{}/{}/{}", path, ConfigBean.DATA, ConfigBean.AUTHORIZE));
saveFile = FileUtil.file(tempFilePath, IdUtil.fastSimpleUUID() + ConfigBean.AUTHORIZE);
sshService.download(sshModel, normalize, saveFile);
//
String json = FileUtil.readString(saveFile, CharsetUtil.CHARSET_UTF_8);
AgentAutoUser autoUser = JSONObject.parseObject(json, AgentAutoUser.class);
nodeModel.setLoginPwd(autoUser.getAgentPwd());
nodeModel.setLoginName(autoUser.getAgentName());
} catch (Exception e) {
log.error("拉取授权信息失败:{}", e.getMessage());
return "获取授权信息失败,请检查对应的插件端运行状态" + e.getMessage();
} finally {
FileUtil.del(saveFile);
}
return null;
}
private NodeModel getNodeModel(String data, SshModel sshModel) {
NodeModel nodeModel = StringUtil.jsonConvert(data, NodeModel.class);
Assert.notNull(nodeModel, "请填写节点信息");
//JSONObject.toJavaObject(JSONObject.parseObject(data), NodeModel.class);
private NodeModel getNodeModel(String data, SshModel sshModel) {
NodeModel nodeModel = StringUtil.jsonConvert(data, NodeModel.class);
Assert.notNull(nodeModel, "请填写节点信息");
//JSONObject.toJavaObject(JSONObject.parseObject(data), NodeModel.class);
Assert.hasText(nodeModel.getName(), "输入节点名称");
Assert.hasText(nodeModel.getName(), "输入节点名称");
Assert.hasText(nodeModel.getUrl(), "请输入节点地址");
//nodeModel.setCycle(Cycle.one.getCode());
//
//nodeModel.setProtocol(StrUtil.emptyToDefault(nodeModel.getProtocol(), "http"));
//
Entity entity = Entity.create();
entity.set("url", nodeModel.getUrl());
entity.set("workspaceId", sshModel.getWorkspaceId());
boolean exists = nodeService.exists(entity);
Assert.state(!exists, "对应的节点已经存在啦");
//
nodeModel.setOpenStatus(1);
Assert.hasText(nodeModel.getUrl(), "请输入节点地址");
//nodeModel.setCycle(Cycle.one.getCode());
//
//nodeModel.setProtocol(StrUtil.emptyToDefault(nodeModel.getProtocol(), "http"));
//
Entity entity = Entity.create();
entity.set("url", nodeModel.getUrl());
entity.set("workspaceId", sshModel.getWorkspaceId());
boolean exists = nodeService.exists(entity);
Assert.state(!exists, "对应的节点已经存在啦");
//
nodeModel.setOpenStatus(1);
return nodeModel;
}
return nodeModel;
}
}

View File

@ -138,7 +138,7 @@ public class SystemConfigController extends BaseServerController {
@PostMapping(value = "save_config.json", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EDIT)
@SystemPermission(superUser = true)
public String saveConfig(String nodeId, String content, String restart) throws IOException, SQLException {
public String saveConfig(String nodeId, String content, String restart) throws SQLException, IOException {
if (StrUtil.isNotEmpty(nodeId)) {
return NodeForward.request(getNode(), getRequest(), NodeUrl.SystemSaveConfig).toString();
}
@ -175,10 +175,9 @@ public class SystemConfigController extends BaseServerController {
Assert.state(restartBool, "修改数据库密码必须重启");
initDb.alterUser(oldDbExtConfigUserName, newDbExtConfigUserName, newDbExtConfigUserPwd);
}
Assert.state(!JpomManifest.getInstance().isDebug(), "调试模式下不支持在线修改,请到resources目录下的bin目录修改extConfig.yml");
File resourceFile = ExtConfigBean.getResourceFile();
FileUtil.writeString(content, resourceFile, CharsetUtil.CHARSET_UTF_8);
Resource resource = ExtConfigBean.getResource();
Assert.state(resource.isFile(), "当前环境下不支持在线修改配置文件");
FileUtil.writeString(content, resource.getFile(), CharsetUtil.CHARSET_UTF_8);
if (restartBool) {
// 重启

View File

@ -69,11 +69,19 @@
</root>
<logger name="org.springframework.web.servlet.DispatcherServlet" additivity="false">
<!-- 打印请求信息方式二-->
<level value="debug"/>
<appender-ref ref="LOG-ROOT"/>
<appender-ref ref="STDOUT"/>
</logger>
<!--请求响应日志-->
<logger name="io.jpom.system.WebAopLog" additivity="false">
<level value="INFO"/>
<appender-ref ref="LOG-ROOT"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="io.jpom" additivity="false">
<level value="debug"/>