code format

This commit is contained in:
bwcx_jzy 2021-04-18 10:30:06 +08:00
parent bdf13e33c4
commit 18e2a4f712

View File

@ -52,59 +52,59 @@ public class WhitelistDirectoryController extends BaseJpomController {
return save(project, certificateList, nList).toString(); return save(project, certificateList, nList).toString();
} }
private JsonMessage save(String project, List<String> certificate, List<String> nginx) { private JsonMessage<String> save(String project, List<String> certificate, List<String> nginx) {
if (StrUtil.isEmpty(project)) { if (StrUtil.isEmpty(project)) {
return new JsonMessage(401, "项目路径白名单不能为空"); return new JsonMessage<>(401, "项目路径白名单不能为空");
} }
List<String> list = StrSpliter.splitTrim(project, StrUtil.LF, true); List<String> list = StrSpliter.splitTrim(project, StrUtil.LF, true);
if (list == null || list.size() <= 0) { if (list == null || list.size() <= 0) {
return new JsonMessage(401, "项目路径白名单不能为空"); return new JsonMessage<>(401, "项目路径白名单不能为空");
} }
return save(list, certificate, nginx); return save(list, certificate, nginx);
} }
private JsonMessage save(List<String> projects, List<String> certificate, List<String> nginx) { private JsonMessage<String> save(List<String> projects, List<String> certificate, List<String> nginx) {
List<String> projectArray; List<String> projectArray;
{ {
projectArray = AgentWhitelist.covertToArray(projects); projectArray = AgentWhitelist.covertToArray(projects);
if (projectArray == null) { if (projectArray == null) {
return new JsonMessage(401, "项目路径白名单不能位于Jpom目录下"); return new JsonMessage<>(401, "项目路径白名单不能位于Jpom目录下");
} }
if (projectArray.isEmpty()) { if (projectArray.isEmpty()) {
return new JsonMessage(401, "项目路径白名单不能为空"); return new JsonMessage<>(401, "项目路径白名单不能为空");
} }
String error = findStartsWith(projectArray, 0); String error = findStartsWith(projectArray, 0);
if (error != null) { if (error != null) {
return new JsonMessage(401, "白名单目录中不能存在包含关系:" + error); return new JsonMessage<>(401, "白名单目录中不能存在包含关系:" + error);
} }
} }
List<String> certificateArray = null; List<String> certificateArray = null;
if (certificate != null && !certificate.isEmpty()) { if (certificate != null && !certificate.isEmpty()) {
certificateArray = AgentWhitelist.covertToArray(certificate); certificateArray = AgentWhitelist.covertToArray(certificate);
if (certificateArray == null) { if (certificateArray == null) {
return new JsonMessage(401, "证书路径白名单不能位于Jpom目录下"); return new JsonMessage<>(401, "证书路径白名单不能位于Jpom目录下");
} }
if (certificateArray.isEmpty()) { if (certificateArray.isEmpty()) {
return new JsonMessage(401, "证书路径白名单不能为空"); return new JsonMessage<>(401, "证书路径白名单不能为空");
} }
String error = findStartsWith(certificateArray, 0); String error = findStartsWith(certificateArray, 0);
if (error != null) { if (error != null) {
return new JsonMessage(401, "证书目录中不能存在包含关系:" + error); return new JsonMessage<>(401, "证书目录中不能存在包含关系:" + error);
} }
} }
List<String> nginxArray = null; List<String> nginxArray = null;
if (nginx != null && !nginx.isEmpty()) { if (nginx != null && !nginx.isEmpty()) {
nginxArray = AgentWhitelist.covertToArray(nginx); nginxArray = AgentWhitelist.covertToArray(nginx);
if (nginxArray == null) { if (nginxArray == null) {
return new JsonMessage(401, "nginx路径白名单不能位于Jpom目录下"); return new JsonMessage<>(401, "nginx路径白名单不能位于Jpom目录下");
} }
if (nginxArray.isEmpty()) { if (nginxArray.isEmpty()) {
return new JsonMessage(401, "nginx路径白名单不能为空"); return new JsonMessage<>(401, "nginx路径白名单不能为空");
} }
String error = findStartsWith(nginxArray, 0); String error = findStartsWith(nginxArray, 0);
if (error != null) { if (error != null) {
return new JsonMessage(401, "nginx目录中不能存在包含关系" + error); return new JsonMessage<>(401, "nginx目录中不能存在包含关系" + error);
} }
} }
AgentWhitelist agentWhitelist = whitelistDirectoryService.getWhitelist(); AgentWhitelist agentWhitelist = whitelistDirectoryService.getWhitelist();
@ -115,7 +115,7 @@ public class WhitelistDirectoryController extends BaseJpomController {
agentWhitelist.setCertificate(certificateArray); agentWhitelist.setCertificate(certificateArray);
agentWhitelist.setNginx(nginxArray); agentWhitelist.setNginx(nginxArray);
whitelistDirectoryService.saveWhitelistDirectory(agentWhitelist); whitelistDirectoryService.saveWhitelistDirectory(agentWhitelist);
return new JsonMessage(200, "保存成功"); return new JsonMessage<>(200, "保存成功");
} }
/** /**