Commit 77a9cae7 by huangfusuper

校验虚节点

parent 97417284
...@@ -36,7 +36,7 @@ public interface ApiFlowService { ...@@ -36,7 +36,7 @@ public interface ApiFlowService {
* @param flow * @param flow
* @return * @return
*/ */
void validateFlow(Integer workspaceId, PluginFlow flow); void validateFlow(Integer workspaceId, PluginFlow flow, boolean isInner);
/** /**
* 重跑任务 * 重跑任务
......
...@@ -158,10 +158,10 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -158,10 +158,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flow.setTriggerNextTime(StringUtils.isEmpty(pluginFlow.getConfig().getFlowCron()) ? null : new CronExpression(pluginFlow.getConfig().getFlowCron()).getNextValidTimeAfter(new Date()).getTime()); flow.setTriggerNextTime(StringUtils.isEmpty(pluginFlow.getConfig().getFlowCron()) ? null : new CronExpression(pluginFlow.getConfig().getFlowCron()).getNextValidTimeAfter(new Date()).getTime());
//设置超时时间,未设置默认30分钟 //设置超时时间,未设置默认30分钟
flow.setFlowTimeout(null == pluginFlow.getConfig().getFlowTimeout() ? 1000 * 60 * 120 : pluginFlow.getConfig().getFlowTimeout()); flow.setFlowTimeout(null == pluginFlow.getConfig().getFlowTimeout() ? 1000 * 60 * 120 : pluginFlow.getConfig().getFlowTimeout());
Flow oldFlow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName());
//判断是否是重发 //判断是否是重发
if (pluginFlow.isRePublish()){ if ((pluginFlow.isRePublish() && !isInnner) || (isInnner && null != oldFlow)){
Flow oldFlow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName());
String version = oldFlow.getVersionName(); String version = oldFlow.getVersionName();
Integer versionTag = Integer.valueOf(version.split("\\.")[1]); Integer versionTag = Integer.valueOf(version.split("\\.")[1]);
flow.setFlowId(oldFlow.getFlowId()); flow.setFlowId(oldFlow.getFlowId());
...@@ -339,7 +339,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -339,7 +339,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
PluginFlow flow = pluginPackage.getFlow(); PluginFlow flow = pluginPackage.getFlow();
//校验工作流参数配置 //校验工作流参数配置
validateFlow(workspace.getWorkspaceId(), flow); validateFlow(workspace.getWorkspaceId(), flow, false);
//校验工作流名称是否重复 //校验工作流名称是否重复
HashSet<String> flowNameSet = new HashSet<>(); HashSet<String> flowNameSet = new HashSet<>();
//用来工作流的内嵌关系 //用来工作流的内嵌关系
...@@ -383,7 +383,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -383,7 +383,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil.isTrueValidation(!(node instanceof PluginFlow), "工作流的type设置错误,只有当节点为内嵌工作流是type才允许设置为flow"); ValidationUtil.isTrueValidation(!(node instanceof PluginFlow), "工作流的type设置错误,只有当节点为内嵌工作流是type才允许设置为flow");
//校验父工作流和内嵌工作流的执行类型是否一致 //校验父工作流和内嵌工作流的执行类型是否一致
ValidationUtil.isTrueValidation(!(flow.getConfig().getExecType().equals(((PluginFlow) node).getConfig().getExecType())), "内嵌工作流的调度配置必须和父工作流配置保持一致!"); ValidationUtil.isTrueValidation(!(flow.getConfig().getExecType().equals(((PluginFlow) node).getConfig().getExecType())), "内嵌工作流的调度配置必须和父工作流配置保持一致!");
validateFlow(workspace.getWorkspaceId(), (PluginFlow) node); validateFlow(workspace.getWorkspaceId(), (PluginFlow) node, true);
if(FlowPropertyEnum.NO_SCHEDULE.getCode().equals(flow.getConfig().getScheduleFollow())){ if(FlowPropertyEnum.NO_SCHEDULE.getCode().equals(flow.getConfig().getScheduleFollow())){
ValidationUtil.dataNotBank( ((PluginFlow) node).getConfig().getFlowCron(), "工作流设置为不跟随调度时节点必须设置调度时间!"); ValidationUtil.dataNotBank( ((PluginFlow) node).getConfig().getFlowCron(), "工作流设置为不跟随调度时节点必须设置调度时间!");
} }
...@@ -419,7 +419,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -419,7 +419,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
} }
@Override @Override
public void validateFlow(Integer workspaceId, PluginFlow pluginFlow) { public void validateFlow(Integer workspaceId, PluginFlow pluginFlow, boolean isInner) {
ValidationUtil.dataNotBank(pluginFlow.getName(), "工作流名称不允许为空!"); ValidationUtil.dataNotBank(pluginFlow.getName(), "工作流名称不允许为空!");
ValidationUtil.dataNotNull(pluginFlow.getNodeList(), "工作流下属节点不允许为空!"); ValidationUtil.dataNotNull(pluginFlow.getNodeList(), "工作流下属节点不允许为空!");
ValidationUtil.dataNotNull(pluginFlow.getConfig(), "工作流配置不允许为空!"); ValidationUtil.dataNotNull(pluginFlow.getConfig(), "工作流配置不允许为空!");
...@@ -434,7 +434,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -434,7 +434,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
Flow flow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName()); Flow flow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName());
//判断是否是重发 //判断是否是重发
//是重发 //是重发
if (pluginFlow.isRePublish()){ if (pluginFlow.isRePublish() && !isInner){
ValidationUtil.dataNotNull(flow, "工作流【"+ pluginFlow.getName() + "】不存在!"); ValidationUtil.dataNotNull(flow, "工作流【"+ pluginFlow.getName() + "】不存在!");
}else {//不是重发 }else {//不是重发
ValidationUtil.isTrueValidation(null != flow, "工作流【"+ pluginFlow.getName() + "】已存在!"); ValidationUtil.isTrueValidation(null != flow, "工作流【"+ pluginFlow.getName() + "】已存在!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment