diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebScriptResource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebScriptResource.java index 1a87e6cd33..7957d89b42 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebScriptResource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebScriptResource.java @@ -314,7 +314,7 @@ Response publishScriptVersion( Long scriptVersionId ); - @ApiOperation(value = "下线脚本", produces = "application/json") + @ApiOperation(value = "禁用脚本", produces = "application/json") @PutMapping("/scope/{scopeType}/{scopeId}/script/{scriptId}/scriptVersion/{scriptVersionId}/disable") Response disableScriptVersion( @ApiParam("用户名,网关自动传入") diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/common/consts/JobResourceStatusEnum.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/common/consts/JobResourceStatusEnum.java index 955e99dd41..3cceb51a7e 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/common/consts/JobResourceStatusEnum.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/common/consts/JobResourceStatusEnum.java @@ -26,13 +26,11 @@ /** * JOB资源状态 - * - * @date 2019/09/19 */ public enum JobResourceStatusEnum { /** - * 未上线-草稿 + * 未上线 */ DRAFT(0), /** @@ -48,7 +46,7 @@ public enum JobResourceStatusEnum { */ DISABLED(3); - private int status; + private final int status; JobResourceStatusEnum(int status) { this.status = status; @@ -67,7 +65,7 @@ public static JobResourceStatusEnum getJobResourceStatus(Integer status) { } else if (status == OFFLINE.getValue()) { return OFFLINE; } else { - return null; + throw new IllegalArgumentException("No JobResourceStatusEnum constant: " + status); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java index 686aa0d552..ad995ed95f 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/ScriptServiceImpl.java @@ -634,7 +634,8 @@ public void disableScript( throw new NotFoundException(ErrorCode.SCRIPT_NOT_EXIST); } - if (!scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.ONLINE.getValue())) { + if (!scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.ONLINE.getValue()) + && !scriptVersionToBeDisabled.getStatus().equals(JobResourceStatusEnum.OFFLINE.getValue())) { log.warn("Disable script, scriptVersion:{}, status:{} could not disable", scriptVersionId, scriptVersionToBeDisabled.getStatus()); throw new FailedPreconditionException(ErrorCode.UNSUPPORTED_OPERATION);