diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index 0d45e7dd35..77e82312d4 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_CREATE); + Map 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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_UPDATE); + Map 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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, VERSION_DELETE); + Map 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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_CREATE); + Map 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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_UPDATE); + Map result = new HashMap<>(); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return result; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java index a19f69496c..838744767a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java @@ -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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE); + Map 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 result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_CREATE); + Map 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 deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) { Project project = projectMapper.queryByCode(projectCode); // check if user have write perm for project - Map result = - projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_DEFINITION_DELETE); + Map result = new HashMap<>(); boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result); if (!hasProjectAndWritePerm) { return result; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java index f1a0a66213..62d5496d05 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java @@ -810,12 +810,9 @@ public class ProcessDefinitionServiceTest extends BaseServiceTestTool { @Test public void testUpdateProcessDefinition() { Map 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 { diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java index 391769627f..26091e7529 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java @@ -156,9 +156,9 @@ public class TaskDefinitionServiceImplTest { Mockito.when(projectMapper.queryByCode(PROJECT_CODE)).thenReturn(project); Map 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\":"