mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
[dev] parametric verification
This commit is contained in:
parent
50ad38ba0b
commit
404a5bb953
@ -3,6 +3,7 @@ package com.github.kfcfans.powerjob.common.request.http;
|
|||||||
import com.github.kfcfans.powerjob.common.ExecuteType;
|
import com.github.kfcfans.powerjob.common.ExecuteType;
|
||||||
import com.github.kfcfans.powerjob.common.ProcessorType;
|
import com.github.kfcfans.powerjob.common.ProcessorType;
|
||||||
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
||||||
|
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -76,4 +77,14 @@ public class SaveJobInfoRequest {
|
|||||||
|
|
||||||
// 报警用户ID列表
|
// 报警用户ID列表
|
||||||
private List<Long> notifyUserIds;
|
private List<Long> notifyUserIds;
|
||||||
|
|
||||||
|
|
||||||
|
public void valid() {
|
||||||
|
CommonUtils.requireNonNull(jobName, "jobName can't be empty");
|
||||||
|
CommonUtils.requireNonNull(appId, "appId can't be empty");
|
||||||
|
CommonUtils.requireNonNull(processorInfo, "processorInfo can't be empty");
|
||||||
|
CommonUtils.requireNonNull(executeType, "executeType can't be empty");
|
||||||
|
CommonUtils.requireNonNull(processorType, "processorType can't be empty");
|
||||||
|
CommonUtils.requireNonNull(timeExpressionType, "timeExpressionType can't be empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.github.kfcfans.powerjob.common.request.http;
|
|||||||
|
|
||||||
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
import com.github.kfcfans.powerjob.common.TimeExpressionType;
|
||||||
import com.github.kfcfans.powerjob.common.model.PEWorkflowDAG;
|
import com.github.kfcfans.powerjob.common.model.PEWorkflowDAG;
|
||||||
|
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -43,4 +44,11 @@ public class SaveWorkflowRequest {
|
|||||||
|
|
||||||
// 工作流整体失败的报警
|
// 工作流整体失败的报警
|
||||||
private List<Long> notifyUserIds = Lists.newLinkedList();
|
private List<Long> notifyUserIds = Lists.newLinkedList();
|
||||||
|
|
||||||
|
public void valid() {
|
||||||
|
CommonUtils.requireNonNull(wfName, "workflow name can't be empty");
|
||||||
|
CommonUtils.requireNonNull(appId, "appId can't be empty");
|
||||||
|
CommonUtils.requireNonNull(pEWorkflowDAG, "dag can't be empty");
|
||||||
|
CommonUtils.requireNonNull(timeExpressionType, "timeExpressionType can't be empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.github.kfcfans.powerjob.common.utils;
|
package com.github.kfcfans.powerjob.common.utils;
|
||||||
|
|
||||||
|
import com.github.kfcfans.powerjob.common.OmsException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
@ -114,4 +117,16 @@ public class CommonUtils {
|
|||||||
return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
|
return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T requireNonNull(T obj, String msg) {
|
||||||
|
if (obj == null) {
|
||||||
|
throw new OmsException(msg);
|
||||||
|
}
|
||||||
|
if (obj instanceof String) {
|
||||||
|
if (StringUtils.isEmpty((String) obj)) {
|
||||||
|
throw new OmsException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ public class ContainerService {
|
|||||||
* @param request 容器保存请求
|
* @param request 容器保存请求
|
||||||
*/
|
*/
|
||||||
public void save(SaveContainerInfoRequest request) {
|
public void save(SaveContainerInfoRequest request) {
|
||||||
|
|
||||||
|
request.valid();
|
||||||
|
|
||||||
ContainerInfoDO container;
|
ContainerInfoDO container;
|
||||||
Long originId = request.getId();
|
Long originId = request.getId();
|
||||||
if (originId != null) {
|
if (originId != null) {
|
||||||
|
@ -52,6 +52,8 @@ public class JobService {
|
|||||||
*/
|
*/
|
||||||
public Long saveJob(SaveJobInfoRequest request) throws Exception {
|
public Long saveJob(SaveJobInfoRequest request) throws Exception {
|
||||||
|
|
||||||
|
request.valid();
|
||||||
|
|
||||||
JobInfoDO jobInfoDO;
|
JobInfoDO jobInfoDO;
|
||||||
if (request.getId() != null) {
|
if (request.getId() != null) {
|
||||||
jobInfoDO = jobInfoRepository.findById(request.getId()).orElseThrow(() -> new IllegalArgumentException("can't find job by jobId: " + request.getId()));
|
jobInfoDO = jobInfoRepository.findById(request.getId()).orElseThrow(() -> new IllegalArgumentException("can't find job by jobId: " + request.getId()));
|
||||||
|
@ -39,6 +39,8 @@ public class WorkflowService {
|
|||||||
*/
|
*/
|
||||||
public Long saveWorkflow(SaveWorkflowRequest req) throws Exception {
|
public Long saveWorkflow(SaveWorkflowRequest req) throws Exception {
|
||||||
|
|
||||||
|
req.valid();
|
||||||
|
|
||||||
if (!WorkflowDAGUtils.valid(req.getPEWorkflowDAG())) {
|
if (!WorkflowDAGUtils.valid(req.getPEWorkflowDAG())) {
|
||||||
throw new OmsException("illegal DAG");
|
throw new OmsException("illegal DAG");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.kfcfans.powerjob.server.web.request;
|
package com.github.kfcfans.powerjob.server.web.request;
|
||||||
|
|
||||||
|
import com.github.kfcfans.powerjob.common.utils.CommonUtils;
|
||||||
import com.github.kfcfans.powerjob.server.common.constans.ContainerSourceType;
|
import com.github.kfcfans.powerjob.server.common.constans.ContainerSourceType;
|
||||||
import com.github.kfcfans.powerjob.server.common.constans.SwitchableStatus;
|
import com.github.kfcfans.powerjob.server.common.constans.SwitchableStatus;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -29,4 +30,10 @@ public class SaveContainerInfoRequest {
|
|||||||
|
|
||||||
// 状态,枚举值为 ContainerStatus(ENABLE/DISABLE)
|
// 状态,枚举值为 ContainerStatus(ENABLE/DISABLE)
|
||||||
private SwitchableStatus status;
|
private SwitchableStatus status;
|
||||||
|
|
||||||
|
public void valid() {
|
||||||
|
CommonUtils.requireNonNull(containerName, "containerName can't be empty");
|
||||||
|
CommonUtils.requireNonNull(appId, "appId can't be empty");
|
||||||
|
CommonUtils.requireNonNull(sourceInfo, "sourceInfo can't be empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _bar
|
|||||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: \"Navbar\",\n data: function data() {\n return {\n changeAppInfoDialogVisible: false,\n appInfo: {\n id: this.$store.state.appInfo.id,\n appName: this.$store.state.appInfo.appName,\n password: undefined,\n password2: undefined\n }\n };\n },\n methods: {\n // 退出当前应用\n onClickCloseConsole: function onClickCloseConsole() {\n window.localStorage.removeItem('oms_auto_login');\n this.$router.push(\"/\");\n },\n // 处理系统设置的指令时间\n handleSettings: function handleSettings(cmd) {\n switch (cmd) {\n case \"logout\":\n this.onClickCloseConsole();\n break;\n\n case \"changeAppInfo\":\n this.changeAppInfoDialogVisible = true;\n break;\n }\n },\n // 更新应用信息\n saveNewAppInfo: function saveNewAppInfo() {\n var _this = this;\n\n if (this.appInfo.password === this.appInfo.password2) {\n var that = this;\n this.axios.post(\"/appInfo/save\", this.appInfo).then(function () {\n that.$message.success(_this.$t('message.success'));\n that.$router.push(\"/\");\n }, function (e) {\n return that.$message.error(e);\n });\n }\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/bar/Navbar.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
eval("__webpack_require__.r(__webpack_exports__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n name: \"Navbar\",\n data: function data() {\n return {\n changeAppInfoDialogVisible: false,\n appInfo: {\n id: this.$store.state.appInfo.id,\n appName: this.$store.state.appInfo.appName,\n password: undefined,\n password2: undefined\n }\n };\n },\n methods: {\n // 退出当前应用\n onClickCloseConsole: function onClickCloseConsole() {\n window.localStorage.removeItem('oms_auto_login');\n this.$router.push(\"/\");\n },\n // 处理系统设置的指令时间\n handleSettings: function handleSettings(cmd) {\n switch (cmd) {\n case \"logout\":\n this.onClickCloseConsole();\n break;\n\n case \"changeAppInfo\":\n this.changeAppInfoDialogVisible = true;\n break;\n }\n },\n // 更新应用信息\n saveNewAppInfo: function saveNewAppInfo() {\n var _this = this;\n\n if (this.appInfo.password === this.appInfo.password2) {\n var that = this;\n this.axios.post(\"/appInfo/save\", this.appInfo).then(function () {\n that.$message.success(_this.$t('message.success'));\n that.$router.push(\"/\");\n }, function (e) {\n return that.$message.error(e);\n });\n } else {\n this.$message.error(\"the password doesn't match\");\n }\n }\n }\n});\n\n//# sourceURL=webpack:///./src/components/bar/Navbar.vue?./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public class OmsContainerFactory {
|
|||||||
public static void destroyContainer(Long containerId) {
|
public static void destroyContainer(Long containerId) {
|
||||||
OmsContainer container = CARGO.remove(containerId);
|
OmsContainer container = CARGO.remove(containerId);
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
log.warn("[OmsContainer-{}] container not exists.", containerId);
|
log.info("[OmsContainer-{}] container not exists, so there is no need to destroy the container.", containerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user