mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-04 21:28:00 +08:00
[Improvement-14311][Permission]Remove duplicate checkProjectAndAuth (#14313)
This commit is contained in:
parent
221df4a278
commit
5250b253eb
@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_DEFINITION_MOVE;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_DELETE;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VERSION_LIST;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_BATCH_COPY;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.WORKFLOW_CREATE;
|
||||
@ -282,8 +281,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_CREATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -765,8 +763,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
ProcessExecutionTypeEnum executionType) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_UPDATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -2397,8 +2394,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
int version) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, VERSION_DELETE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -2459,8 +2455,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
ProcessExecutionTypeEnum executionType) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_CREATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -2595,8 +2590,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
ProcessExecutionTypeEnum executionType) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_UPDATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
|
@ -155,8 +155,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
||||
String taskDefinitionJson) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -300,8 +299,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
||||
String upstreamCodes) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
@ -1071,8 +1069,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
||||
public Map<String, Object> deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) {
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
// check if user have write perm for project
|
||||
Map<String, Object> result =
|
||||
projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_DELETE);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
|
||||
if (!hasProjectAndWritePerm) {
|
||||
return result;
|
||||
|
@ -810,12 +810,9 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool {
|
||||
@Test
|
||||
public void testUpdateProcessDefinition() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
Project project = getProject(projectCode);
|
||||
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
|
||||
Mockito.when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_UPDATE))
|
||||
.thenReturn(result);
|
||||
Mockito.when(projectService.hasProjectAndWritePerm(user, project, result)).thenReturn(true);
|
||||
|
||||
try {
|
||||
|
@ -156,9 +156,9 @@ public class TaskDefinitionServiceImplTest {
|
||||
Mockito.when(projectMapper.queryByCode(PROJECT_CODE)).thenReturn(project);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
putMsg(result, Status.SUCCESS, PROJECT_CODE);
|
||||
Mockito.when(projectService.checkProjectAndAuth(user, project, PROJECT_CODE, TASK_DEFINITION_CREATE))
|
||||
.thenReturn(result);
|
||||
Mockito.when(projectService.hasProjectAndWritePerm(user, project, result))
|
||||
.thenReturn(true);
|
||||
Mockito.when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true);
|
||||
|
||||
String createTaskDefinitionJson =
|
||||
"[{\"name\":\"detail_up\",\"description\":\"\",\"taskType\":\"SHELL\",\"taskParams\":"
|
||||
|
Loading…
Reference in New Issue
Block a user