[Feature][dolphinscheduler-api] access control of taskDefinition and taskInstance in project to #7081 (#7082)
* to #7081 * fix #7081 * to #7081 Co-authored-by: honghuo.zw <honghuo.zw@alibaba-inc.com>
This commit is contained in:
parent
3de182dc08
commit
2bf73603bb
|
|
@ -191,6 +191,10 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|||
return result;
|
||||
}
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
|
||||
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
|
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
|
||||
return result;
|
||||
}
|
||||
if (taskDefinition.getFlag() == Flag.YES) {
|
||||
putMsg(result, Status.TASK_DEFINE_STATE_ONLINE, taskCode);
|
||||
return result;
|
||||
|
|
@ -329,7 +333,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|||
return result;
|
||||
}
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
|
||||
if (taskDefinition == null) {
|
||||
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
|
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -364,7 +368,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|||
}
|
||||
PageInfo<TaskDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
Page<TaskDefinitionLog> page = new Page<>(pageNo, pageSize);
|
||||
IPage<TaskDefinitionLog> taskDefinitionVersionsPaging = taskDefinitionLogMapper.queryTaskDefinitionVersionsPaging(page, taskCode);
|
||||
IPage<TaskDefinitionLog> taskDefinitionVersionsPaging = taskDefinitionLogMapper.queryTaskDefinitionVersionsPaging(page, taskCode, projectCode);
|
||||
List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionVersionsPaging.getRecords();
|
||||
|
||||
pageInfo.setTotalList(taskDefinitionLogs);
|
||||
|
|
@ -411,7 +415,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|||
}
|
||||
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
|
||||
if (taskDefinition == null) {
|
||||
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
|
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
|
||||
} else {
|
||||
result.put(Constants.DATA_LIST, taskDefinition);
|
||||
|
|
@ -506,7 +510,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|||
return result;
|
||||
}
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(code);
|
||||
if (taskDefinition == null) {
|
||||
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
|
||||
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, code);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
|||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.Project;
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
|
||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||
|
||||
|
|
@ -71,6 +73,9 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
|
|||
@Autowired
|
||||
UsersService usersService;
|
||||
|
||||
@Autowired
|
||||
TaskDefinitionMapper taskDefinitionMapper;
|
||||
|
||||
/**
|
||||
* query task list by project, process instance, task name, task start time, task end time, task status, keyword paging
|
||||
*
|
||||
|
|
@ -171,6 +176,12 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
|
|||
return result;
|
||||
}
|
||||
|
||||
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(task.getTaskCode());
|
||||
if (taskDefinition != null && projectCode != taskDefinition.getProjectCode()) {
|
||||
putMsg(result, Status.TASK_INSTANCE_NOT_FOUND, taskInstanceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
// check whether the task instance state type is failure or cancel
|
||||
if (!task.getState().typeIsFailure() && !task.getState().typeIsCancel()) {
|
||||
putMsg(result, Status.TASK_INSTANCE_STATE_OPERATION_ERROR, taskInstanceId, task.getState().toString());
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ public interface TaskDefinitionLogMapper extends BaseMapper<TaskDefinitionLog> {
|
|||
* query the paging task definition version list by pagination info
|
||||
*
|
||||
* @param page pagination info
|
||||
* @param projectCode project code
|
||||
* @param code process definition code
|
||||
* @return the paging task definition version list
|
||||
*/
|
||||
IPage<TaskDefinitionLog> queryTaskDefinitionVersionsPaging(Page<TaskDefinitionLog> page, @Param("code") long code);
|
||||
IPage<TaskDefinitionLog> queryTaskDefinitionVersionsPaging(Page<TaskDefinitionLog> page, @Param("code") long code, @Param("projectCode") long projectCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@
|
|||
<include refid="baseSql"/>
|
||||
from t_ds_task_definition_log
|
||||
where code = #{code}
|
||||
<if test="projectCode != 0">
|
||||
and project_code = #{projectCode}
|
||||
</if>
|
||||
order by version desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue