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
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.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.spi.utils; /** * constants */ public class Constants {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.java
private Constants() { throw new IllegalStateException("Constants class"); } public static final String STRING_PLUGIN_PARAM_FIELD = "field"; public static final String STRING_PLUGIN_PARAM_NAME = "name"; public static final String STRING_PLUGIN_PARAM_PROPS = "props"; public static final String STRING_PLUGIN_PARAM_TYPE = "type"; public static final String STRING_PLUGIN_PARAM_TITLE = "title"; public static final String STRING_PLUGIN_PARAM_VALUE = "value"; public static final String STRING_PLUGIN_PARAM_VALIDATE = "validate"; public static final String STRING_PLUGIN_PARAM_OPTIONS = "options"; public static final String STRING_TRUE = "true"; public static final String STRING_FALSE = "false"; public static final String STRING_YES = "YES";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.java
public static final String STRING_NO = "NO"; /** * common properties path */ public static final String COMMON_PROPERTIES_PATH = "/common.properties"; /** * date format of yyyy-MM-dd HH:mm:ss */ public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; /** * date format of yyyyMMddHHmmss */ public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; /** * date format of yyyyMMddHHmmssSSS */ public static final String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS"; public static final String SPRING_DATASOURCE_MIN_IDLE = "spring.datasource.minIdle"; public static final String SPRING_DATASOURCE_MAX_ACTIVE = "spring.datasource.maxActive"; public static final String SPRING_DATASOURCE_TEST_ON_BORROW = "spring.datasource.testOnBorrow"; /** * java.security.krb5.conf */ public static final String JAVA_SECURITY_KRB5_CONF = "java.security.krb5.conf"; /** * java.security.krb5.conf.path */ public static final String JAVA_SECURITY_KRB5_CONF_PATH = "java.security.krb5.conf.path"; /** * hadoop.security.authentication
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.java
*/ public static final String HADOOP_SECURITY_AUTHENTICATION = "hadoop.security.authentication"; /** * hadoop.security.authentication */ public static final String HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE = "hadoop.security.authentication.startup.state"; /** * loginUserFromKeytab user */ public static final String LOGIN_USER_KEY_TAB_USERNAME = "login.user.keytab.username"; /** * loginUserFromKeytab path */ public static final String LOGIN_USER_KEY_TAB_PATH = "login.user.keytab.path"; /** * resource storage type */ public static final String RESOURCE_STORAGE_TYPE = "resource.storage.type"; /** * kerberos */ public static final String KERBEROS = "kerberos"; /** * driver */ public static final String ORG_POSTGRESQL_DRIVER = "org.postgresql.Driver"; public static final String COM_MYSQL_CJ_JDBC_DRIVER = "com.mysql.cj.jdbc.Driver"; public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver"; public static final String ORG_APACHE_HIVE_JDBC_HIVE_DRIVER = "org.apache.hive.jdbc.HiveDriver"; public static final String COM_CLICKHOUSE_JDBC_DRIVER = "ru.yandex.clickhouse.ClickHouseDriver";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.java
public static final String COM_ORACLE_JDBC_DRIVER = "oracle.jdbc.OracleDriver"; public static final String COM_SQLSERVER_JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; public static final String COM_DB2_JDBC_DRIVER = "com.ibm.db2.jcc.DB2Driver"; public static final String COM_PRESTO_JDBC_DRIVER = "com.facebook.presto.jdbc.PrestoDriver"; /** * validation Query */ public static final String POSTGRESQL_VALIDATION_QUERY = "select version()"; public static final String MYSQL_VALIDATION_QUERY = "select 1"; public static final String HIVE_VALIDATION_QUERY = "select 1"; public static final String CLICKHOUSE_VALIDATION_QUERY = "select 1"; public static final String ORACLE_VALIDATION_QUERY = "select 1 from dual"; public static final String SQLSERVER_VALIDATION_QUERY = "select 1"; public static final String DB2_VALIDATION_QUERY = "select 1 from sysibm.sysdummy1"; public static final String PRESTO_VALIDATION_QUERY = "select 1"; /** * jdbc url */ public static final String JDBC_MYSQL = "jdbc:mysql://"; public static final String JDBC_POSTGRESQL = "jdbc:postgresql://"; public static final String JDBC_HIVE_2 = "jdbc:hive2://"; public static final String JDBC_CLICKHOUSE = "jdbc:clickhouse://"; public static final String JDBC_ORACLE_SID = "jdbc:oracle:thin:@"; public static final String JDBC_ORACLE_SERVICE_NAME = "jdbc:oracle:thin:@//"; public static final String JDBC_SQLSERVER = "jdbc:sqlserver://"; public static final String JDBC_DB2 = "jdbc:db2://"; public static final String JDBC_PRESTO = "jdbc:presto://"; public static final String ADDRESS = "address"; public static final String DATABASE = "database"; public static final String JDBC_URL = "jdbcUrl";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
7,671
[Bug] [task-plugin-sql] hive/impala datasource can not get connection, throw NullpointerException
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened ![image](https://user-images.githubusercontent.com/38685000/147537710-ecea98b0-25d4-468f-958b-5d298c1f5241.png) ![image](https://user-images.githubusercontent.com/38685000/147537750-9a017819-d590-430d-b8f9-9c5d0fc47f6c.png) 使用JdbcDataSourceProvider.createOneSessionJdbcDataSource()方法hive/impala创建连接池设置了MaximumPoolSize=1,但是调度任务是,一般hive/impala都是多任务同时跑的话,会出现getConnection=null的情况,因此SqlTask.prepareStatementAndBind()方法会抛出空指针异常。 ### What you expected to happen 为什么hive/impala连接池需要创建容量为1的连接池? ### How to reproduce see what happened ### Anything else _No response_ ### Version 2.0.1 ### Are you willing to submit 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/7671
https://github.com/apache/dolphinscheduler/pull/7675
713d0e75501f714e35189a33e8cee67926f7bd9e
898727709f49e403e232bf5b68f006d3c6b28e55
2021-12-28T07:03:08Z
java
2022-01-13T10:06:40Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/Constants.java
public static final String PRINCIPAL = "principal"; public static final String OTHER = "other"; public static final String ORACLE_DB_CONNECT_TYPE = "connectType"; public static final String KERBEROS_KRB5_CONF_PATH = "javaSecurityKrb5Conf"; public static final String KERBEROS_KEY_TAB_USERNAME = "loginUserKeytabUsername"; public static final String KERBEROS_KEY_TAB_PATH = "loginUserKeytabPath"; /** * DOUBLE_SLASH // */ public static final String DOUBLE_SLASH = "//"; /** * comma , */ public static final String COMMA = ","; /** * COLON : */ public static final String COLON = ":"; /** * AT SIGN */ public static final String AT_SIGN = "@"; /** * datasource encryption salt */ public static final String DATASOURCE_ENCRYPTION_SALT_DEFAULT = "!@#$%^&*"; public static final String DATASOURCE_ENCRYPTION_ENABLE = "datasource.encryption.enable"; public static final String DATASOURCE_ENCRYPTION_SALT = "datasource.encryption.salt"; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.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.impl; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.DataSourceService; 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.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.User;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.commons.lang.StringUtils; import java.sql.Connection; 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 org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereo.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.node.ObjectNode; /** * data source service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
public class DataSourceServiceImpl extends BaseServiceImpl implements DataSourceService { private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceImpl.class); @Autowired private DataSourceMapper dataSourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; /** * create data source * * @param loginUser login user * @param datasourceParam datasource parameters * @return create result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) { DataSourceUtils.checkDatasourceParam(datasourceParam); Result<Object> result = new Result<>(); if (checkName(datasourceParam.getName())) { putMsg(result, Status.DATASOURCE_EXIST); return result; } ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(datasourceParam); Result<Object> isConnection = checkConnection(datasourceParam.getType(), connectionParam); if (Status.SUCCESS.getCode() != isConnection.getCode()) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } DataSource dataSource = new DataSource(); Date now = new Date(); dataSource.setName(datasourceParam.getName().trim()); dataSource.setNote(datasourceParam.getNote()); dataSource.setUserId(loginUser.getId()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(datasourceParam.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setCreateTime(now); dataSource.setUpdateTime(now); try { dataSourceMapper.insert(dataSource);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
putMsg(result, Status.SUCCESS); } catch (DuplicateKeyException ex) { logger.error("Create datasource error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result; } /** * updateProcessInstance datasource * * @param loginUser login user * @param id data source id * @return update result code */ @Override public Result<Object> updateDataSource(int id, User loginUser, BaseDataSourceParamDTO dataSourceParam) { DataSourceUtils.checkDatasourceParam(dataSourceParam); Result<Object> result = new Result<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, dataSource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!dataSource.getName().trim().equals(dataSource.getName()) && checkName(dataSource.getName())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
putMsg(result, Status.DATASOURCE_EXIST); return result; } BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams(dataSourceParam); String password = connectionParam.getPassword(); if (StringUtils.isBlank(password)) { String oldConnectionParams = dataSource.getConnectionParams(); ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams); connectionParam.setPassword(oldParams.path(Constants.PASSWORD).asText()); } Result<Object> isConnection = checkConnection(dataSource.getType(), connectionParam); if (isConnection.isFailed()) { return isConnection; } Date now = new Date(); dataSource.setName(dataSourceParam.getName().trim()); dataSource.setNote(dataSourceParam.getNote()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(dataSource.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setUpdateTime(now); try { dataSourceMapper.updateById(dataSource); putMsg(result, Status.SUCCESS); } catch (DuplicateKeyException ex) { logger.error("Update datasource error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} private boolean checkName(String name) { List<DataSource> queryDataSource = dataSourceMapper.queryDataSourceByName(name.trim()); return queryDataSource != null && !queryDataSource.isEmpty(); } /** * updateProcessInstance datasource * * @param id datasource id * @return data source detail */ @Override public Map<String, Object> queryDataSource(int id) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } // BaseDataSourceParamDTO baseDataSourceParamDTO = DataSourceUtils.buildDatasourceParamDTO( dataSource.getType(), dataSource.getConnectionParams()); baseDataSourceParamDTO.setId(dataSource.getId()); baseDataSourceParamDTO.setName(dataSource.getName()); baseDataSourceParamDTO.setNote(dataSource.getNote()); result.put(Constants.DATA_LIST, baseDataSourceParamDTO); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
* query datasource list by keyword * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page */ @Override public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); IPage<DataSource> dataSourceList; Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize); if (isAdmin(loginUser)) { dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, 0, searchVal); } else { dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, loginUser.getId(), searchVal); } List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>(); handlePasswd(dataSources); PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L)); pageInfo.setTotalList(dataSources); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * handle datasource connection password for safety */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
private void handlePasswd(List<DataSource> dataSourceList) { for (DataSource dataSource : dataSourceList) { String connectionParams = dataSource.getConnectionParams(); ObjectNode object = JSONUtils.parseObject(connectionParams); object.put(Constants.PASSWORD, getHiddenPassword()); dataSource.setConnectionParams(object.toString()); } } /** * get hidden password (resolve the security hotspot) * * @return hidden password */ private String getHiddenPassword() { return Constants.XXXXXX; } /** * query data resource list * * @param loginUser login user * @param data source * @return data source list page */ @Override public Map<String, Object> queryDataSourceList(User loginUser, Integer ) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList; if (isAdmin(loginUser)) { datasourceList = dataSourceMapper.listAllDataSourceByType(); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
datasourceList = dataSourceMapper.queryDataSourceByType(loginUser.getId(), ); } result.put(Constants.DATA_LIST, datasourceList); putMsg(result, Status.SUCCESS); return result; } /** * verify datasource exists * * @param name datasource name * @return true if data datasource not exists, otherwise return false */ @Override public Result<Object> verifyDataSourceName(String name) { Result<Object> result = new Result<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name); if (dataSourceList != null && !dataSourceList.isEmpty()) { putMsg(result, Status.DATASOURCE_EXIST); } else { putMsg(result, Status.SUCCESS); } return result; } /** * check connection * * @param data source * @param connectionParam connectionParam * @return true if connect successfully, otherwise false * @return true if connect successfully, otherwise false
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Result<Object> checkConnection(DbType , ConnectionParam connectionParam) { Result<Object> result = new Result<>(); try (Connection connection = DataSourceClientProvider.getInstance().getConnection(, connectionParam)) { if (connection == null) { putMsg(result, Status.CONNECTION_TEST_FAILURE); return result; } putMsg(result, Status.SUCCESS); return result; } catch (Exception e) { logger.error("datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", , connectionParam, e.getMessage()); return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), e.getMessage()); } } /** * test connection * * @param id datasource id * @return connect result code */ @Override public Result<Object> connectionTest(int id) { DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { Result<Object> result = new Result<>(); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
return checkConnection(dataSource.getType(), DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams())); } /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code */ @Override @Transactional(rollbackFor = RuntimeException.class) public Result<Object> delete(User loginUser, int datasourceId) { Result<Object> result = new Result<>(); try { // DataSource dataSource = dataSourceMapper.selectById(datasourceId); if (dataSource == null) { logger.error("resource id {} not exist", datasourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, dataSource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } dataSourceMapper.deleteById(datasourceId); datasourceUserMapper.deleteByDatasourceId(datasourceId); putMsg(result, Status.SUCCESS); } catch (Exception e) { logger.error("delete datasource error", e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
throw new RuntimeException("delete datasource error"); } return result; } /** * unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ @Override public Map<String, Object> unauthDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); // if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } /** * query all data sources except userId */ List<DataSource> resultList = new ArrayList<>(); List<DataSource> datasourceList = dataSourceMapper.queryDatasourceExceptUserId(userId); Set<DataSource> datasourceSet = null; if (datasourceList != null && !datasourceList.isEmpty()) { datasourceSet = new HashSet<>(datasourceList); List<DataSource> authedDataSourceList = dataSourceMapper.queryAuthedDatasource(userId); Set<DataSource> authedDataSourceSet = null; if (authedDataSourceList != null && !authedDataSourceList.isEmpty()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
authedDataSourceSet = new HashSet<>(authedDataSourceList); datasourceSet.removeAll(authedDataSourceSet); } resultList = new ArrayList<>(datasourceSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authedDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } List<DataSource> authedDatasourceList = dataSourceMapper.queryAuthedDatasource(userId); result.put(Constants.DATA_LIST, authedDatasourceList); putMsg(result, Status.SUCCESS); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.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.impl; import static org.apache.dolphinscheduler.api.utils.CheckUtils.checkDesc; import org.apache.dolphinscheduler.api.enums.Status;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
import org.apache.dolphinscheduler.api.service.ProjectService; 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.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * project service impl **/ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService { @Autowired private ProjectMapper projectMapper; @Autowired private ProjectUserMapper projectUserMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private UserMapper userMapper; /** * create project * * @param loginUser login user * @param name project name * @param desc description * @return returns an error if it exists */ @Override public Map<String, Object> createProject(User loginUser, String name, String desc) { Map<String, Object> result = new HashMap<>(); Map<String, Object> descCheck = checkDesc(desc); if (descCheck.get(Constants.STATUS) != Status.SUCCESS) { return descCheck;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
} Project project = projectMapper.queryByName(name); if (project != null) { putMsg(result, Status.PROJECT_ALREADY_EXISTS, name); return result; } Date now = new Date(); try { project = Project .newBuilder() .name(name) .code(CodeGenerateUtils.getInstance().genCode()) .description(desc) .userId(loginUser.getId()) .userName(loginUser.getUserName()) .createTime(now) .updateTime(now) .build(); } catch (CodeGenerateException e) { putMsg(result, Status.CREATE_PROJECT_ERROR); return result; } if (projectMapper.insert(project) > 0) { result.put(Constants.DATA_LIST, project); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.CREATE_PROJECT_ERROR); } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
/** * query project details by code * * @param projectCode project code * @return project detail information */ @Override public Map<String, Object> queryByCode(User loginUser, long projectCode) { Map<String, Object> result = new HashMap<>(); Project project = projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result); if (!hasProjectAndPerm) { return result; } if (project != null) { result.put(Constants.DATA_LIST, project); putMsg(result, Status.SUCCESS); } return result; } @Override public Map<String, Object> queryByName(User loginUser, String projectName) { Map<String, Object> result = new HashMap<>(); Project project = projectMapper.queryByName(projectName); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result); if (!hasProjectAndPerm) { return result; } if (project != null) { result.put(Constants.DATA_LIST, project);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
putMsg(result, Status.SUCCESS); } return result; } /** * check project and authorization * * @param loginUser login user * @param project project * @param projectCode project code * @return true if the login user have permission to see the project */ @Override public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, long projectCode) { Map<String, Object> result = new HashMap<>(); if (project == null) { putMsg(result, Status.PROJECT_NOT_EXIST); } else if (!checkReadPermission(loginUser, project)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), projectCode); } else { putMsg(result, Status.SUCCESS); } return result; } @Override public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result) { boolean checkResult = false; if (project == null) { putMsg(result, Status.PROJECT_NOT_FOUND, "");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
} else if (!checkReadPermission(loginUser, project)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getCode()); } else { checkResult = true; } return checkResult; } @Override public boolean hasProjectAndPerm(User loginUser, Project project, Result result) { boolean checkResult = false; if (project == null) { putMsg(result, Status.PROJECT_NOT_FOUND, ""); } else if (!checkReadPermission(loginUser, project)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName()); } else { checkResult = true; } return checkResult; } /** * admin can view all projects * * @param loginUser login user * @param searchVal search value * @param pageSize page size * @param pageNo page number * @return project list which the login user have permission to see */ @Override public Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
Result result = new Result(); PageInfo<Project> pageInfo = new PageInfo<>(pageNo, pageSize); Page<Project> page = new Page<>(pageNo, pageSize); int userId = loginUser.getUserType() == UserType.ADMIN_USER ? 0 : loginUser.getId(); IPage<Project> projectIPage = projectMapper.queryProjectListPaging(page, userId, searchVal); List<Project> projectList = projectIPage.getRecords(); if (userId != 0) { for (Project project : projectList) { project.setPerm(Constants.DEFAULT_ADMIN_PERMISSION); } } pageInfo.setTotal((int) projectIPage.getTotal()); pageInfo.setTotalList(projectList); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * delete project by code * * @param loginUser login user * @param projectCode project code * @return delete result code */ @Override public Map<String, Object> deleteProject(User loginUser, Long projectCode) { Map<String, Object> result = new HashMap<>(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = getCheckResult(loginUser, project); if (checkResult != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
return checkResult; } if (!hasPerm(loginUser, project.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(project.getCode()); if (!processDefinitionList.isEmpty()) { putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL); return result; } int delete = projectMapper.deleteById(project.getId()); if (delete > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.DELETE_PROJECT_ERROR); } return result; } /** * get check result * * @param loginUser login user * @param project project * @return check result */ private Map<String, Object> getCheckResult(User loginUser, Project project) { Map<String, Object> checkResult = checkProjectAndAuth(loginUser, project, project == null ? 0L : project.getCode()); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
return checkResult; } return null; } /** * updateProcessInstance project * * @param loginUser login user * @param projectCode project code * @param projectName project name * @param desc description * @param userName project owner * @return update result code */ @Override public Map<String, Object> update(User loginUser, Long projectCode, String projectName, String desc, String userName) { Map<String, Object> result = new HashMap<>(); Map<String, Object> descCheck = checkDesc(desc); if (descCheck.get(Constants.STATUS) != Status.SUCCESS) { return descCheck; } Project project = projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result); if (!hasProjectAndPerm) { return result; } Project tempProject = projectMapper.queryByName(projectName); if (tempProject != null && tempProject.getCode() != project.getCode()) { putMsg(result, Status.PROJECT_ALREADY_EXISTS, projectName); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
} User user = userMapper.queryByUserNameAccurately(userName); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userName); return result; } project.setName(projectName); project.setDescription(desc); project.setUpdateTime(new Date()); project.setUserId(user.getId()); int update = projectMapper.updateById(project); if (update > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.UPDATE_PROJECT_ERROR); } return result; } /** * query unauthorized project * * @param loginUser login user * @param userId user id * @return the projects which user have not permission to see */ @Override public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (loginUser.getId() != userId && isNotAdmin(loginUser, result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
} List<Project> projectList = projectMapper.queryProjectExceptUserId(userId); List<Project> resultList = new ArrayList<>(); Set<Project> projectSet; if (projectList != null && !projectList.isEmpty()) { projectSet = new HashSet<>(projectList); List<Project> authedProjectList = projectMapper.queryAuthedProjectListByUserId(userId); resultList = getUnauthorizedProjects(projectSet, authedProjectList); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * get unauthorized project * * @param projectSet project set * @param authedProjectList authed project list * @return project list that authorization */ private List<Project> getUnauthorizedProjects(Set<Project> projectSet, List<Project> authedProjectList) { List<Project> resultList; Set<Project> authedProjectSet; if (authedProjectList != null && !authedProjectList.isEmpty()) { authedProjectSet = new HashSet<>(authedProjectList); projectSet.removeAll(authedProjectSet); } resultList = new ArrayList<>(projectSet); return resultList;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
} /** * query authorized project * * @param loginUser login user * @param userId user id * @return projects which the user have permission to see, Except for items created by this user */ @Override public Map<String, Object> queryAuthorizedProject(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (loginUser.getId() != userId && isNotAdmin(loginUser, result)) { return result; } List<Project> projects = projectMapper.queryAuthedProjectListByUserId(userId); result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; } /** * query authorized user * * @param loginUser login user * @param projectCode project code * @return users who have permission for the specified project */ @Override public Map<String, Object> queryAuthorizedUser(User loginUser, Long projectCode) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
Project project = this.projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = this.hasProjectAndPerm(loginUser, project, result); if (!hasProjectAndPerm) { return result; } List<User> users = this.userMapper.queryAuthedUserListByProjectId(project.getId()); result.put(Constants.DATA_LIST, users); this.putMsg(result, Status.SUCCESS); return result; } /** * query authorized project * * @param loginUser login user * @return projects which the user have permission to see, Except for items created by this user */ @Override public Map<String, Object> queryProjectCreatedByUser(User loginUser) { Map<String, Object> result = new HashMap<>(); List<Project> projects = projectMapper.queryProjectCreatedByUser(loginUser.getId()); result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; } /** * query authorized and user create project list by user * * @param loginUser login user * @return project list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
*/ @Override public Map<String, Object> queryProjectCreatedAndAuthorizedByUser(User loginUser) { Map<String, Object> result = new HashMap<>(); List<Project> projects = null; if (loginUser.getUserType() == UserType.ADMIN_USER) { projects = projectMapper.selectList(null); } else { projects = projectMapper.queryProjectCreatedAndAuthorizedByUserId(loginUser.getId()); } result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; } /** * check whether have read permission * * @param user user * @param project project * @return true if the user have permission to see the project, otherwise return false */ private boolean checkReadPermission(User user, Project project) { int permissionId = queryPermission(user, project); return (permissionId & Constants.READ_PERMISSION) != 0; } /** * query permission id * * @param user user * @param project project
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* @return permission */ private int queryPermission(User user, Project project) { if (user.getUserType() == UserType.ADMIN_USER) { return Constants.READ_PERMISSION; } if (project.getUserId() == user.getId()) { return Constants.ALL_PERMISSIONS; } ProjectUser projectUser = projectUserMapper.queryProjectRelation(project.getId(), user.getId()); if (projectUser == null) { return 0; } return projectUser.getPerm(); } /** * query all project list * * @return project list */ @Override public Map<String, Object> queryAllProjectList() { Map<String, Object> result = new HashMap<>(); List<Project> projects = projectMapper.queryAllProject(); result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.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.impl; import static org.apache.dolphinscheduler.common.Constants.ALIAS; import static org.apache.dolphinscheduler.common.Constants.CONTENT; import static org.apache.dolphinscheduler.common.Constants.JAR;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.RegexUtils; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; 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.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; 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.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.commons.beanutils.BeanMap;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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.Arrays; 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.UUID; import java.util.regex.Matcher; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.SerializationFeature; import com.google.common.io.Files; /** * resources service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class); @Autowired private ResourceMapper resourcesMapper; @Autowired private UdfFuncMapper udfFunctionMapper; @Autowired private TenantMapper tenantMapper; @Autowired private UserMapper userMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; /** * create directory * * @param loginUser login user * @param name alias * @param description description * @param type type * @param pid parent id * @param currentDir current directory * @return create directory result */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> createDirectory(User loginUser, String name, String description,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
ResourceType type, int pid, String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,true,description,name,loginUser.getId(),type,0,now,now); try { resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (DuplicateKeyException e) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } catch (Exception e) { logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } createDirectory(loginUser,fullName,type,result); return result; } /** * create resource * * @param loginUser login user * @param name alias * @param desc description * @param file file * @param type type * @param pid parent id * @param currentDir current directory * @return create result code */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> createResource(User loginUser, String name, String desc, ResourceType type,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
MultipartFile file, int pid, String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyPid(loginUser, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); putMsg(result, Status.RESOURCE_EXIST); return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,false,desc,file.getOriginalFilename(),loginUser.getId(),type,file.getSize(),now,now); try { resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (Exception e) { logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } return result; } /** * check resource is exists * * @param fullName fullName * @param type type * @return true if resource exists */ private boolean checkResourceExists(String fullName, int type) { Boolean existResource = resourcesMapper.existResource(fullName, type); return existResource == Boolean.TRUE; } /** * update resource
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param loginUser login user * @param resourceId resource id * @param name name * @param desc description * @param type resource type * @param file resource file * @return update result code */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> updateResource(User loginUser, int resourceId, String name, String desc, ResourceType type, MultipartFile file) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } String originFullName = resource.getFullName(); String originResourceName = resource.getAlias(); String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/") + 1),name); if (!originResourceName.equals(name) && checkResourceExists(fullName, type.ordinal())) { logger.error("resource {} already exists, can't recreate", name); putMsg(result, Status.RESOURCE_EXIST); return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } String originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName); try { if (!HadoopUtils.getInstance().exists(originHdfsFileName)) { logger.error("{} not exist", originHdfsFileName); putMsg(result,Status.RESOURCE_NOT_EXIST); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (IOException e) { logger.error(e.getMessage(),e); throw new ServiceException(Status.HDFS_OPERATION_ERROR); } if (!resource.isDirectory()) { String originSuffix = Files.getFileExtension(originFullName); String suffix = Files.getFileExtension(fullName); boolean suffixIsChanged = false; if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) { suffixIsChanged = true; } if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) { suffixIsChanged = true; } if (suffixIsChanged) { Map<String, Object> columnMap = new HashMap<>(); columnMap.put("resources_id", resourceId); List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap); if (CollectionUtils.isNotEmpty(resourcesUsers)) { List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList()); List<User> users = userMapper.selectBatchIds(userIds); String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString(); logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames); putMsg(result,Status.RESOURCE_IS_AUTHORIZED,userNames); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} Date now = new Date(); resource.setAlias(name); resource.setFileName(name); resource.setFullName(fullName); resource.setDescription(desc); resource.setUpdateTime(now); if (file != null) { resource.setSize(file.getSize()); } try { resourcesMapper.updateById(resource); if (resource.isDirectory()) { List<Integer> childrenResource = listAllChildren(resource,false); if (CollectionUtils.isNotEmpty(childrenResource)) { String matcherFullName = Matcher.quoteReplacement(fullName); List<Resource> childResourceList; Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]); List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray); childResourceList = resourceList.stream().map(t -> { t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); resourcesMapper.batchUpdateResource(childResourceList); if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } } } else if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId}); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> { t.setResourceName(fullName); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (Exception e) { logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR); } if (originResourceName.equals(name) && file == null) { return result; } if (file != null) { if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", name, RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } if (!fullName.equals(originFullName)) { try { HadoopUtils.getInstance().delete(originHdfsFileName,false); } catch (IOException e) { logger.error(e.getMessage(),e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); } } return result; } String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName); try { logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName); HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, destHdfsFileName), e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result,Status.HDFS_COPY_FAIL); throw new ServiceException(Status.HDFS_COPY_FAIL); } return result; } private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (file != null) { if (file.isEmpty()) { logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(name); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT); return result; } } return result; } /** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); Page<Resource> page = new Page<>(pageNo, pageSize); int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; } if (directoryId != -1) { Resource directory = resourcesMapper.selectById(directoryId); if (directory == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } List<Integer> resourcesIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds); PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int)resourceIPage.getTotal()); pageInfo.setTotalList(resourceIPage.getRecords()); result.setData(pageInfo); putMsg(result,Status.SUCCESS); return result; } /** * create directory * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser,String fullName,ResourceType type,Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String directoryName = HadoopUtils.getHdfsFileName(type,tenantCode,fullName); String resourceRootPath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourceRootPath)) { createTenantDirIfNotExists(tenantCode); } if (!HadoopUtils.getInstance().mkdir(directoryName)) { logger.error("create resource directory {} of hdfs failed",directoryName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } catch (Exception e) { logger.error("create resource directory {} of hdfs failed",directoryName); putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } /** * upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(fullName); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { return false; } String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String resourcePath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourcePath)) { createTenantDirIfNotExists(tenantCode); } org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename); HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); } catch (Exception e) { FileUtils.deleteFile(localFilename); logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON: suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> delete(User loginUser, int resourceId) throws IOException { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Map<String, Object>> list = processDefinitionMapper.listResources(); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); List<Integer> allChildren = listAllChildren(resource,true); Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]); if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs); putMsg(result,Status.UDF_RESOURCE_IS_BOUND,udfFuncs.get(0).getFuncName()); return result; } } if (resourceIdSet.contains(resource.getPid())) { logger.error("can't be deleted,because it is used of process definition"); putMsg(result, Status.RESOURCE_IS_USED); return result; } resourceIdSet.retainAll(allChildren); 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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String hdfsFilename = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); resourcesMapper.deleteIds(needDeleteResourceIdArray); resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); HadoopUtils.getInstance().delete(hdfsFilename, true); putMsg(result, Status.SUCCESS); return result; } /** * verify resource by name and type * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } else { Tenant tenant = tenantMapper.queryById(loginUser.getTenantId()); if (tenant != null) { String tenantCode = tenant.getTenantCode(); try { String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (HadoopUtils.getInstance().exists(hdfsFilename)) { logger.error("resource type:{} name:{} has exist in hdfs {}, can't create again.", type, RegexUtils.escapeNRT(fullName), hdfsFilename); putMsg(result, Status.RESOURCE_FILE_EXIST,hdfsFilename); } } catch (Exception e) { logger.error(e.getMessage(),e); putMsg(result,Status.HDFS_OPERATION_ERROR); } } else { putMsg(result,Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); } } return result; } /** * verify resource by full name or pid and type * @param fullName resource full name * @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResource(String fullName, Integer id, ResourceType type) { Result<Object> result = new Result<>(); if (StringUtils.isBlank(fullName) && id == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName,type.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isEmpty(resourceList)) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(resourceList.get(0)); } else { Resource resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } Resource parentResource = resourcesMapper.selectById(resource.getPid()); if (parentResource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(parentResource); } return result; } /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Override public Result<Object> readResource(int resourceId, int skipLineNum, int limit) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } String hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resource.getFullName()); logger.info("resource hdfs path is {}", hdfsFileName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
try { if (HadoopUtils.getInstance().exists(hdfsFileName)) { List<String> content = HadoopUtils.getInstance().catFile(hdfsFileName, skipLineNum, limit); putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, resource.getAlias()); map.put(CONTENT, String.join("\n", content)); result.setData(map); } else { logger.error("read file {} not exist in hdfs", hdfsFileName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST,hdfsFileName); } } catch (Exception e) { logger.error("Resource {} read failed", hdfsFileName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); } return result; } /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @param pid pid * @param currentDir current directory * @return create result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,false,desc,name,loginUser.getId(),type,content.getBytes().length,now,now); resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); result = uploadContentToHdfs(fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.HDFS_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, parentResource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource * * @param resourceId resource id * @param content content * @return update result cod */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> updateResourceContent(int resourceId, String content) { Result<Object> result = checkResourceUploadStartupState();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("read file not exist, resource id {}", resourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } resource.setSize(content.getBytes().length); resource.setUpdateTime(new Date()); resourcesMapper.updateById(resource); result = uploadContentToHdfs(resource.getFullName(), tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } /** * @param resourceName resource name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToHdfs(String resourceName, String tenantCode, String content) { Result<Object> result = new Result<>(); String localFilename = ""; String hdfsFileName = ""; try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resourceName); String resourcePath = HadoopUtils.getHdfsResDir(tenantCode); logger.info("resource hdfs path is {}, resource dir is {}", hdfsFileName, resourcePath); HadoopUtils hadoopUtils = HadoopUtils.getInstance(); if (!hadoopUtils.exists(resourcePath)) { createTenantDirIfNotExists(tenantCode); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (hadoopUtils.exists(hdfsFileName)) { hadoopUtils.delete(hdfsFileName, false); } hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true); } catch (Exception e) { logger.error(e.getMessage(), e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, hdfsFileName)); return result; } putMsg(result, Status.SUCCESS); return result; } /** * download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(int resourceId) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("download file not exist, resource id {}", resourceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return null; } if (resource.isDirectory()) { logger.error("resource id {} is directory,can't download it", resourceId); throw new ServiceException("can't download directory"); } int userId = resource.getUserId(); User user = userMapper.selectById(userId); if (user == null) { logger.error("user id {} not exists", userId); throw new ServiceException(String.format("resource owner id %d not exist",userId)); } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant id {} not exists", user.getTenantId()); throw new ServiceException(String.format("The tenant id %d of resource owner not exist",user.getTenantId())); } String tenantCode = tenant.getTenantCode(); String hdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); String localFileName = FileUtils.getDownloadFilename(resource.getAlias()); logger.info("resource hdfs path is {}, download local filename is {}", hdfsFileName, localFileName); HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { Visitor visitor = new ResourceTreeVisitor(resourceList); list = visitor.visit().getChildren(); } else { list = new ArrayList<>(0); } result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0); } Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet; if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } /** * authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result,Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) { Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * get tenantCode by UserId * * @param userId user id * @param result return result * @return tenant code */ private String getTenantCode(int userId,Result<Object> result) { User user = userMapper.selectById(userId); if (user == null) { logger.error("user {} not exists", userId); putMsg(result, Status.USER_NOT_EXIST,userId); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return null; } return tenant.getTenantCode(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * list all children id * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource,boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != -1 && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(),childList); } return childList; } /** * list all children id * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId,List<Integer> childList) { List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { List<Resource> relationResources; int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; relationResources = new ArrayList<>(); } else { relationResources = queryResourceList(userId, 0); } List<Resource> ownResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal()); ownResourceList.addAll(relationResources); return ownResourceList; } /** * query resource list by userId and perm * @param userId userId * @param perm perm * @return resource list */ private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
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. */ 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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; 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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 public class UsersServiceImpl extends BaseServiceImpl implements UsersService { private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class); @Autowired private AccessTokenMapper accessTokenMapper; @Autowired private UserMapper userMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
@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 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
*/ @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<>(); 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()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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) 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
user.setCreateTime(now); user.setUpdateTime(now); if (StringUtils.isEmpty(queue)) { queue = ""; } user.setQueue(queue); userMapper.insert(user); return user; } /*** * create User for ldap login */ @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; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* 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 * @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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @return user info */ @Override public User queryUser(String name) { return userMapper.queryByUserNameAccurately(name); } /** * query user * * @param name name * @param password password * @return user info */ @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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (null != executor) { executorId = executor.getId(); } else { executorId = -1; } } return executorId; } /** * query user list * * @param loginUser login user * @param pageNo page number * @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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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 * @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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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); 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone); return result; } if (state == 0 && user.getState() != state && loginUser.getId() == user.getId()) { putMsg(result, Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT); 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()); 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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); 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()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
} } 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 */ @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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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); } } } 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
* @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; } 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
projectUser.setUpdateTime(now); projectUserMapper.insert(projectUser); } putMsg(result, Status.SUCCESS); return result; } /** * grant project by code * * @param loginUser login user * @param userId user id * @param projectCode project code * @return grant result code */ @Override public Map<String, Object> grantProjectByCode(final User loginUser, final int userId, final long projectCode) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); User tempUser = this.userMapper.selectById(userId); if (tempUser == null) { this.putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Project project = this.projectMapper.queryByCode(projectCode); if (project == null) { this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
if (!this.hasPerm(loginUser, project.getUserId())) { this.putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } final Date today = new Date(); ProjectUser projectUser = new ProjectUser(); projectUser.setUserId(userId); projectUser.setProjectId(project.getId()); projectUser.setPerm(7); projectUser.setCreateTime(today); projectUser.setUpdateTime(today); this.projectUserMapper.insert(projectUser); this.putMsg(result, Status.SUCCESS); return result; } /** * revoke the project permission for specified user. * @param loginUser Login user * @param userId User id * @param projectCode Project Code * @return */ @Override public Map<String, Object> revokeProject(User loginUser, int userId, long projectCode) { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, false); if (this.check(result, !this.isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
return result; } User user = this.userMapper.selectById(userId); if (user == null) { this.putMsg(result, Status.USER_NOT_EXIST, userId); return result; } Project project = this.projectMapper.queryByCode(projectCode); if (project == null) { this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); return result; } this.projectUserMapper.deleteProjectRelation(project.getId(), user.getId()); this.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
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
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
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
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
6,820
[Feature][API] Ordinary users can also share resource data source projects with others
### 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 Ordinary users can also share resource data source projects with others ### 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/6820
https://github.com/apache/dolphinscheduler/pull/7929
0c353d69e29a0b562ebb6938d345fc1b4589b781
82d04f1924692db83461b8c7800f2ab7228825c1
2021-11-11T16:24:04Z
java
2022-01-15T01:08:03Z
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;