|
@@ -426,57 +426,48 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public Map<String, Object> setScheduleState(User loginUser,
|
|
+ public void setScheduleState(User loginUser,
|
|
- long projectCode,
|
|
+ long projectCode,
|
|
- Integer id,
|
|
+ Integer id,
|
|
- ReleaseState scheduleStatus) {
|
|
+ ReleaseState scheduleStatus) {
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
|
-
|
|
|
|
Project project = projectMapper.queryByCode(projectCode);
|
|
Project project = projectMapper.queryByCode(projectCode);
|
|
|
|
|
|
- boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result, null);
|
|
+ projectService.checkProjectAndAuthThrowException(loginUser, project, null);
|
|
- if (!hasProjectAndPerm) {
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
Schedule scheduleObj = scheduleMapper.selectById(id);
|
|
Schedule scheduleObj = scheduleMapper.selectById(id);
|
|
|
|
|
|
if (scheduleObj == null) {
|
|
if (scheduleObj == null) {
|
|
logger.error("Schedule does not exist, scheduleId:{}.", id);
|
|
logger.error("Schedule does not exist, scheduleId:{}.", id);
|
|
- putMsg(result, Status.SCHEDULE_CRON_NOT_EXISTS, id);
|
|
+ throw new ServiceException(Status.SCHEDULE_CRON_NOT_EXISTS, id);
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (scheduleObj.getReleaseState() == scheduleStatus) {
|
|
if (scheduleObj.getReleaseState() == scheduleStatus) {
|
|
logger.warn("Schedule state does not need to change due to schedule state is already {}, scheduleId:{}.",
|
|
logger.warn("Schedule state does not need to change due to schedule state is already {}, scheduleId:{}.",
|
|
scheduleObj.getReleaseState().getDescp(), scheduleObj.getId());
|
|
scheduleObj.getReleaseState().getDescp(), scheduleObj.getId());
|
|
- putMsg(result, Status.SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE, scheduleStatus);
|
|
+ throw new ServiceException(Status.SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE, scheduleStatus);
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
ProcessDefinition processDefinition =
|
|
ProcessDefinition processDefinition =
|
|
processDefinitionMapper.queryByCode(scheduleObj.getProcessDefinitionCode());
|
|
processDefinitionMapper.queryByCode(scheduleObj.getProcessDefinitionCode());
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) {
|
|
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) {
|
|
logger.error("Process definition does not exist, processDefinitionCode:{}.",
|
|
logger.error("Process definition does not exist, processDefinitionCode:{}.",
|
|
scheduleObj.getProcessDefinitionCode());
|
|
scheduleObj.getProcessDefinitionCode());
|
|
- putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(scheduleObj.getProcessDefinitionCode()));
|
|
+ throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST,
|
|
- return result;
|
|
+ String.valueOf(scheduleObj.getProcessDefinitionCode()));
|
|
}
|
|
}
|
|
List<ProcessTaskRelation> processTaskRelations =
|
|
List<ProcessTaskRelation> processTaskRelations =
|
|
processTaskRelationMapper.queryByProcessCode(projectCode, scheduleObj.getProcessDefinitionCode());
|
|
processTaskRelationMapper.queryByProcessCode(projectCode, scheduleObj.getProcessDefinitionCode());
|
|
if (processTaskRelations.isEmpty()) {
|
|
if (processTaskRelations.isEmpty()) {
|
|
logger.error("Process task relations do not exist, projectCode:{}, processDefinitionCode:{}.", projectCode,
|
|
logger.error("Process task relations do not exist, projectCode:{}, processDefinitionCode:{}.", projectCode,
|
|
processDefinition.getCode());
|
|
processDefinition.getCode());
|
|
- putMsg(result, Status.PROCESS_DAG_IS_EMPTY);
|
|
+ throw new ServiceException(Status.PROCESS_DAG_IS_EMPTY);
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
if (scheduleStatus == ReleaseState.ONLINE) {
|
|
if (scheduleStatus == ReleaseState.ONLINE) {
|
|
|
|
|
|
if (processDefinition.getReleaseState() != ReleaseState.ONLINE) {
|
|
if (processDefinition.getReleaseState() != ReleaseState.ONLINE) {
|
|
logger.warn("Only process definition state is {} can change schedule state, processDefinitionCode:{}.",
|
|
logger.warn("Only process definition state is {} can change schedule state, processDefinitionCode:{}.",
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode());
|
|
ReleaseState.ONLINE.getDescp(), processDefinition.getCode());
|
|
- putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinition.getName());
|
|
+ throw new ServiceException(Status.PROCESS_DEFINE_NOT_RELEASE, processDefinition.getName());
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
List<Long> subProcessDefineCodes = new ArrayList<>();
|
|
List<Long> subProcessDefineCodes = new ArrayList<>();
|
|
@@ -496,9 +487,8 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|
logger.warn(
|
|
logger.warn(
|
|
"Only sub process definition state is {} can change schedule state, subProcessDefinitionCode:{}.",
|
|
"Only sub process definition state is {} can change schedule state, subProcessDefinitionCode:{}.",
|
|
ReleaseState.ONLINE.getDescp(), subProcessDefinition.getCode());
|
|
ReleaseState.ONLINE.getDescp(), subProcessDefinition.getCode());
|
|
- putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE,
|
|
+ throw new ServiceException(Status.PROCESS_DEFINE_NOT_RELEASE,
|
|
String.valueOf(subProcessDefinition.getId()));
|
|
String.valueOf(subProcessDefinition.getId()));
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -510,8 +500,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|
|
|
|
|
if (masterServers.isEmpty()) {
|
|
if (masterServers.isEmpty()) {
|
|
logger.error("Master does not exist.");
|
|
logger.error("Master does not exist.");
|
|
- putMsg(result, Status.MASTER_NOT_EXISTS);
|
|
+ throw new ServiceException(Status.MASTER_NOT_EXISTS);
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -532,20 +521,15 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|
deleteSchedule(project.getId(), id);
|
|
deleteSchedule(project.getId(), id);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- putMsg(result, Status.SCHEDULE_STATUS_UNKNOWN, scheduleStatus.toString());
|
|
+ throw new ServiceException(Status.SCHEDULE_STATUS_UNKNOWN, scheduleStatus.toString());
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.error("Set schedule state to {} error, projectCode:{}, scheduleId:{}.", scheduleStatus.getDescp(),
|
|
logger.error("Set schedule state to {} error, projectCode:{}, scheduleId:{}.", scheduleStatus.getDescp(),
|
|
projectCode, scheduleObj.getId());
|
|
projectCode, scheduleObj.getId());
|
|
Status status = scheduleStatus == ReleaseState.ONLINE ? Status.PUBLISH_SCHEDULE_ONLINE_ERROR
|
|
Status status = scheduleStatus == ReleaseState.ONLINE ? Status.PUBLISH_SCHEDULE_ONLINE_ERROR
|
|
: Status.OFFLINE_SCHEDULE_ERROR;
|
|
: Status.OFFLINE_SCHEDULE_ERROR;
|
|
- result.put(Constants.STATUS, status);
|
|
|
|
throw new ServiceException(status, e);
|
|
throw new ServiceException(status, e);
|
|
}
|
|
}
|
|
-
|
|
|
|
- putMsg(result, Status.SUCCESS);
|
|
|
|
- return result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|