status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
βŒ€
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
unknown
language
stringclasses
5 values
commit_datetime
unknown
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
* * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.server; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.QueueService; import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.service.TenantService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import py4j.GatewayServer; @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { @ComponentScan.Filter(type = FilterType.REGEX, pattern = { "org.apache.dolphinscheduler.server.master.*", "org.apache.dolphinscheduler.server.worker.*",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
"org.apache.dolphinscheduler.server.monitor.*", "org.apache.dolphinscheduler.server.log.*", "org.apache.dolphinscheduler.alert.*" }) }) public class PythonGatewayServer extends SpringBootServletInitializer { private static final Logger LOGGER = LoggerFactory.getLogger(PythonGatewayServer.class); private static final WarningType DEFAULT_WARNING_TYPE = WarningType.NONE; private static final int DEFAULT_WARNING_GROUP_ID = 0; private static final FailureStrategy DEFAULT_FAILURE_STRATEGY = FailureStrategy.CONTINUE; private static final Priority DEFAULT_PRIORITY = Priority.MEDIUM; private static final Long DEFAULT_ENVIRONMENT_CODE = -1L; private static final TaskDependType DEFAULT_TASK_DEPEND_TYPE = TaskDependType.TASK_POST; private static final RunMode DEFAULT_RUN_MODE = RunMode.RUN_MODE_SERIAL; private static final int DEFAULT_DRY_RUN = 0; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProjectService projectService; @Autowired private TenantService tenantService; @Autowired private ExecutorService executorService; @Autowired private ProcessDefinitionService processDefinitionService; @Autowired private TaskDefinitionService taskDefinitionService; @Autowired private UsersService usersService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
@Autowired private QueueService queueService; @Autowired private ProjectMapper projectMapper; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private SchedulerService schedulerService; @Autowired private ScheduleMapper scheduleMapper; @Autowired private DataSourceMapper dataSourceMapper; private final User dummyAdminUser = new User() { { setId(Integer.MAX_VALUE); setUserName("dummyUser"); setUserType(UserType.ADMIN_USER); } }; private final Queue queuePythonGateway = new Queue() { { setId(Integer.MAX_VALUE); setQueueName("queuePythonGateway"); } }; public String ping() { return "PONG"; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
public Map<String, Object> genTaskCodeList(Integer genNum) { return taskDefinitionService.genTaskCodeList(genNum); } public Map<String, Long> getCodeAndVersion(String projectName, String taskName) throws CodeGenerateUtils.CodeGenerateException { Project project = projectMapper.queryByName(projectName); Map<String, Long> result = new HashMap<>(); if (project == null) { result.put("code", CodeGenerateUtils.getInstance().genCode()); result.put("version", 0L); return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), taskName); if (taskDefinition == null) { result.put("code", CodeGenerateUtils.getInstance().genCode()); result.put("version", 0L); } else { result.put("code", taskDefinition.getCode()); result.put("version", (long) taskDefinition.getVersion()); } return result; } /** * create or update process definition. * If process definition do not exists in Project=`projectCode` would create a new one * If process definition already exists in Project=`projectCode` would update it * * @param userName user name who create or update process definition * @param projectName project name which process definition belongs to
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
* @param name process definition name * @param description description * @param globalParams global params * @param schedule schedule for process definition, will not set schedule if null, * and if would always fresh exists schedule if not null * @param locations locations json object about all tasks * @param timeout timeout for process definition working, if running time longer than timeout, * task will mark as fail * @param workerGroup run task in which worker group * @param tenantCode tenantCode * @param taskRelationJson relation json for nodes * @param taskDefinitionJson taskDefinitionJson * @return create result code */ public Long createOrUpdateProcessDefinition(String userName, String projectName, String name, String description, String globalParams, String schedule, String locations, int timeout, String workerGroup, String tenantCode, String taskRelationJson, String taskDefinitionJson, ProcessExecutionTypeEnum executionType) { User user = usersService.queryUser(userName); Project project = (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST); long projectCode = project.getCode();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
Map<String, Object> verifyProcessDefinitionExists = processDefinitionService.verifyProcessDefinitionName(user, projectCode, name); Status verifyStatus = (Status) verifyProcessDefinitionExists.get(Constants.STATUS); long processDefinitionCode; if (verifyStatus == Status.PROCESS_DEFINITION_NAME_EXIST) { ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name); processDefinitionCode = processDefinition.getCode(); processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); Map<String, Object> result = processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams, locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson,executionType); } else if (verifyStatus == Status.SUCCESS) { Map<String, Object> result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams, locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson,executionType); ProcessDefinition processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST); processDefinitionCode = processDefinition.getCode(); } else { String msg = "Verify process definition exists status is invalid, neither SUCCESS or PROCESS_DEFINITION_NAME_EXIST."; LOGGER.error(msg); throw new RuntimeException(msg); } if (schedule != null) { createOrUpdateSchedule(user, projectCode, processDefinitionCode, schedule, workerGroup); } processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE); return processDefinitionCode; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
* create or update process definition schedule. * It would always use latest schedule define in workflow-as-code, and set schedule online when * it's not null * * @param user user who create or update schedule * @param projectCode project which process definition belongs to * @param processDefinitionCode process definition code * @param schedule schedule expression * @param workerGroup work group */ private void createOrUpdateSchedule(User user, long projectCode, long processDefinitionCode, String schedule, String workerGroup) { Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(processDefinitionCode); int scheduleId; if (scheduleObj == null) { processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE); Map<String, Object> result = schedulerService.insertSchedule(user, projectCode, processDefinitionCode, schedule, DEFAULT_WARNING_TYPE, DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); scheduleId = (int) result.get("scheduleId"); } else { scheduleId = scheduleObj.getId(); processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); schedulerService.updateSchedule(user, projectCode, scheduleId, schedule, DEFAULT_WARNING_TYPE, DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); } schedulerService.setScheduleState(user, projectCode, scheduleId, ReleaseState.ONLINE);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
} public void execProcessInstance(String userName, String projectName, String processDefinitionName, String cronTime, String workerGroup, Integer timeout ) { User user = usersService.queryUser(userName); Project project = projectMapper.queryByName(projectName); ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getCode(), processDefinitionName); processDefinitionService.releaseProcessDefinition(user, project.getCode(), processDefinition.getCode(), ReleaseState.ONLINE); executorService.execProcessInstance(user, project.getCode(), processDefinition.getCode(), cronTime, null, DEFAULT_FAILURE_STRATEGY, null, DEFAULT_TASK_DEPEND_TYPE, DEFAULT_WARNING_TYPE, DEFAULT_WARNING_GROUP_ID, DEFAULT_RUN_MODE, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE, timeout, null, null,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
DEFAULT_DRY_RUN ); } public Map<String, Object> createProject(String userName, String name, String desc) { User user = usersService.queryUser(userName); return projectService.createProject(user, name, desc); } public Map<String, Object> createQueue(String name, String queueName) { Result<Object> verifyQueueExists = queueService.verifyQueue(name, queueName); if (verifyQueueExists.getCode() == 0) { return queueService.createQueue(dummyAdminUser, name, queueName); } else { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); result.put(Constants.MSG, Status.SUCCESS.getMsg()); return result; } } public Map<String, Object> createTenant(String tenantCode, String desc, String queueName) throws Exception { if (tenantService.checkTenantExists(tenantCode)) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); result.put(Constants.MSG, Status.SUCCESS.getMsg()); return result; } else { Result<Object> verifyQueueExists = queueService.verifyQueue(queueName, queueName); if (verifyQueueExists.getCode() == 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
queueService.createQueue(dummyAdminUser, queueName, queueName); } Map<String, Object> result = queueService.queryQueueName(queueName); List<Queue> queueList = (List<Queue>) result.get(Constants.DATA_LIST); Queue queue = queueList.get(0); return tenantService.createTenant(dummyAdminUser, tenantCode, queue.getId(), desc); } } public void createUser(String userName, String userPassword, String email, String phone, String tenantCode, String queue, int state) { User user = usersService.queryUser(userName); if (Objects.isNull(user)) { Map<String, Object> tenantResult = tenantService.queryByTenantCode(tenantCode); Tenant tenant = (Tenant) tenantResult.get(Constants.DATA_LIST); usersService.createUser(userName, userPassword, email, tenant.getId(), phone, queue, state); } } /** * Get datasource by given datasource name. It return map contain datasource id, type, name. * Useful in Python API create sql task which need datasource information. * * @param datasourceName user who create or update schedule */ public Map<String, Object> getDatasourceInfo(String datasourceName) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,930
[Feature][Python] Add workflow as code task type sub_process
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Add python api task type sub_process. sub task in #6407. we should cover all parameter from UI side and make it suitable for python. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6930
https://github.com/apache/dolphinscheduler/pull/7022
3304edee47947e0b5a2a9445fe602133efc3d5d7
f480b8adf8f86b7bf1d6727385c8fad8307a452b
"2021-11-19T07:09:05Z"
java
"2021-12-03T02:26:45Z"
dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
Map<String, Object> result = new HashMap<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(datasourceName); if (dataSourceList.size() > 1) { String msg = String.format("Get more than one datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else if (dataSourceList.size() == 0) { String msg = String.format("Can not find any datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else { DataSource dataSource = dataSourceList.get(0); result.put("id", dataSource.getId()); result.put("type", dataSource.getType().name()); result.put("name", dataSource.getName()); } return result; } @PostConstruct public void run() { GatewayServer server = new GatewayServer(this); GatewayServer.turnLoggingOn(); server.start(); } public static void main(String[] args) { SpringApplication.run(PythonGatewayServer.class, args); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.controller;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_USER_BY_ID_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GET_USER_INFO_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_DATASOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_RESOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_UDF_FUNCTION_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_USER_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.USER_LIST_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_USERNAME_ERROR; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.dao.entity.User; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import springfox.documentation.annotations.ApiIgnore; /** * users controller */ @Api(tags = "USERS_TAG") @RestController @RequestMapping("/users") public class UsersController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(UsersController.class); @Autowired private UsersService usersService; /** * create user * * @param loginUser login user * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
* @param queue queue * @return create result code */ @ApiOperation(value = "createUser", notes = "CREATE_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type = "String"), @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "queue", value = "QUEUE", dataType = "String"), @ApiImplicitParam(name = "email", value = "EMAIL", required = true, dataType = "String"), @ApiImplicitParam(name = "phone", value = "PHONE", dataType = "String"), @ApiImplicitParam(name = "state", value = "STATE", dataType = "Int", example = "1") }) @PostMapping(value = "/create") @ResponseStatus(HttpStatus.CREATED) @ApiException(CREATE_USER_ERROR) @AccessLogAnnotation(ignoreRequestArgs = {"loginUser", "userPassword"}) public Result createUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userName") String userName, @RequestParam(value = "userPassword") String userPassword, @RequestParam(value = "tenantId") int tenantId, @RequestParam(value = "queue", required = false, defaultValue = "") String queue, @RequestParam(value = "email") String email, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "state", required = false) int state) throws Exception { Map<String, Object> result = usersService.createUser(loginUser, userName, userPassword, email, tenantId, phone, queue, state); return returnDataList(result); } /** * query user list paging
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
* * @param loginUser login user * @param pageNo page number * @param searchVal search avlue * @param pageSize page size * @return user list page */ @ApiOperation(value = "queryUserList", notes = "QUERY_USER_LIST_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"), @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "10"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String") }) @GetMapping(value = "/list-paging") @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_USER_LIST_PAGING_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryUserList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "searchVal", required = false) String searchVal) { Result result = checkPageParams(pageNo, pageSize); if (!result.checkResult()) { return result; } searchVal = ParameterUtils.handleEscapes(searchVal); result = usersService.queryUserList(loginUser, searchVal, pageNo, pageSize); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
* update user * * @param loginUser login user * @param id user id * @param userName user name * @param userPassword user password * @param email email * @param tenantId tennat id * @param phone phone * @param queue queue * @return update result code */ @ApiOperation(value = "updateUser", notes = "UPDATE_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "USER_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type = "String"), @ApiImplicitParam(name = "tenantId", value = "TENANT_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "queue", value = "QUEUE", dataType = "String"), @ApiImplicitParam(name = "email", value = "EMAIL", required = true, dataType = "String"), @ApiImplicitParam(name = "phone", value = "PHONE", dataType = "String"), @ApiImplicitParam(name = "state", value = "STATE", dataType = "Int", example = "1") }) @PostMapping(value = "/update") @ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_USER_ERROR) @AccessLogAnnotation(ignoreRequestArgs = {"loginUser", "userPassword"}) public Result updateUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id, @RequestParam(value = "userName") String userName,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@RequestParam(value = "userPassword") String userPassword, @RequestParam(value = "queue", required = false, defaultValue = "") String queue, @RequestParam(value = "email") String email, @RequestParam(value = "tenantId") int tenantId, @RequestParam(value = "phone", required = false) String phone, @RequestParam(value = "state", required = false) int state) throws Exception { Map<String, Object> result = usersService.updateUser(loginUser, id, userName, userPassword, email, tenantId, phone, queue, state); return returnDataList(result); } /** * delete user by id * * @param loginUser login user * @param id user id * @return delete result code */ @ApiOperation(value = "delUserById", notes = "DELETE_USER_BY_ID_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "USER_ID", required = true, dataType = "Int", example = "100") }) @PostMapping(value = "/delete") @ResponseStatus(HttpStatus.OK) @ApiException(DELETE_USER_BY_ID_ERROR) @AccessLogAnnotation public Result delUserById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "id") int id) throws Exception { Map<String, Object> result = usersService.deleteUserById(loginUser, id); return returnDataList(result); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
* grant project * * @param loginUser login user * @param userId user id * @param projectIds project id array * @return grant result code */ @ApiOperation(value = "grantProject", notes = "GRANT_PROJECT_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "projectIds", value = "PROJECT_IDS", required = true, type = "String") }) @PostMapping(value = "/grant-project") @ResponseStatus(HttpStatus.OK) @ApiException(GRANT_PROJECT_ERROR) @AccessLogAnnotation public Result grantProject(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "projectIds") String projectIds) { Map<String, Object> result = usersService.grantProject(loginUser, userId, projectIds); return returnDataList(result); } /** * grant resource * * @param loginUser login user * @param userId user id * @param resourceIds resource id array * @return grant result code */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@ApiOperation(value = "grantResource", notes = "GRANT_RESOURCE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "resourceIds", value = "RESOURCE_IDS", required = true, type = "String") }) @PostMapping(value = "/grant-file") @ResponseStatus(HttpStatus.OK) @ApiException(GRANT_RESOURCE_ERROR) @AccessLogAnnotation public Result grantResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "resourceIds") String resourceIds) { Map<String, Object> result = usersService.grantResources(loginUser, userId, resourceIds); return returnDataList(result); } /** * grant udf function * * @param loginUser login user * @param userId user id * @param udfIds udf id array * @return grant result code */ @ApiOperation(value = "grantUDFFunc", notes = "GRANT_UDF_FUNC_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "udfIds", value = "UDF_IDS", required = true, type = "String") }) @PostMapping(value = "/grant-udf-func") @ResponseStatus(HttpStatus.OK)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@ApiException(GRANT_UDF_FUNCTION_ERROR) @AccessLogAnnotation public Result grantUDFFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "udfIds") String udfIds) { Map<String, Object> result = usersService.grantUDFFunction(loginUser, userId, udfIds); return returnDataList(result); } /** * grant datasource * * @param loginUser login user * @param userId user id * @param datasourceIds data source id array * @return grant result code */ @ApiOperation(value = "grantDataSource", notes = "GRANT_DATASOURCE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "datasourceIds", value = "DATASOURCE_IDS", required = true, type = "String") }) @PostMapping(value = "/grant-datasource") @ResponseStatus(HttpStatus.OK) @ApiException(GRANT_DATASOURCE_ERROR) @AccessLogAnnotation public Result grantDataSource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userId") int userId, @RequestParam(value = "datasourceIds") String datasourceIds) { Map<String, Object> result = usersService.grantDataSource(loginUser, userId, datasourceIds); return returnDataList(result);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
} /** * get user info * * @param loginUser login user * @return user info */ @ApiOperation(value = "getUserInfo", notes = "GET_USER_INFO_NOTES") @GetMapping(value = "/get-user-info") @ResponseStatus(HttpStatus.OK) @ApiException(GET_USER_INFO_ERROR) @AccessLogAnnotation public Result getUserInfo(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { Map<String, Object> result = usersService.getUserInfo(loginUser); return returnDataList(result); } /** * user list no paging * * @param loginUser login user * @return user list */ @ApiOperation(value = "listUser", notes = "LIST_USER_NOTES") @GetMapping(value = "/list") @ResponseStatus(HttpStatus.OK) @ApiException(USER_LIST_ERROR) @AccessLogAnnotation public Result listUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { Map<String, Object> result = usersService.queryAllGeneralUsers(loginUser); return returnDataList(result);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
} /** * user list no paging * * @param loginUser login user * @return user list */ @GetMapping(value = "/list-all") @ResponseStatus(HttpStatus.OK) @ApiException(USER_LIST_ERROR) @AccessLogAnnotation public Result listAll(@RequestAttribute(value = Constants.SESSION_USER) User loginUser) { Map<String, Object> result = usersService.queryUserList(loginUser); return returnDataList(result); } /** * verify username * * @param loginUser login user * @param userName user name * @return true if user name not exists, otherwise return false */ @ApiOperation(value = "verifyUserName", notes = "VERIFY_USER_NAME_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String") }) @GetMapping(value = "/verify-user-name") @ResponseStatus(HttpStatus.OK) @ApiException(VERIFY_USERNAME_ERROR) @AccessLogAnnotation
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
public Result verifyUserName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userName") String userName ) { return usersService.verifyUserName(userName); } /** * unauthorized user * * @param loginUser login user * @param alertgroupId alert group id * @return unauthorize result code */ @ApiOperation(value = "unauthorizedUser", notes = "UNAUTHORIZED_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "alertgroupId", value = "ALERT_GROUP_ID", required = true, type = "String") }) @GetMapping(value = "/unauth-user") @ResponseStatus(HttpStatus.OK) @ApiException(UNAUTHORIZED_USER_ERROR) @AccessLogAnnotation public Result unauthorizedUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("alertgroupId") Integer alertgroupId) { Map<String, Object> result = usersService.unauthorizedUser(loginUser, alertgroupId); return returnDataList(result); } /** * authorized user * * @param loginUser login user * @param alertgroupId alert group id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
* @return authorized result code */ @ApiOperation(value = "authorizedUser", notes = "AUTHORIZED_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "alertgroupId", value = "ALERT_GROUP_ID", required = true, type = "String") }) @GetMapping(value = "/authed-user") @ResponseStatus(HttpStatus.OK) @ApiException(AUTHORIZED_USER_ERROR) @AccessLogAnnotation public Result authorizedUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam("alertgroupId") Integer alertgroupId) { try { Map<String, Object> result = usersService.authorizedUser(loginUser, alertgroupId); return returnDataList(result); } catch (Exception e) { logger.error(Status.AUTHORIZED_USER_ERROR.getMsg(), e); return error(Status.AUTHORIZED_USER_ERROR.getCode(), Status.AUTHORIZED_USER_ERROR.getMsg()); } } /** * user registry * * @param userName user name * @param userPassword user password * @param repeatPassword repeat password * @param email user email */ @ApiOperation(value = "registerUser", notes = "REGISTER_USER_NOTES") @ApiImplicitParams({
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"), @ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type = "String"), @ApiImplicitParam(name = "repeatPassword", value = "REPEAT_PASSWORD", required = true, type = "String"), @ApiImplicitParam(name = "email", value = "EMAIL", required = true, type = "String"), }) @PostMapping("/register") @ResponseStatus(HttpStatus.OK) @ApiException(CREATE_USER_ERROR) @AccessLogAnnotation public Result<Object> registerUser(@RequestParam(value = "userName") String userName, @RequestParam(value = "userPassword") String userPassword, @RequestParam(value = "repeatPassword") String repeatPassword, @RequestParam(value = "email") String email) throws Exception { userName = ParameterUtils.handleEscapes(userName); userPassword = ParameterUtils.handleEscapes(userPassword); repeatPassword = ParameterUtils.handleEscapes(repeatPassword); email = ParameterUtils.handleEscapes(email); Map<String, Object> result = usersService.registerUser(userName, userPassword, repeatPassword, email); return returnDataList(result); } /** * user activate * * @param userName user name */ @ApiOperation(value = "activateUser", notes = "ACTIVATE_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userName", value = "USER_NAME", type = "String"), }) @PostMapping("/activate")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_USER_ERROR) @AccessLogAnnotation public Result<Object> activateUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "userName") String userName) { userName = ParameterUtils.handleEscapes(userName); Map<String, Object> result = usersService.activateUser(loginUser, userName); return returnDataList(result); } /** * user batch activate * * @param userNames user names */ @ApiOperation(value = "batchActivateUser", notes = "BATCH_ACTIVATE_USER_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "userNames", value = "USER_NAMES", required = true, type = "String"), }) @PostMapping("/batch/activate") @ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_USER_ERROR) @AccessLogAnnotation public Result<Object> batchActivateUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestBody List<String> userNames) { List<String> formatUserNames = userNames.stream().map(ParameterUtils::handleEscapes).collect(Collectors.toList()); Map<String, Object> result = usersService.batchActivateUser(loginUser, formatUserNames); return returnDataList(result); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.User; import java.io.IOException; import java.util.List; import java.util.Map; /** * users service */ public interface UsersService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
/** * create user, only system admin have permission * * @param loginUser login user * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue * @return create result code * @throws Exception exception */ Map<String, Object> createUser(User loginUser, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws IOException; User createUser(String userName, String userPassword, String email, int tenantId, String phone, String queue, int state); /*** * create User for ldap login */ User createUser(UserType userType, String userId, String email); /** * get user by user name * * @param userName user name * @return exist user or null */ User getUserByUserName(String userName); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
* query user by id * * @param id id * @return user info */ User queryUser(int id); /** * query user by ids * * @param ids id list * @return user list */ List<User> queryUser(List<Integer> ids); /** * query user * * @param name name * @return user info */ User queryUser(String name); /** * query user * * @param name name * @param password password * @return user info */ User queryUser(String name, String password); /** * get user id by user name
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
* * @param name user name * @return if name empty 0, user not exists -1, user exist user id */ int getUserIdByName(String name); /** * query user list * * @param loginUser login user * @param pageNo page number * @param searchVal search avlue * @param pageSize page size * @return user list page */ Result queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize); /** * updateProcessInstance user * * * @param loginUser * @param userId user id * @param userName user name * @param userPassword user password * @param email email * @param tenantId tennat id * @param phone phone * @param queue queue * @return update result code * @throws Exception exception */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
Map<String, Object> updateUser(User loginUser, int userId, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws IOException; /** * delete user * * @param loginUser login user * @param id user id * @return delete result code * @throws Exception exception when operate hdfs */ Map<String, Object> deleteUserById(User loginUser, int id) throws IOException; /** * grant project * * @param loginUser login user * @param userId user id * @param projectIds project id array * @return grant result code */ Map<String, Object> grantProject(User loginUser, int userId, String projectIds); /** * grant resource * * @param loginUser login user * @param userId user id * @param resourceIds resource id array * @return grant result code */ Map<String, Object> grantResources(User loginUser, int userId, String resourceIds); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
* grant udf function * * @param loginUser login user * @param userId user id * @param udfIds udf id array * @return grant result code */ Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds); /** * grant datasource * * @param loginUser login user * @param userId user id * @param datasourceIds data source id array * @return grant result code */ Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds); /** * query user info * * @param loginUser login user * @return user info */ Map<String, Object> getUserInfo(User loginUser); /** * query user list * * @param loginUser login user * @return user list */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
Map<String, Object> queryAllGeneralUsers(User loginUser); /** * query user list * * @param loginUser login user * @return user list */ Map<String, Object> queryUserList(User loginUser); /** * verify user name exists * * @param userName user name * @return true if user name not exists, otherwise return false */ Result<Object> verifyUserName(String userName); /** * unauthorized user * * @param loginUser login user * @param alertgroupId alert group id * @return unauthorize result code */ Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId); /** * authorized user * * @param loginUser login user * @param alertgroupId alert group id * @return authorized result code */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
Map<String, Object> authorizedUser(User loginUser, Integer alertgroupId); /** * registry user, default state is 0, default tenant_id is 1, no phone, no queue * * @param userName user name * @param userPassword user password * @param repeatPassword repeat password * @param email email * @return registry result code * @throws Exception exception */ Map<String, Object> registerUser(String userName, String userPassword, String repeatPassword, String email); /** * activate user, only system admin have permission, change user state code 0 to 1 * * @param loginUser login user * @param userName user name * @return create result code */ Map<String, Object> activateUser(User loginUser, String userName); /** * activate user, only system admin have permission, change users state code 0 to 1 * * @param loginUser login user * @param userNames user name * @return create result code */ Map<String, Object> batchActivateUser(User loginUser, List<String> userNames); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
package org.apache.dolphinscheduler.api.service.impl; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.CheckUtils; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.EncryptionUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.DatasourceUser; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesUser; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UDFUser; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * users service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
public class UsersServiceImpl extends BaseServiceImpl implements UsersService { private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class); @Autowired private AccessTokenMapper accessTokenMapper; @Autowired private UserMapper userMapper; @Autowired private TenantMapper tenantMapper; @Autowired private ProjectUserMapper projectUserMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ResourceMapper resourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; @Autowired private UDFUserMapper udfUserMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
private AlertGroupMapper alertGroupMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProjectMapper projectMapper; /** * create user, only system admin have permission * * @param loginUser login user * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue * @return create result code * @throws Exception exception */ @Override @Transactional(rollbackFor = Exception.class) public Map<String, Object> createUser(User loginUser, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws IOException { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
String msg = this.checkUserParams(userName, userPassword, email, phone); if (!StringUtils.isEmpty(msg)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); return result; } if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!checkTenantExists(tenantId)) { putMsg(result, Status.TENANT_NOT_EXIST); return result; } User user = createUser(userName, userPassword, email, tenantId, phone, queue, state); Tenant tenant = tenantMapper.queryById(tenantId); if (PropertyUtils.getResUploadStartupState()) { if (!HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(tenant.getTenantCode()))) { createTenantDirIfNotExists(tenant.getTenantCode()); } String userPath = HadoopUtils.getHdfsUserDir(tenant.getTenantCode(), user.getId()); HadoopUtils.getInstance().mkdir(userPath); } result.put(Constants.DATA_LIST, user); putMsg(result, Status.SUCCESS); return result; } @Override @Transactional(rollbackFor = RuntimeException.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
public User createUser(String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) { User user = new User(); Date now = new Date(); user.setUserName(userName); user.setUserPassword(EncryptionUtils.getMd5(userPassword)); user.setEmail(email); user.setTenantId(tenantId); user.setPhone(phone); user.setState(state); user.setUserType(UserType.GENERAL_USER); user.setCreateTime(now); user.setUpdateTime(now); if (StringUtils.isEmpty(queue)) { queue = ""; } user.setQueue(queue); userMapper.insert(user); return user; } /*** * create User for ldap login */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
@Override @Transactional(rollbackFor = Exception.class) public User createUser(UserType userType, String userId, String email) { User user = new User(); Date now = new Date(); user.setUserName(userId); user.setEmail(email); user.setUserType(userType); user.setCreateTime(now); user.setUpdateTime(now); user.setQueue(""); userMapper.insert(user); return user; } /** * get user by user name * * @param userName user name * @return exist user or null */ @Override public User getUserByUserName(String userName) { return userMapper.queryByUserNameAccurately(userName); } /** * query user by id * * @param id id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @return user info */ @Override public User queryUser(int id) { return userMapper.selectById(id); } @Override public List<User> queryUser(List<Integer> ids) { if (CollectionUtils.isEmpty(ids)) { return new ArrayList<>(); } return userMapper.selectByIds(ids); } /** * query user * * @param name name * @return user info */ @Override public User queryUser(String name) { return userMapper.queryByUserNameAccurately(name); } /** * query user * * @param name name * @param password password * @return user info */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
@Override public User queryUser(String name, String password) { String md5 = EncryptionUtils.getMd5(password); return userMapper.queryUserByNamePassword(name, md5); } /** * get user id by user name * * @param name user name * @return if name empty 0, user not exists -1, user exist user id */ @Override public int getUserIdByName(String name) { int executorId = 0; if (StringUtils.isNotEmpty(name)) { User executor = queryUser(name); if (null != executor) { executorId = executor.getId(); } else { executorId = -1; } } return executorId; } /** * query user list * * @param loginUser login user * @param pageNo page number
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param searchVal search value * @param pageSize page size * @return user list page */ @Override public Result queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } Page<User> page = new Page<>(pageNo, pageSize); IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal); PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int) scheduleList.getTotal()); pageInfo.setTotalList(scheduleList.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * updateProcessInstance user * * @param userId user id * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @return update result code * @throws Exception exception */ @Override public Map<String, Object> updateUser(User loginUser, int userId, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws IOException { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (check(result, !hasPerm(loginUser, userId), Status.USER_NO_OPERATION_PERM)) { return result; } User user = userMapper.selectById(userId); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result; } if (StringUtils.isNotEmpty(userName)) { if (!CheckUtils.checkUserName(userName)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } User tempUser = userMapper.queryByUserNameAccurately(userName); if (tempUser != null && tempUser.getId() != userId) { putMsg(result, Status.USER_NAME_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } user.setUserName(userName); } if (StringUtils.isNotEmpty(userPassword)) { if (!CheckUtils.checkPassword(userPassword)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userPassword); return result; } user.setUserPassword(EncryptionUtils.getMd5(userPassword)); } if (StringUtils.isNotEmpty(email)) { if (!CheckUtils.checkEmail(email)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email); return result; } user.setEmail(email); } if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone); return result; } user.setPhone(phone); user.setQueue(queue); user.setState(state); Date now = new Date(); user.setUpdateTime(now); if (user.getTenantId() != tenantId) { Tenant oldTenant = tenantMapper.queryById(user.getTenantId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Tenant newTenant = tenantMapper.queryById(tenantId); if (newTenant != null) { if (PropertyUtils.getResUploadStartupState() && oldTenant != null) { String newTenantCode = newTenant.getTenantCode(); String oldResourcePath = HadoopUtils.getHdfsResDir(oldTenant.getTenantCode()); String oldUdfsPath = HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode()); if (HadoopUtils.getInstance().exists(oldResourcePath)) { String newResourcePath = HadoopUtils.getHdfsResDir(newTenantCode); String newUdfsPath = HadoopUtils.getHdfsUdfDir(newTenantCode); List<Resource> fileResourcesList = resourceMapper.queryResourceList( null, userId, ResourceType.FILE.ordinal()); if (CollectionUtils.isNotEmpty(fileResourcesList)) { ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(fileResourcesList); ResourceComponent resourceComponent = resourceTreeVisitor.visit(); copyResourceFiles(resourceComponent, oldResourcePath, newResourcePath); } List<Resource> udfResourceList = resourceMapper.queryResourceList( null, userId, ResourceType.UDF.ordinal()); if (CollectionUtils.isNotEmpty(udfResourceList)) { ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(udfResourceList); ResourceComponent resourceComponent = resourceTreeVisitor.visit(); copyResourceFiles(resourceComponent, oldUdfsPath, newUdfsPath); } String oldUserPath = HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(), userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
HadoopUtils.getInstance().delete(oldUserPath, true); } else { createTenantDirIfNotExists(oldTenant.getTenantCode()); } if (HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode()))) { String newUserPath = HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(), user.getId()); HadoopUtils.getInstance().mkdir(newUserPath); } else { createTenantDirIfNotExists(newTenant.getTenantCode()); } } } user.setTenantId(tenantId); } userMapper.updateById(user); putMsg(result, Status.SUCCESS); return result; } /** * delete user * * @param loginUser login user * @param id user id * @return delete result code * @throws Exception exception when operate hdfs */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
@Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException { Map<String, Object> result = new HashMap<>(); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM, id); return result; } User tempUser = userMapper.selectById(id); if (tempUser == null) { putMsg(result, Status.USER_NOT_EXIST, id); return result; } List<Project> projects = projectMapper.queryProjectCreatedByUser(id); if (CollectionUtils.isNotEmpty(projects)) { String projectNames = projects.stream().map(Project::getName).collect(Collectors.joining(",")); putMsg(result, Status.TRANSFORM_PROJECT_OWNERSHIP, projectNames); return result; } User user = userMapper.queryTenantCodeByUserId(id); if (user != null) { if (PropertyUtils.getResUploadStartupState()) { String userPath = HadoopUtils.getHdfsUserDir(user.getTenantCode(), id); if (HadoopUtils.getInstance().exists(userPath)) { HadoopUtils.getInstance().delete(userPath, true); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} } accessTokenMapper.deleteAccessTokenByUserId(id); userMapper.deleteById(id); putMsg(result, Status.SUCCESS); return result; } /** * grant project * * @param loginUser login user * @param userId user id * @param projectIds project id array * @return grant result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } User tempUser = userMapper.selectById(userId); if (tempUser == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (check(result, StringUtils.isEmpty(projectIds), Status.SUCCESS)) { projectUserMapper.deleteProjectRelation(0, userId); return result; } String[] projectIdArr = projectIds.split(","); for (String projectId : projectIdArr) { Date now = new Date(); ProjectUser projectUser = new ProjectUser(); projectUser.setUserId(userId); projectUser.setProjectId(Integer.parseInt(projectId)); projectUser.setPerm(7); projectUser.setCreateTime(now); projectUser.setUpdateTime(now); projectUserMapper.insert(projectUser); } putMsg(result, Status.SUCCESS); return result; } /** * grant resource * * @param loginUser login user * @param userId user id * @param resourceIds resource id array * @return grant result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Map<String, Object> result = new HashMap<>(); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } User user = userMapper.selectById(userId); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Set<Integer> needAuthorizeResIds = new HashSet<>(); if (StringUtils.isNotBlank(resourceIds)) { String[] resourceFullIdArr = resourceIds.split(","); for (String resourceFullId : resourceFullIdArr) { String[] resourceIdArr = resourceFullId.split("-"); for (int i = 0; i <= resourceIdArr.length - 1; i++) { int resourceIdValue = Integer.parseInt(resourceIdArr[i]); needAuthorizeResIds.add(resourceIdValue); } } } List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, Constants.AUTHORIZE_WRITABLE_PERM); List<Resource> oldAuthorizedRes = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); Set<Integer> oldAuthorizedResIds = oldAuthorizedRes.stream().map(Resource::getId).collect(Collectors.toSet()); oldAuthorizedResIds.removeAll(needAuthorizeResIds); if (CollectionUtils.isNotEmpty(oldAuthorizedResIds)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
List<Map<String, Object>> list = processDefinitionMapper.listResourcesByUser(userId); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); resourceIdSet.retainAll(oldAuthorizedResIds); if (CollectionUtils.isNotEmpty(resourceIdSet)) { logger.error("can't be deleted,because it is used of process definition"); for (Integer resId : resourceIdSet) { logger.error("resource id:{} is used of process definition {}", resId, resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; } } resourceUserMapper.deleteResourceUser(userId, 0); if (check(result, StringUtils.isEmpty(resourceIds), Status.SUCCESS)) { return result; } for (int resourceIdValue : needAuthorizeResIds) { Resource resource = resourceMapper.selectById(resourceIdValue); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } Date now = new Date(); ResourcesUser resourcesUser = new ResourcesUser(); resourcesUser.setUserId(userId); resourcesUser.setResourcesId(resourceIdValue); if (resource.isDirectory()) { resourcesUser.setPerm(Constants.AUTHORIZE_READABLE_PERM);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} else { resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); } resourcesUser.setCreateTime(now); resourcesUser.setUpdateTime(now); resourceUserMapper.insert(resourcesUser); } putMsg(result, Status.SUCCESS); return result; } /** * grant udf function * * @param loginUser login user * @param userId user id * @param udfIds udf id array * @return grant result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) { Map<String, Object> result = new HashMap<>(); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } User user = userMapper.selectById(userId); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} udfUserMapper.deleteByUserId(userId); if (check(result, StringUtils.isEmpty(udfIds), Status.SUCCESS)) { return result; } String[] resourcesIdArr = udfIds.split(","); for (String udfId : resourcesIdArr) { Date now = new Date(); UDFUser udfUser = new UDFUser(); udfUser.setUserId(userId); udfUser.setUdfId(Integer.parseInt(udfId)); udfUser.setPerm(7); udfUser.setCreateTime(now); udfUser.setUpdateTime(now); udfUserMapper.insert(udfUser); } putMsg(result, Status.SUCCESS); return result; } /** * grant datasource * * @param loginUser login user * @param userId user id * @param datasourceIds data source id array * @return grant result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } User user = userMapper.selectById(userId); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userId); return result; } datasourceUserMapper.deleteByUserId(userId); if (check(result, StringUtils.isEmpty(datasourceIds), Status.SUCCESS)) { return result; } String[] datasourceIdArr = datasourceIds.split(","); for (String datasourceId : datasourceIdArr) { Date now = new Date(); DatasourceUser datasourceUser = new DatasourceUser(); datasourceUser.setUserId(userId); datasourceUser.setDatasourceId(Integer.parseInt(datasourceId)); datasourceUser.setPerm(7); datasourceUser.setCreateTime(now); datasourceUser.setUpdateTime(now); datasourceUserMapper.insert(datasourceUser); } putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* query user info * * @param loginUser login user * @return user info */ @Override public Map<String, Object> getUserInfo(User loginUser) { Map<String, Object> result = new HashMap<>(); User user = null; if (loginUser.getUserType() == UserType.ADMIN_USER) { user = loginUser; } else { user = userMapper.queryDetailsById(loginUser.getId()); List<AlertGroup> alertGroups = alertGroupMapper.queryByUserId(loginUser.getId()); StringBuilder sb = new StringBuilder(); if (alertGroups != null && !alertGroups.isEmpty()) { for (int i = 0; i < alertGroups.size() - 1; i++) { sb.append(alertGroups.get(i).getGroupName() + ","); } sb.append(alertGroups.get(alertGroups.size() - 1)); user.setAlertGroup(sb.toString()); } } result.put(Constants.DATA_LIST, user); putMsg(result, Status.SUCCESS); return result; } /** * query user list *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @param loginUser login user * @return user list */ @Override public Map<String, Object> queryAllGeneralUsers(User loginUser) { Map<String, Object> result = new HashMap<>(); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } List<User> userList = userMapper.queryAllGeneralUser(); result.put(Constants.DATA_LIST, userList); putMsg(result, Status.SUCCESS); return result; } /** * query user list * * @param loginUser login user * @return user list */ @Override public Map<String, Object> queryUserList(User loginUser) { Map<String, Object> result = new HashMap<>(); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } List<User> userList = userMapper.selectList(null); result.put(Constants.DATA_LIST, userList);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } /** * verify user name exists * * @param userName user name * @return true if user name not exists, otherwise return false */ @Override public Result<Object> verifyUserName(String userName) { Result<Object> result = new Result<>(); User user = userMapper.queryByUserNameAccurately(userName); if (user != null) { putMsg(result, Status.USER_NAME_EXIST); } else { putMsg(result, Status.SUCCESS); } return result; } /** * unauthorized user * * @param loginUser login user * @param alertgroupId alert group id * @return unauthorize result code */ @Override public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } List<User> userList = userMapper.selectList(null); List<User> resultUsers = new ArrayList<>(); Set<User> userSet = null; if (userList != null && !userList.isEmpty()) { userSet = new HashSet<>(userList); List<User> authedUserList = userMapper.queryUserListByAlertGroupId(alertgroupId); Set<User> authedUserSet = null; if (authedUserList != null && !authedUserList.isEmpty()) { authedUserSet = new HashSet<>(authedUserList); userSet.removeAll(authedUserSet); } resultUsers = new ArrayList<>(userSet); } result.put(Constants.DATA_LIST, resultUsers); putMsg(result, Status.SUCCESS); return result; } /** * authorized user * * @param loginUser login user * @param alertgroupId alert group id * @return authorized result code */ @Override public Map<String, Object> authorizedUser(User loginUser, Integer alertgroupId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Map<String, Object> result = new HashMap<>(); if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { return result; } List<User> userList = userMapper.queryUserListByAlertGroupId(alertgroupId); result.put(Constants.DATA_LIST, userList); putMsg(result, Status.SUCCESS); return result; } /** * @param tenantId tenant id * @return true if tenant exists, otherwise return false */ private boolean checkTenantExists(int tenantId) { return tenantMapper.queryById(tenantId) != null; } /** * @return if check failed return the field, otherwise return null */ private String checkUserParams(String userName, String password, String email, String phone) { String msg = null; if (!CheckUtils.checkUserName(userName)) { msg = userName; } else if (!CheckUtils.checkPassword(password)) { msg = password; } else if (!CheckUtils.checkEmail(email)) { msg = email; } else if (!CheckUtils.checkPhone(phone)) { msg = phone;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} return msg; } /** * copy resource files * * @param resourceComponent resource component * @param srcBasePath src base path * @param dstBasePath dst base path * @throws IOException io exception */ private void copyResourceFiles(ResourceComponent resourceComponent, String srcBasePath, String dstBasePath) throws IOException { List<ResourceComponent> components = resourceComponent.getChildren(); if (CollectionUtils.isNotEmpty(components)) { for (ResourceComponent component : components) { if (!HadoopUtils.getInstance().exists(String.format("%s/%s", srcBasePath, component.getFullName()))) { logger.error("resource file: {} not exist,copy error", component.getFullName()); throw new ServiceException(Status.RESOURCE_NOT_EXIST); } if (!component.isDirctory()) { HadoopUtils.getInstance().copy(String.format("%s/%s", srcBasePath, component.getFullName()), String.format("%s/%s", dstBasePath, component.getFullName()), false, true); continue; } if (CollectionUtils.isEmpty(component.getChildren())) { if (!HadoopUtils.getInstance().exists(String.format("%s/%s", dstBasePath, component.getFullName()))) { HadoopUtils.getInstance().mkdir(String.format("%s/%s", dstBasePath, component.getFullName())); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} else { copyResourceFiles(component, srcBasePath, dstBasePath); } } } } /** * registry user, default state is 0, default tenant_id is 1, no phone, no queue * * @param userName user name * @param userPassword user password * @param repeatPassword repeat password * @param email email * @return registry result code * @throws Exception exception */ @Override @Transactional(rollbackFor = RuntimeException.class) public Map<String, Object> registerUser(String userName, String userPassword, String repeatPassword, String email) { Map<String, Object> result = new HashMap<>(); String msg = this.checkUserParams(userName, userPassword, email, ""); if (!StringUtils.isEmpty(msg)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); return result; } if (!userPassword.equals(repeatPassword)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "two passwords are not same"); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
User user = createUser(userName, userPassword, email, 1, "", "", Flag.NO.ordinal()); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, user); return result; } /** * activate user, only system admin have permission, change user state code 0 to 1 * * @param loginUser login user * @param userName user name * @return create result code */ @Override public Map<String, Object> activateUser(User loginUser, String userName) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!CheckUtils.checkUserName(userName)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } User user = userMapper.queryByUserNameAccurately(userName); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userName); return result; } if (user.getState() != Flag.NO.ordinal()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); return result; } user.setState(Flag.YES.ordinal()); Date now = new Date(); user.setUpdateTime(now); userMapper.updateById(user); User responseUser = userMapper.queryByUserNameAccurately(userName); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, responseUser); return result; } /** * activate user, only system admin have permission, change users state code 0 to 1 * * @param loginUser login user * @param userNames user name * @return create result code */ @Override public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) { Map<String, Object> result = new HashMap<>(); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } int totalSuccess = 0; List<String> successUserNames = new ArrayList<>(); Map<String, Object> successRes = new HashMap<>(); int totalFailed = 0;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
List<Map<String, String>> failedInfo = new ArrayList<>(); Map<String, Object> failedRes = new HashMap<>(); for (String userName : userNames) { Map<String, Object> tmpResult = activateUser(loginUser, userName); if (tmpResult.get(Constants.STATUS) != Status.SUCCESS) { totalFailed++; Map<String, String> failedBody = new HashMap<>(); failedBody.put("userName", userName); Status status = (Status) tmpResult.get(Constants.STATUS); String errorMessage = MessageFormat.format(status.getMsg(), userName); failedBody.put("msg", errorMessage); failedInfo.add(failedBody); } else { totalSuccess++; successUserNames.add(userName); } } successRes.put("sum", totalSuccess); successRes.put("userName", successUserNames); failedRes.put("sum", totalFailed); failedRes.put("info", failedInfo); Map<String, Object> res = new HashMap<>(); res.put("success", successRes); res.put("failed", failedRes); putMsg(result, Status.SUCCESS); result.put(Constants.DATA_LIST, res); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.controller; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.utils.JSONUtils; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; /** * users controller test */ public class UsersControllerTest extends AbstractControllerTest { private static final Logger logger = LoggerFactory.getLogger(UsersControllerTest.class); @Test public void testCreateUser() throws Exception {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName", "user_test"); paramsMap.add("userPassword", "123456qwe?"); paramsMap.add("tenantId", "109"); paramsMap.add("queue", "1"); paramsMap.add("email", "[email protected]"); paramsMap.add("phone", "15800000000"); MvcResult mvcResult = mockMvc.perform(post("/users/create") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.CREATE_USER_ERROR.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testUpdateUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("id", "32"); paramsMap.add("userName", "user_test"); paramsMap.add("userPassword", "123456qwe?"); paramsMap.add("tenantId", "9"); paramsMap.add("queue", "1"); paramsMap.add("email", "[email protected]"); paramsMap.add("phone", "15800000000"); MvcResult mvcResult = mockMvc.perform(post("/users/update") .header(SESSION_ID, sessionId) .params(paramsMap))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
.andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.UPDATE_USER_ERROR.getCode(), result.getCode().intValue()); } @Test public void testGrantProject() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userId", "32"); paramsMap.add("projectIds", "3"); MvcResult mvcResult = mockMvc.perform(post("/users/grant-project") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testGrantResource() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userId", "32"); paramsMap.add("resourceIds", "5"); MvcResult mvcResult = mockMvc.perform(post("/users/grant-file") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testGrantUDFFunc() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userId", "32"); paramsMap.add("udfIds", "5"); MvcResult mvcResult = mockMvc.perform(post("/users/grant-udf-func") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testGrantDataSource() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userId", "32"); paramsMap.add("datasourceIds", "5"); MvcResult mvcResult = mockMvc.perform(post("/users/grant-datasource") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk())
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testGetUserInfo() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/users/get-user-info") .header(SESSION_ID, sessionId)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testListAll() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName", "test"); MvcResult mvcResult = mockMvc.perform(get("/users/list-all") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
} @Ignore @Test public void testAuthorizedUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("alertgroupId", "1"); MvcResult mvcResult = mockMvc.perform(get("/users/authed-user") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Ignore @Test public void testUnauthorizedUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("alertgroupId", "1"); MvcResult mvcResult = mockMvc.perform(get("/users/unauth-user") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testVerifyUserName() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName", "hello"); MvcResult mvcResult = mockMvc.perform(get("/users/verify-user-name") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testDelUserById() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("id", "32"); MvcResult mvcResult = mockMvc.perform(post("/users/delete") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
} @Test public void testQueryList() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/users/list") .header(SESSION_ID, sessionId)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testRegisterUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName", "user_test"); paramsMap.add("userPassword", "123456qwe?"); paramsMap.add("repeatPassword", "123456qwe?"); paramsMap.add("email", "[email protected]"); MvcResult mvcResult = mockMvc.perform(post("/users/register") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } @Test @Ignore
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java
public void testActivateUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("userName", "user_test"); MvcResult mvcResult = mockMvc.perform(post("/users/activate") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } @Test public void testBatchActivateUser() throws Exception { List<String> userNames = new ArrayList<>(); userNames.add("user_sky_cxl"); userNames.add("19990323"); userNames.add("test_sky_post_11"); String jsonUserNames = JSONUtils.toJsonString(userNames); MvcResult mvcResult = mockMvc.perform(post("/users/batch/activate") .header(SESSION_ID, sessionId) .contentType(MediaType.APPLICATION_JSON) .content(jsonUserNames)) .andExpect(status().isOk()) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.api.service; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.UsersServiceImpl; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.EncryptionUtils; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; /** * users service test */ @RunWith(MockitoJUnitRunner.class) public class UsersServiceTest { private static final Logger logger = LoggerFactory.getLogger(UsersServiceTest.class); @InjectMocks private UsersServiceImpl usersService; @Mock private UserMapper userMapper; @Mock private AccessTokenMapper accessTokenMapper; @Mock private TenantMapper tenantMapper; @Mock private ResourceMapper resourceMapper; @Mock private AlertGroupMapper alertGroupMapper; @Mock private DataSourceUserMapper datasourceUserMapper; @Mock private ProjectUserMapper projectUserMapper; @Mock private ResourceUserMapper resourceUserMapper; @Mock private UDFUserMapper udfUserMapper; @Mock
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
private ProjectMapper projectMapper; private String queueName = "UsersServiceTestQueue"; @Before public void before() { } @After public void after() { } @Test public void testCreateUserForLdap() { String userName = "user1"; String email = "[email protected]"; User user = usersService.createUser(UserType.ADMIN_USER, userName, email); Assert.assertNotNull(user); } @Test public void testCreateUser() { User user = new User(); user.setUserType(UserType.ADMIN_USER); String userName = "userTest0001~"; String userPassword = "userTest"; String email = "[email protected]"; int tenantId = Integer.MAX_VALUE; String phone = "13456432345"; int state = 1; try { Map<String, Object> result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
userName = "userTest0001"; userPassword = "userTest000111111111111111"; result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); userPassword = "userTest0001"; email = "1q.com"; result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); email = "[email protected]"; phone = "2233"; result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); phone = "13456432345"; result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.TENANT_NOT_EXIST, result.get(Constants.STATUS)); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); result = usersService.createUser(user, userName, userPassword, email, 1, phone, queueName, state); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { logger.error(Status.CREATE_USER_ERROR.getMsg(), e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
Assert.assertTrue(false); } } @Test public void testQueryUser() { String userName = "userTest0001"; String userPassword = "userTest0001"; when(userMapper.queryUserByNamePassword(userName, EncryptionUtils.getMd5(userPassword))).thenReturn(getGeneralUser()); User queryUser = usersService.queryUser(userName, userPassword); logger.info(queryUser.toString()); Assert.assertTrue(queryUser != null); } @Test public void testSelectByIds() { List<Integer> ids = new ArrayList<>(); List<User> users = usersService.queryUser(ids); Assert.assertTrue(users.isEmpty()); ids.add(1); List<User> userList = new ArrayList<>(); userList.add(new User()); when(userMapper.selectByIds(ids)).thenReturn(userList); List<User> userList1 = usersService.queryUser(ids); Assert.assertFalse(userList1.isEmpty()); } @Test public void testGetUserIdByName() { User user = new User(); user.setId(1); user.setUserType(UserType.ADMIN_USER); user.setUserName("test_user");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
int userId = usersService.getUserIdByName(""); Assert.assertEquals(0, userId); when(usersService.queryUser(user.getUserName())).thenReturn(null); int userNotExistId = usersService.getUserIdByName(user.getUserName()); Assert.assertEquals(-1, userNotExistId); when(usersService.queryUser(user.getUserName())).thenReturn(user); int userExistId = usersService.getUserIdByName(user.getUserName()); Assert.assertEquals(user.getId(), userExistId); } @Test public void testQueryUserList() { User user = new User(); Map<String, Object> result = usersService.queryUserList(user); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); when(userMapper.selectList(null)).thenReturn(getUserList()); result = usersService.queryUserList(user); List<User> userList = (List<User>) result.get(Constants.DATA_LIST); Assert.assertTrue(userList.size() > 0); } @Test public void testQueryUserListPage() { User user = new User(); IPage<User> page = new Page<>(1, 10);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
page.setRecords(getUserList()); when(userMapper.queryUserPaging(any(Page.class), eq("userTest"))).thenReturn(page); Result result = usersService.queryUserList(user, "userTest", 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), (int) result.getCode()); user.setUserType(UserType.ADMIN_USER); result = usersService.queryUserList(user, "userTest", 1, 10); Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode()); PageInfo<User> pageInfo = (PageInfo<User>) result.getData(); Assert.assertTrue(pageInfo.getTotalList().size() > 0); } @Test public void testUpdateUser() { String userName = "userTest0001"; String userPassword = "userTest0001"; try { Map<String, Object> result = usersService.updateUser(getLoginUser(), 0, userName, userPassword, "[email protected]", 1, "13457864543", "queue", 1); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); logger.info(result.toString()); when(userMapper.selectById(1)).thenReturn(getUser()); result = usersService.updateUser(getLoginUser(), 1, userName, userPassword, "[email protected]", 1, "13457864543", "queue", 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { logger.error("update user error", e); Assert.assertTrue(false);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
} } @Test public void testDeleteUserById() { User loginUser = new User(); try { when(userMapper.queryTenantCodeByUserId(1)).thenReturn(getUser()); when(userMapper.selectById(1)).thenReturn(getUser()); when(accessTokenMapper.deleteAccessTokenByUserId(1)).thenReturn(0); Map<String, Object> result = usersService.deleteUserById(loginUser, 3); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); result = usersService.deleteUserById(loginUser, 3); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); Mockito.when(projectMapper.queryProjectCreatedByUser(1)).thenReturn(Lists.newArrayList(new Project())); result = usersService.deleteUserById(loginUser, 1); Assert.assertEquals(Status.TRANSFORM_PROJECT_OWNERSHIP, result.get(Constants.STATUS)); Mockito.when(projectMapper.queryProjectCreatedByUser(1)).thenReturn(null); result = usersService.deleteUserById(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { logger.error("delete user error", e); Assert.assertTrue(false);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
} } @Test public void testGrantProject() { when(userMapper.selectById(1)).thenReturn(getUser()); User loginUser = new User(); String projectIds = "100000,120000"; Map<String, Object> result = usersService.grantProject(loginUser, 1, projectIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); result = usersService.grantProject(loginUser, 2, projectIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); result = usersService.grantProject(loginUser, 1, projectIds); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @Test public void testGrantResources() { String resourceIds = "100000,120000"; when(userMapper.selectById(1)).thenReturn(getUser()); User loginUser = new User(); Map<String, Object> result = usersService.grantResources(loginUser, 1, resourceIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
result = usersService.grantResources(loginUser, 2, resourceIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); when(resourceMapper.selectById(Mockito.anyInt())).thenReturn(getResource()); when(resourceUserMapper.deleteResourceUser(1, 0)).thenReturn(1); result = usersService.grantResources(loginUser, 1, resourceIds); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @Test public void testGrantUDFFunction() { String udfIds = "100000,120000"; when(userMapper.selectById(1)).thenReturn(getUser()); User loginUser = new User(); Map<String, Object> result = usersService.grantUDFFunction(loginUser, 1, udfIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); result = usersService.grantUDFFunction(loginUser, 2, udfIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); when(udfUserMapper.deleteByUserId(1)).thenReturn(1); result = usersService.grantUDFFunction(loginUser, 1, udfIds); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
public void testGrantDataSource() { String datasourceIds = "100000,120000"; when(userMapper.selectById(1)).thenReturn(getUser()); User loginUser = new User(); Map<String, Object> result = usersService.grantDataSource(loginUser, 1, datasourceIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); result = usersService.grantDataSource(loginUser, 2, datasourceIds); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); when(datasourceUserMapper.deleteByUserId(Mockito.anyInt())).thenReturn(1); result = usersService.grantDataSource(loginUser, 1, datasourceIds); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } private User getLoginUser() { User loginUser = new User(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); return loginUser; } @Test public void getUserInfo() { User loginUser = new User(); loginUser.setUserName("admin"); loginUser.setUserType(UserType.ADMIN_USER);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
Map<String, Object> result = usersService.getUserInfo(loginUser); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); User tempUser = (User) result.get(Constants.DATA_LIST); Assert.assertEquals("admin", tempUser.getUserName()); loginUser.setUserType(null); loginUser.setId(1); when(userMapper.queryDetailsById(1)).thenReturn(getGeneralUser()); when(alertGroupMapper.queryByUserId(1)).thenReturn(getAlertGroups()); result = usersService.getUserInfo(loginUser); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); tempUser = (User) result.get(Constants.DATA_LIST); Assert.assertEquals("userTest0001", tempUser.getUserName()); } @Test public void testQueryAllGeneralUsers() { User loginUser = new User(); Map<String, Object> result = usersService.queryAllGeneralUsers(loginUser); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); when(userMapper.queryAllGeneralUser()).thenReturn(getUserList()); result = usersService.queryAllGeneralUsers(loginUser); logger.info(result.toString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<User> userList = (List<User>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(userList)); } @Test public void testVerifyUserName() { Result result = usersService.verifyUserName("admin89899"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); when(userMapper.queryByUserNameAccurately("userTest0001")).thenReturn(getUser()); result = usersService.verifyUserName("userTest0001"); logger.info(result.toString()); Assert.assertEquals(Status.USER_NAME_EXIST.getMsg(), result.getMsg()); } @Test public void testUnauthorizedUser() { User loginUser = new User(); when(userMapper.selectList(null)).thenReturn(getUserList()); when(userMapper.queryUserListByAlertGroupId(2)).thenReturn(getUserList()); Map<String, Object> result = usersService.unauthorizedUser(loginUser, 2); logger.info(result.toString()); loginUser.setUserType(UserType.ADMIN_USER); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); result = usersService.unauthorizedUser(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
} @Test public void testAuthorizedUser() { User loginUser = new User(); when(userMapper.queryUserListByAlertGroupId(2)).thenReturn(getUserList()); Map<String, Object> result = usersService.authorizedUser(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); result = usersService.authorizedUser(loginUser, 2); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<User> userList = (List<User>) result.get(Constants.DATA_LIST); logger.info(result.toString()); Assert.assertTrue(CollectionUtils.isNotEmpty(userList)); } @Test public void testRegisterUser() { String userName = "userTest0002~"; String userPassword = "userTest"; String repeatPassword = "userTest"; String email = "[email protected]"; try { Map<String, Object> result = usersService.registerUser(userName, userPassword, repeatPassword, email); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); userName = "userTest0002"; userPassword = "userTest000111111111111111";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
result = usersService.registerUser(userName, userPassword, repeatPassword, email); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); userPassword = "userTest0002"; email = "1q.com"; result = usersService.registerUser(userName, userPassword, repeatPassword, email); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); email = "[email protected]"; repeatPassword = "userPassword"; result = usersService.registerUser(userName, userPassword, repeatPassword, email); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); repeatPassword = "userTest0002"; result = usersService.registerUser(userName, userPassword, repeatPassword, email); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { Assert.assertTrue(false); } } @Test public void testActivateUser() { User user = new User(); user.setUserType(UserType.GENERAL_USER); String userName = "userTest0002~"; try { Map<String, Object> result = usersService.activateUser(user, userName); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
user.setUserType(UserType.ADMIN_USER); result = usersService.activateUser(user, userName); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); userName = "userTest10013"; result = usersService.activateUser(user, userName); Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS)); userName = "userTest0001"; when(userMapper.queryByUserNameAccurately(userName)).thenReturn(getUser()); result = usersService.activateUser(user, userName); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); when(userMapper.queryByUserNameAccurately(userName)).thenReturn(getDisabledUser()); result = usersService.activateUser(user, userName); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { Assert.assertTrue(false); } } @Test public void testBatchActivateUser() { User user = new User(); user.setUserType(UserType.GENERAL_USER); List<String> userNames = new ArrayList<>(); userNames.add("userTest0001"); userNames.add("userTest0002"); userNames.add("userTest0003~"); userNames.add("userTest0004"); try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
Map<String, Object> result = usersService.batchActivateUser(user, userNames); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); when(userMapper.queryByUserNameAccurately("userTest0001")).thenReturn(getUser()); when(userMapper.queryByUserNameAccurately("userTest0002")).thenReturn(getDisabledUser()); result = usersService.batchActivateUser(user, userNames); Map<String, Object> responseData = (Map<String, Object>) result.get(Constants.DATA_LIST); Map<String, Object> successData = (Map<String, Object>) responseData.get("success"); int totalSuccess = (Integer) successData.get("sum"); Map<String, Object> failedData = (Map<String, Object>) responseData.get("failed"); int totalFailed = (Integer) failedData.get("sum"); Assert.assertEquals(1, totalSuccess); Assert.assertEquals(3, totalFailed); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } catch (Exception e) { Assert.assertTrue(false); } } /** * get disabled user */ private User getDisabledUser() { User user = new User(); user.setUserType(UserType.GENERAL_USER); user.setUserName("userTest0001"); user.setUserPassword("userTest0001"); user.setState(0); return user;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
} /** * get user */ private User getGeneralUser() { User user = new User(); user.setUserType(UserType.GENERAL_USER); user.setUserName("userTest0001"); user.setUserPassword("userTest0001"); return user; } private List<User> getUserList() { List<User> userList = new ArrayList<>(); userList.add(getGeneralUser()); return userList; } /** * get user */ private User getUser() { User user = new User(); user.setUserType(UserType.ADMIN_USER); user.setUserName("userTest0001"); user.setUserPassword("userTest0001"); user.setState(1); return user; } /** * get tenant *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
* @return tenant */ private Tenant getTenant() { Tenant tenant = new Tenant(); tenant.setId(1); return tenant; } /** * get resource * * @return resource */ private Resource getResource() { Resource resource = new Resource(); resource.setPid(-1); resource.setUserId(1); resource.setDescription("ResourcesServiceTest.jar"); resource.setAlias("ResourcesServiceTest.jar"); resource.setFullName("/ResourcesServiceTest.jar"); resource.setType(ResourceType.FILE); return resource; } private List<AlertGroup> getAlertGroups() { List<AlertGroup> alertGroups = new ArrayList<>(); AlertGroup alertGroup = new AlertGroup(); alertGroups.add(alertGroup); return alertGroups; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,110
[Feature][dolphinscheduler-api] support grant project by code
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Third-party integrated scenarios, support grant through project code ### Use case ## API ## org.apache.dolphinscheduler.api.controller.UsersController#grantProjectByCode ## Request ## | Name | Type | Require | | :--- | :--- | :---: | | userId | Int | βœ“ | | projectCodes | String | βœ“ | ## Response ## Same as `org.apache.dolphinscheduler.api.controller.UsersController#grantProject` ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/7110
https://github.com/apache/dolphinscheduler/pull/7111
fa8ccd3855dfaa19d73cd7541184938f227bb4b7
27ea43d5dfda2556fa5fb02179e7c906408007ad
"2021-12-01T16:08:53Z"
java
"2021-12-04T13:43:14Z"
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.ibatis.annotations.Param; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; /** * project mapper interface */ public interface ProjectMapper extends BaseMapper<Project> {