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 | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testReadResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true);
result = resourcesService.readResource(getUser(), 2, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), (int) result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.anyString())).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FILE_NOT_EXIST.getCode(), (int) result.getCode());
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(true);
Mockito.when(storageOperate.vimFile(Mockito.any(), Mockito.any(), eq(1), eq(10))).thenReturn(getContent());
} catch (IOException e) {
logger.error("storage error", e);
}
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testOnlineCreateResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(storageOperate.getResourceFileName(Mockito.anyString(), eq("hdfsdDir"))).thenReturn("hdfsDir");
PowerMockito.when(storageOperate.getUdfDir("udfDir")).thenReturn("udfDir");
User user = getUser();
user.setId(1);
Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
try {
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
} catch (RuntimeException ex) {
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testUpdateResourceContent() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
Result result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.updateResourceContent(getUser(), 2, "content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getCode() == result.getCode());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testDownloadResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_DOWNLOAD, serviceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class);
try {
org.springframework.core.io.Resource resource = resourcesService.downloadResource(getUser(), 1);
Assert.assertNull(resource);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock);
resource = resourcesService.downloadResource(getUser(), 1);
Assert.assertNotNull(resource);
} catch (Exception e) {
logger.error("DownloadResource error", e);
Assert.assertTrue(false);
}
}
@Test
public void testAuthorizeResourceTree() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedFile() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getSingleResourceList());
Map<String, Object> result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList());
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList());
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", user.getId()))).thenReturn(getUdfFuncList());
result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setUserType(UserType.GENERAL_USER);
user.setId(2);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedFile() {
User user = getUser();
user.setId(1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testCatFile() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
try {
Mockito.when(storageOperate.exists(Mockito.anyString(), Mockito.anyString())).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(storageOperate.vimFile(Mockito.anyString(), Mockito.anyString(), eq(1), eq(10))).thenReturn(getContent());
List<String> list = storageOperate.vimFile(Mockito.any(), Mockito.anyString(), eq(1), eq(10));
Assert.assertNotNull(list);
} catch (IOException e) {
logger.error("hadoop error", e);
}
}
private List<Resource> getResourceList() {
List<Resource> resources = new ArrayList<>();
resources.add(getResource(1));
resources.add(getResource(2));
resources.add(getResource(3));
return resources;
}
private Set<Integer> getSetIds() {
Set<Integer> resources = new HashSet<>();
resources.add(1);
return resources;
}
private List<Resource> getSingleResourceList() {
return Collections.singletonList(getResource(1));
}
private Tenant getTenant() {
Tenant tenant = new Tenant();
tenant.setTenantCode("123");
return tenant;
}
private Resource getResource() {
Resource resource = new Resource();
resource.setPid(-1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId,ResourceType type) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(type);
return resource;
}
private Resource getUdfResource() { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Resource resource = new Resource();
resource.setUserId(1);
resource.setDescription("udfTest");
resource.setAlias("udfTest.jar");
resource.setFullName("/udfTest.jar");
resource.setType(ResourceType.UDF);
return resource;
}
private UdfFunc getUdfFunc() {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(1);
return udfFunc;
}
private UdfFunc getUdfFunc(int udfId) {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(udfId);
return udfFunc;
}
private List<UdfFunc> getUdfFuncList() {
List<UdfFunc> udfFuncs = new ArrayList<>();
udfFuncs.add(getUdfFunc(1));
udfFuncs.add(getUdfFunc(2));
udfFuncs.add(getUdfFunc(3));
return udfFuncs;
}
private List<UdfFunc> getSingleUdfFuncList() {
return Collections.singletonList(getUdfFunc(3));
}
private User getUser() {
User user = new User(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,293 | [Bug] [Api-Server] Improve exception handling when admin user uploads file in resource center | ### 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
* If user logs in with admin role and does not set tenant, there will be `null pointer exception` when he / she tries to upload files in `resource center`.

### What you expected to happen
* We need some exception handling here and provide users with instructive error message: https://github.com/apache/dolphinscheduler/blob/8d26d4fe72aa81437103716b22f52ef6dc515a14/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L653-L656
* We need to remind users that tenant should be set before playing with `resource center` if they log in with `admin` role.
### How to reproduce
* Already described above.
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10293 | https://github.com/apache/dolphinscheduler/pull/10303 | 3f2a21293d1b7cc8fe12a5e951fda15d231b05ac | 442f93544eef5436f82a0c9f7dacde93d4347090 | 2022-05-30T07:41:04Z | java | 2022-06-01T09:22:36Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setId(1);
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(1);
user.setTenantCode("tenantCode");
return user;
}
private List<String> getContent() {
List<String> contentList = new ArrayList<>();
contentList.add("test");
return contentList;
}
private List<Map<String, Object>> getResources() {
List<Map<String, Object>> resources = new ArrayList<>();
Map<String, Object> resource = new HashMap<>();
resource.put("id", 1);
resource.put("resource_ids", "1");
resources.add(resource);
return resources;
}
private static String getRandomStringWithLength(int length) {
Random r = new Random();
StringBuilder sb = new StringBuilder();
while (sb.length() < length) {
char c = (char) (r.nextInt(26) + 'a');
sb.append(c);
}
return sb.toString();
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/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.common;
import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import java.util.regex.Pattern;
/**
* Constants
*/
public final class Constants { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | private Constants() {
throw new UnsupportedOperationException("Construct Constants");
}
/**
* common properties path
*/
public static final String COMMON_PROPERTIES_PATH = "/common.properties";
/**
* registry properties
*/
public static final String REGISTRY_DOLPHINSCHEDULER_MASTERS = "/nodes/master";
public static final String REGISTRY_DOLPHINSCHEDULER_WORKERS = "/nodes/worker";
public static final String REGISTRY_DOLPHINSCHEDULER_DEAD_SERVERS = "/dead-servers";
public static final String REGISTRY_DOLPHINSCHEDULER_NODE = "/nodes";
public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_MASTERS = "/lock/masters";
public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_MASTERS = "/lock/failover/masters";
public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_WORKERS = "/lock/failover/workers";
public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_STARTUP_MASTERS = "/lock/failover/startup-masters";
public static final String FORMAT_SS = "%s%s";
public static final String FORMAT_S_S = "%s/%s";
public static final String AWS_ACCESS_KEY_ID = "aws.access.key.id";
public static final String AWS_SECRET_ACCESS_KEY = "aws.secret.access.key";
public static final String AWS_REGION = "aws.region";
public static final String FOLDER_SEPARATOR = "/";
public static final String RESOURCE_TYPE_FILE = "resources";
public static final String RESOURCE_TYPE_UDF = "udfs";
public static final String STORAGE_S3 = "S3"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String STORAGE_HDFS = "HDFS";
public static final String BUCKET_NAME = "dolphinscheduler-test";
public static final String EMPTY_STRING = "";
/**
* fs.defaultFS
*/
public static final String FS_DEFAULT_FS = "fs.defaultFS";
/**
* hadoop configuration
*/
public static final String HADOOP_RM_STATE_ACTIVE = "ACTIVE";
public static final String HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT = "resource.manager.httpaddress.port";
/**
* yarn.resourcemanager.ha.rm.ids
*/
public static final String YARN_RESOURCEMANAGER_HA_RM_IDS = "yarn.resourcemanager.ha.rm.ids";
/**
* yarn.application.status.address
*/
public static final String YARN_APPLICATION_STATUS_ADDRESS = "yarn.application.status.address";
/**
* yarn.job.history.status.address
*/
public static final String YARN_JOB_HISTORY_STATUS_ADDRESS = "yarn.job.history.status.address";
/**
* hdfs configuration
* hdfs.root.user
*/
public static final String HDFS_ROOT_USER = "hdfs.root.user";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * hdfs/s3 configuration
* resource.upload.path
*/
public static final String RESOURCE_UPLOAD_PATH = "resource.upload.path";
/**
* data basedir path
*/
public static final String DATA_BASEDIR_PATH = "data.basedir.path";
/**
* dolphinscheduler.env.path
*/
public static final String DOLPHINSCHEDULER_ENV_PATH = "dolphinscheduler.env.path";
/**
* environment properties default path
*/
public static final String ENV_PATH = "dolphinscheduler_env.sh";
/**
* resource.view.suffixs
*/
public static final String RESOURCE_VIEW_SUFFIXES = "resource.view.suffixs";
public static final String RESOURCE_VIEW_SUFFIXES_DEFAULT_VALUE = "txt,log,sh,bat,conf,cfg,py,java,sql,xml,hql,properties,json,yml,yaml,ini,js";
/**
* development.state
*/
public static final String DEVELOPMENT_STATE = "development.state";
/**
* sudo enable
*/
public static final String SUDO_ENABLE = "sudo.enable";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * string true
*/
public static final String STRING_TRUE = "true";
/**
* resource storage type
*/
public static final String RESOURCE_STORAGE_TYPE = "resource.storage.type";
public static final String AWS_END_POINT = "aws.endpoint";
/**
* comma ,
*/
public static final String COMMA = ",";
/**
* COLON :
*/
public static final String COLON = ":";
/**
* QUESTION ?
*/
public static final String QUESTION = "?";
/**
* SPACE " "
*/
public static final String SPACE = " ";
/**
* SINGLE_SLASH /
*/
public static final String SINGLE_SLASH = "/";
/**
* DOUBLE_SLASH // |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String DOUBLE_SLASH = "//";
/**
* EQUAL SIGN
*/
public static final String EQUAL_SIGN = "=";
/**
* AT SIGN
*/
public static final String AT_SIGN = "@";
/**
* 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 yyyyMMdd
*/
public static final String YYYYMMDD = "yyyyMMdd";
/**
* date format of yyyyMMddHHmmss
*/
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
/**
* date format of yyyyMMddHHmmssSSS
*/
public static final String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";
/**
* http connect time out
*/
public static final int HTTP_CONNECT_TIMEOUT = 60 * 1000; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* http connect request time out
*/
public static final int HTTP_CONNECTION_REQUEST_TIMEOUT = 60 * 1000;
/**
* httpclient soceket time out
*/
public static final int SOCKET_TIMEOUT = 60 * 1000;
/**
* registry session timeout
*/
public static final int REGISTRY_SESSION_TIMEOUT = 10 * 1000;
/**
* http header
*/
public static final String HTTP_HEADER_UNKNOWN = "unKnown";
/**
* http X-Forwarded-For
*/
public static final String HTTP_X_FORWARDED_FOR = "X-Forwarded-For";
/**
* http X-Real-IP
*/
public static final String HTTP_X_REAL_IP = "X-Real-IP";
/**
* UTF-8
*/
public static final String UTF_8 = "UTF-8";
/**
* user name regex |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final Pattern REGEX_USER_NAME = Pattern.compile("^[a-zA-Z0-9._-]{3,39}$");
/**
* read permission
*/
public static final int READ_PERMISSION = 2;
/**
* write permission
*/
public static final int WRITE_PERMISSION = 2 * 2;
/**
* execute permission
*/
public static final int EXECUTE_PERMISSION = 1;
/**
* default admin permission
*/
public static final int DEFAULT_ADMIN_PERMISSION = 7;
/**
* default hash map size
*/
public static final int DEFAULT_HASH_MAP_SIZE = 16;
/**
* all permissions
*/
public static final int ALL_PERMISSIONS = READ_PERMISSION | WRITE_PERMISSION | EXECUTE_PERMISSION;
/**
* max task timeout
*/
public static final int MAX_TASK_TIMEOUT = 24 * 3600; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* worker host weight
*/
public static final int DEFAULT_WORKER_HOST_WEIGHT = 100;
/**
* time unit secong to minutes
*/
public static final int SEC_2_MINUTES_TIME_UNIT = 60;
/***
*
* rpc port
*/
public static final String RPC_PORT = "rpc.port";
/**
* forbid running task
*/
public static final String FLOWNODE_RUN_FLAG_FORBIDDEN = "FORBIDDEN";
/**
* normal running task
*/
public static final String FLOWNODE_RUN_FLAG_NORMAL = "NORMAL";
public static final String COMMON_TASK_TYPE = "common";
public static final String DEFAULT = "default";
public static final String PASSWORD = "password";
public static final String XXXXXX = "******";
public static final String NULL = "NULL";
public static final String THREAD_NAME_MASTER_SERVER = "Master-Server";
public static final String THREAD_NAME_WORKER_SERVER = "Worker-Server";
public static final String THREAD_NAME_ALERT_SERVER = "Alert-Server";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * command parameter keys
*/
public static final String CMD_PARAM_RECOVER_PROCESS_ID_STRING = "ProcessInstanceId";
public static final String CMD_PARAM_RECOVERY_START_NODE_STRING = "StartNodeIdList";
public static final String CMD_PARAM_RECOVERY_WAITING_THREAD = "WaitingThreadInstanceId";
public static final String CMD_PARAM_SUB_PROCESS = "processInstanceId";
public static final String CMD_PARAM_EMPTY_SUB_PROCESS = "0";
public static final String CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID = "parentProcessInstanceId";
public static final String CMD_PARAM_SUB_PROCESS_DEFINE_CODE = "processDefinitionCode";
public static final String CMD_PARAM_START_NODES = "StartNodeList";
public static final String CMD_PARAM_START_PARAMS = "StartParams";
public static final String CMD_PARAM_FATHER_PARAMS = "fatherParams";
/**
* complement data start date
*/
public static final String CMDPARAM_COMPLEMENT_DATA_START_DATE = "complementStartDate";
/**
* complement data end date
*/
public static final String CMDPARAM_COMPLEMENT_DATA_END_DATE = "complementEndDate";
/**
* complement date default cron string
*/
public static final String DEFAULT_CRON_STRING = "0 0 0 * * ? *";
/**
* sleep 1000ms
*/
public static final int SLEEP_TIME_MILLIS = 1000;
/**
* short sleep 100ms |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final int SLEEP_TIME_MILLIS_SHORT = 100;
/**
* one second mils
*/
public static final int SECOND_TIME_MILLIS = 1000;
/**
* master task instance cache-database refresh interval
*/
public static final int CACHE_REFRESH_TIME_MILLIS = 20 * 1000;
/**
* heartbeat for zk info length
*/
public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 13;
/**
* jar
*/
public static final String JAR = "jar";
/**
* hadoop
*/
public static final String HADOOP = "hadoop";
/**
* -D <property>=<value>
*/
public static final String D = "-D";
/**
* exit code success
*/
public static final int EXIT_CODE_SUCCESS = 0; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | /**
* exit code failure
*/
public static final int EXIT_CODE_FAILURE = -1;
/**
* process or task definition failure
*/
public static final int DEFINITION_FAILURE = -1;
public static final int OPPOSITE_VALUE = -1;
/**
* process or task definition first version
*/
public static final int VERSION_FIRST = 1;
/**
* date format of yyyyMMdd
*/
public static final String PARAMETER_FORMAT_DATE = "yyyyMMdd";
/**
* date format of yyyyMMddHHmmss
*/
public static final String PARAMETER_FORMAT_TIME = "yyyyMMddHHmmss";
/**
* system date(yyyyMMddHHmmss)
*/
public static final String PARAMETER_DATETIME = "system.datetime";
/**
* system date(yyyymmdd) today
*/
public static final String PARAMETER_CURRENT_DATE = "system.biz.curdate";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * system date(yyyymmdd) yesterday
*/
public static final String PARAMETER_BUSINESS_DATE = "system.biz.date";
/**
* ACCEPTED
*/
public static final String ACCEPTED = "ACCEPTED";
/**
* SUCCEEDED
*/
public static final String SUCCEEDED = "SUCCEEDED";
/**
* ENDED
*/
public static final String ENDED = "ENDED";
/**
* NEW
*/
public static final String NEW = "NEW";
/**
* NEW_SAVING
*/
public static final String NEW_SAVING = "NEW_SAVING";
/**
* SUBMITTED
*/
public static final String SUBMITTED = "SUBMITTED";
/**
* FAILED
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String FAILED = "FAILED";
/**
* KILLED
*/
public static final String KILLED = "KILLED";
/**
* RUNNING
*/
public static final String RUNNING = "RUNNING";
/**
* underline "_"
*/
public static final String UNDERLINE = "_";
/**
* quartz job prifix
*/
public static final String QUARTZ_JOB_PREFIX = "job";
/**
* quartz job group prifix
*/
public static final String QUARTZ_JOB_GROUP_PREFIX = "jobgroup";
/**
* projectId
*/
public static final String PROJECT_ID = "projectId";
/**
* processId
*/
public static final String SCHEDULE_ID = "scheduleId";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * schedule
*/
public static final String SCHEDULE = "schedule";
/**
* application regex
*/
public static final String APPLICATION_REGEX = "application_\\d+_\\d+";
public static final String PID = SystemUtils.IS_OS_WINDOWS ? "handle" : "pid";
/**
* month_begin
*/
public static final String MONTH_BEGIN = "month_begin";
/**
* add_months
*/
public static final String ADD_MONTHS = "add_months";
/**
* month_end
*/
public static final String MONTH_END = "month_end";
/**
* week_begin
*/
public static final String WEEK_BEGIN = "week_begin";
/**
* week_end
*/
public static final String WEEK_END = "week_end";
/**
* timestamp |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String TIMESTAMP = "timestamp";
public static final char SUBTRACT_CHAR = '-';
public static final char ADD_CHAR = '+';
public static final char MULTIPLY_CHAR = '*';
public static final char DIVISION_CHAR = '/';
public static final char LEFT_BRACE_CHAR = '(';
public static final char RIGHT_BRACE_CHAR = ')';
public static final String ADD_STRING = "+";
public static final String STAR = "*";
public static final String DIVISION_STRING = "/";
public static final String LEFT_BRACE_STRING = "(";
public static final char P = 'P';
public static final char N = 'N';
public static final String SUBTRACT_STRING = "-";
public static final String GLOBAL_PARAMS = "globalParams";
public static final String LOCAL_PARAMS = "localParams";
public static final String SUBPROCESS_INSTANCE_ID = "subProcessInstanceId";
public static final String PROCESS_INSTANCE_STATE = "processInstanceState";
public static final String PARENT_WORKFLOW_INSTANCE = "parentWorkflowInstance";
public static final String CONDITION_RESULT = "conditionResult";
public static final String SWITCH_RESULT = "switchResult";
public static final String WAIT_START_TIMEOUT = "waitStartTimeout";
public static final String DEPENDENCE = "dependence";
public static final String TASK_LIST = "taskList";
public static final String QUEUE = "queue";
public static final String QUEUE_NAME = "queueName";
public static final int LOG_QUERY_SKIP_LINE_NUMBER = 0;
public static final int LOG_QUERY_LIMIT = 4096;
public static final String BLOCKING_CONDITION = "blockingCondition"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String ALERT_WHEN_BLOCKING = "alertWhenBlocking";
/**
* master/worker server use for zk
*/
public static final String MASTER_TYPE = "master";
public static final String WORKER_TYPE = "worker";
public static final String DELETE_OP = "delete";
public static final String ADD_OP = "add";
public static final String ALIAS = "alias";
public static final String CONTENT = "content";
public static final String DEPENDENT_SPLIT = ":||";
public static final long DEPENDENT_ALL_TASK_CODE = 0;
/**
* preview schedule execute count
*/
public static final int PREVIEW_SCHEDULE_EXECUTE_COUNT = 5;
/**
* kerberos
*/
public static final String KERBEROS = "kerberos";
/**
* kerberos expire time
*/
public static final String KERBEROS_EXPIRE_TIME = "kerberos.expire.time";
/**
* java.security.krb5.conf
*/
public static final String JAVA_SECURITY_KRB5_CONF = "java.security.krb5.conf";
/**
* java.security.krb5.conf.path |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | */
public static final String JAVA_SECURITY_KRB5_CONF_PATH = "java.security.krb5.conf.path";
/**
* hadoop.security.authentication
*/
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";
/**
* com.amazonaws.services.s3.enableV4
*/
public static final String AWS_S3_V4 = "com.amazonaws.services.s3.enableV4";
/**
* 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";
/**
* task log info format
*/
public static final String TASK_LOG_INFO_FORMAT = "TaskLogInfo-%s";
public static final int[] NOT_TERMINATED_STATES = new int[]{
ExecutionStatus.SUBMITTED_SUCCESS.ordinal(),
ExecutionStatus.DISPATCH.ordinal(),
ExecutionStatus.RUNNING_EXECUTION.ordinal(), |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | ExecutionStatus.DELAY_EXECUTION.ordinal(),
ExecutionStatus.READY_PAUSE.ordinal(),
ExecutionStatus.READY_STOP.ordinal(),
ExecutionStatus.NEED_FAULT_TOLERANCE.ordinal(),
ExecutionStatus.WAITING_THREAD.ordinal(),
ExecutionStatus.WAITING_DEPEND.ordinal()
};
public static final int[] RUNNING_PROCESS_STATE = new int[]{
ExecutionStatus.RUNNING_EXECUTION.ordinal(),
ExecutionStatus.SUBMITTED_SUCCESS.ordinal(),
ExecutionStatus.DISPATCH.ordinal(),
ExecutionStatus.SERIAL_WAIT.ordinal()
};
/**
* status
*/
public static final String STATUS = "status";
/**
* message
*/
public static final String MSG = "msg";
/**
* data total
*/
public static final String COUNT = "count";
/**
* page size
*/
public static final String PAGE_SIZE = "pageSize";
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | * current page no
*/
public static final String PAGE_NUMBER = "pageNo";
/**
*
*/
public static final String DATA_LIST = "data";
public static final String TOTAL_LIST = "totalList";
public static final String CURRENT_PAGE = "currentPage";
public static final String TOTAL_PAGE = "totalPage";
public static final String TOTAL = "total";
/**
* workflow
*/
public static final String WORKFLOW_LIST = "workFlowList";
public static final String WORKFLOW_RELATION_LIST = "workFlowRelationList";
/**
* session user
*/
public static final String SESSION_USER = "session.user";
public static final String SESSION_ID = "sessionId";
/**
* locale
*/
public static final String LOCALE_LANGUAGE = "language";
/**
* database type
*/
public static final String MYSQL = "MYSQL";
public static final String HIVE = "HIVE"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final String ADDRESS = "address";
public static final String DATABASE = "database";
public static final String OTHER = "other";
public static final String USER = "user";
public static final String JDBC_URL = "jdbcUrl";
/**
* session timeout
*/
public static final int SESSION_TIME_OUT = 7200;
public static final int MAX_FILE_SIZE = 1024 * 1024 * 1024;
public static final String UDF = "UDF";
public static final String CLASS = "class";
/**
* dataSource sensitive param
*/
public static final String DATASOURCE_PASSWORD_REGEX = "(?<=((?i)password((\\\\\":\\\\\")|(=')))).*?(?=((\\\\\")|(')))";
/**
* default worker group
*/
public static final String DEFAULT_WORKER_GROUP = "default";
/**
* authorize writable perm
*/
public static final int AUTHORIZE_WRITABLE_PERM = 7;
/**
* authorize readable perm
*/
public static final int AUTHORIZE_READABLE_PERM = 4;
public static final int NORMAL_NODE_STATUS = 0;
public static final int ABNORMAL_NODE_STATUS = 1; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final int BUSY_NODE_STATUE = 2;
public static final String START_TIME = "start time";
public static final String END_TIME = "end time";
public static final String START_END_DATE = "startDate,endDate";
/**
* system line separator
*/
public static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator");
/**
* 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";
/**
* network interface preferred
*/
public static final String DOLPHIN_SCHEDULER_NETWORK_INTERFACE_PREFERRED = "dolphin.scheduler.network.interface.preferred";
/**
* network IP gets priority, default inner outer
*/
public static final String DOLPHIN_SCHEDULER_NETWORK_PRIORITY_STRATEGY = "dolphin.scheduler.network.priority.strategy";
/**
* exec shell scripts
*/
public static final String SH = "sh";
/**
* pstree, get pud and sub pid
*/
public static final String PSTREE = "pstree"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java | public static final Boolean KUBERNETES_MODE = !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_HOST")) && !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_PORT"));
/**
* dry run flag
*/
public static final int DRY_RUN_FLAG_NO = 0;
public static final int DRY_RUN_FLAG_YES = 1;
/**
* data.quality.error.output.path
*/
public static final String DATA_QUALITY_ERROR_OUTPUT_PATH = "data-quality.error.output.path";
public static final String CACHE_KEY_VALUE_ALL = "'all'";
/**
* use for k8s
*/
public static final String NAMESPACE = "namespace";
public static final String K8S = "k8s";
public static final String LIMITS_CPU = "limitsCpu";
public static final String LIMITS_MEMORY = "limitsMemory";
public static final String K8S_LOCAL_TEST_CLUSTER = "ds_null_k8s";
/**
* schedule timezone
*/
public static final String SCHEDULE_TIMEZONE = "schedule_timezone";
public static final int RESOURCE_FULL_NAME_MAX_LENGTH = 128;
/**
* tenant
*/
public static final int TENANT_FULL_NAME_MAX_LENGTH = 30;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | * (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.common.utils;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.AmazonS3Exception;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectInputStream;
import com.amazonaws.services.s3.transfer.MultipleFileDownload;
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ResUploadType; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.apache.dolphinscheduler.common.Constants.AWS_END_POINT;
import static org.apache.dolphinscheduler.common.Constants.BUCKET_NAME;
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
import static org.apache.dolphinscheduler.common.Constants.RESOURCE_STORAGE_TYPE;
import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_FILE;
import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_UDF;
import static org.apache.dolphinscheduler.common.Constants.STORAGE_S3;
public class S3Utils implements Closeable, StorageOperate {
private static final Logger logger = LoggerFactory.getLogger(S3Utils.class);
public static final String ACCESS_KEY_ID = PropertyUtils.getString(Constants.AWS_ACCESS_KEY_ID);
public static final String SECRET_KEY_ID = PropertyUtils.getString(Constants.AWS_SECRET_ACCESS_KEY);
public static final String REGION = PropertyUtils.getString(Constants.AWS_REGION); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | private AmazonS3 s3Client = null;
private S3Utils() {
if (PropertyUtils.getString(RESOURCE_STORAGE_TYPE).equals(STORAGE_S3)) {
if (!StringUtils.isEmpty(PropertyUtils.getString(AWS_END_POINT))) {
s3Client = AmazonS3ClientBuilder
.standard()
.withPathStyleAccessEnabled(true)
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(PropertyUtils.getString(AWS_END_POINT), Regions.fromName(REGION).getName()))
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_KEY_ID)))
.build();
} else {
s3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_KEY_ID)))
.withRegion(Regions.fromName(REGION))
.build();
}
checkBucketNameIfNotPresent(BUCKET_NAME);
}
}
/**
* S3Utils single
*/
private enum S3Singleton {
INSTANCE;
private final S3Utils instance;
S3Singleton() {
instance = new S3Utils();
}
private S3Utils getInstance() { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | return instance;
}
}
public static S3Utils getInstance() {
return S3Singleton.INSTANCE.getInstance();
}
@Override
public void close() throws IOException {
s3Client.shutdown();
}
@Override
public void createTenantDirIfNotExists(String tenantCode) throws Exception {
createFolder(tenantCode+ FOLDER_SEPARATOR +RESOURCE_TYPE_UDF);
createFolder(tenantCode+ FOLDER_SEPARATOR +RESOURCE_TYPE_FILE);
}
@Override
public String getResDir(String tenantCode) {
return tenantCode+ FOLDER_SEPARATOR +RESOURCE_TYPE_FILE+FOLDER_SEPARATOR;
}
@Override
public String getUdfDir(String tenantCode) {
return tenantCode+ FOLDER_SEPARATOR +RESOURCE_TYPE_UDF+FOLDER_SEPARATOR;
}
@Override
public boolean mkdir(String tenantCode, String path) throws IOException {
createFolder(path);
return true;
}
@Override
public String getResourceFileName(String tenantCode, String fileName) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | if (fileName.startsWith(FOLDER_SEPARATOR)) {
fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
}
return String.format(FORMAT_S_S, tenantCode+FOLDER_SEPARATOR+RESOURCE_TYPE_FILE, fileName);
}
@Override
public String getFileName(ResourceType resourceType, String tenantCode, String fileName) {
if (fileName.startsWith(FOLDER_SEPARATOR)) {
fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
}
return getDir(resourceType, tenantCode)+fileName;
}
@Override
public void download(String tenantCode, String srcFilePath, String dstFile, boolean deleteSource, boolean overwrite) throws IOException {
S3Object o = s3Client.getObject(BUCKET_NAME, srcFilePath);
try (S3ObjectInputStream s3is = o.getObjectContent();
FileOutputStream fos = new FileOutputStream(new File(dstFile))) {
byte[] readBuf = new byte[1024];
int readLen = 0;
while ((readLen = s3is.read(readBuf)) > 0) {
fos.write(readBuf, 0, readLen);
}
} catch (AmazonServiceException e) {
logger.error("the resource can`t be downloaded,the bucket is {},and the src is {}", tenantCode, srcFilePath);
throw new IOException(e.getMessage());
} catch (FileNotFoundException e) {
logger.error("the file isn`t exists");
throw new IOException("the file isn`t exists");
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | @Override
public boolean exists(String tenantCode, String fileName) throws IOException {
return s3Client.doesObjectExist(BUCKET_NAME, fileName);
}
@Override
public boolean delete(String tenantCode, String filePath, boolean recursive) throws IOException {
try {
s3Client.deleteObject(BUCKET_NAME, filePath);
return true;
} catch (AmazonServiceException e) {
logger.error("delete the object error,the resource path is {}", filePath);
return false;
}
}
@Override
public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws IOException {
s3Client.copyObject(BUCKET_NAME, srcPath, BUCKET_NAME, dstPath);
s3Client.deleteObject(BUCKET_NAME, srcPath);
return true;
}
@Override
public String getDir(ResourceType resourceType, String tenantCode) {
switch (resourceType) {
case UDF:
return getUdfDir(tenantCode);
case FILE:
return getResDir(tenantCode);
default:
return tenantCode+ FOLDER_SEPARATOR ;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | }
@Override
public boolean upload(String tenantCode, String srcFile, String dstPath, boolean deleteSource, boolean overwrite) throws IOException {
try {
s3Client.putObject(BUCKET_NAME, dstPath, new File(srcFile));
return true;
} catch (AmazonServiceException e) {
logger.error("upload failed,the bucketName is {},the dstPath is {}", BUCKET_NAME, tenantCode+ FOLDER_SEPARATOR +dstPath);
return false;
}
}
@Override
public List<String> vimFile(String tenantCode,String filePath, int skipLineNums, int limit) throws IOException {
if (StringUtils.isBlank(filePath)) {
logger.error("file path:{} is blank", filePath);
return Collections.emptyList();
}
S3Object s3Object=s3Client.getObject(BUCKET_NAME,filePath);
try(BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(s3Object.getObjectContent()))){
Stream<String> stream = bufferedReader.lines().skip(skipLineNums).limit(limit);
return stream.collect(Collectors.toList());
}
}
private void
createFolder( String folderName) {
if (!s3Client.doesObjectExist(BUCKET_NAME, folderName + FOLDER_SEPARATOR)) {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(0);
InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKET_NAME, folderName + FOLDER_SEPARATOR, emptyContent, metadata); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | s3Client.putObject(putObjectRequest);
}
}
@Override
public void deleteTenant(String tenantCode) throws Exception {
deleteTenantCode(tenantCode);
}
private void deleteTenantCode(String tenantCode) {
deleteDirectory(getResDir(tenantCode));
deleteDirectory(getUdfDir(tenantCode));
}
/**
* xxx untest
* upload local directory to S3
* @param tenantCode
* @param keyPrefix the name of directory
* @param strPath
*/
private void uploadDirectory(String tenantCode, String keyPrefix, String strPath) {
s3Client.putObject(BUCKET_NAME, tenantCode+ FOLDER_SEPARATOR +keyPrefix, new File(strPath));
}
/**
* xxx untest
* download S3 Directory to local
* @param tenantCode
* @param keyPrefix the name of directory
* @param srcPath
*/
private void downloadDirectory(String tenantCode, String keyPrefix, String srcPath){
TransferManager tm= TransferManagerBuilder.standard().withS3Client(s3Client).build(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,305 | [Bug] [Task] Constant definitions are repeated | ### 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
The constants of the following configuration items have repeated definitions
```
aws.access.key.id
aws.secret.access.key
aws.region
```
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### What you expected to happen
Is it necessary to duplicate definitions? Is it possible to use one set?
### How to reproduce
Respectively in
org.apache.dolphinscheduler.plugin.task.api.TaskConstants
org.apache.dolphinscheduler.common.Constants
### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10305 | https://github.com/apache/dolphinscheduler/pull/10311 | e57c2d1663c359041d926716cb0bcb398242b274 | 70dbcb21555e6b49fbf64359f77982c47b4f6902 | 2022-05-30T16:22:36Z | java | 2022-06-02T05:56:36Z | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/S3Utils.java | try{
MultipleFileDownload download = tm.downloadDirectory(BUCKET_NAME, tenantCode + FOLDER_SEPARATOR + keyPrefix, new File(srcPath));
download.waitForCompletion();
} catch (AmazonS3Exception | InterruptedException e) {
logger.error("download the directory failed with the bucketName is {} and the keyPrefix is {}", BUCKET_NAME, tenantCode + FOLDER_SEPARATOR + keyPrefix);
Thread.currentThread().interrupt();
} finally {
tm.shutdownNow();
}
}
public void checkBucketNameIfNotPresent(String bucketName) {
if (!s3Client.doesBucketExistV2(bucketName)) {
logger.info("the current regionName is {}", s3Client.getRegionName());
s3Client.createBucket(bucketName);
}
}
/*
only delete the object of directory ,it`s better to delete the files in it -r
*/
private void deleteDirectory(String directoryName) {
if (s3Client.doesObjectExist(BUCKET_NAME, directoryName)) {
s3Client.deleteObject(BUCKET_NAME, directoryName);
}
}
@Override
public ResUploadType returnStorageType() {
return ResUploadType.S3;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.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.constants;
import org.apache.dolphinscheduler.api.enums.ExecuteType;
import java.util.HashMap;
import java.util.Map;
public class ApiFuncIdentificationConstant {
public static final String ACCESS_TOKEN_MANAGE = "security:token:view";
public static final String ACCESS_TOKEN_VIEW = "security:token:view";
public static final String ACCESS_TOKEN_CREATE = "security:token:create"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java | public static final String ACCESS_TOKEN_UPDATE = "security:token:update";
public static final String ACCESS_TOKEN_DELETE = "security:token:delete";
public static final String ALERT_GROUP_VIEW = "security:alert-group:view";
public static final String ALERT_GROUP_CREATE = "security:alert-group:create";
public static final String ALERT_GROUP_UPDATE = "security:alert-group:update";
public static final String ALERT_GROUP_DELETE = "security:alert-group:delete";
public static final String TENANT_MANAGER = "security:tenant:view";
public static final String TENANT_CREATE = "security:tenant:create";
public static final String TENANT_UPDATE = "security:tenant:update";
public static final String TENANT_DELETE = "security:tenant:delete";
public static final String ALART_LIST = "monitor:alert:view";
public static final String ALART_INSTANCE_CREATE = "security:alert-plugin:create";
public static final String ALERT_PLUGIN_UPDATE = "security:alert-plugin:update";
public static final String ALERT_PLUGIN_DELETE = "security:alert-plugin:delete";
public static final String WORKER_GROUP_CREATE = "security:worker-group:create";
public static final String WORKER_GROUP_EDIT = "security:worker-group:update";
public static final String WORKER_GROUP_DELETE = "security:worker-group:delete";
public static final String YARN_QUEUE_MANAGE = "security:queue:view";
public static final String YARN_QUEUE_CREATE = "security:queue:create";
public static final String YARN_QUEUE_UPDATE = "security:queue:update";
public static final String ENVIRONMENT_CREATE = "security:environment:create";
public static final String ENVIRONMENT_UPDATE = "security:environment:update";
public static final String ENVIRONMENT_DELETE = "security:environment:delete";
public static final String ENVIRONMENT_MANAGER = "security:environment:view";
public static final String CALENDAR_CREATE = "security:calendar:create";
public static final String CALENDAR_EDIT = "security:calendar:update";
public static final String CALENDAR_DELETE = "security:calendar:delete";
public static final String CARDS_CREATE = "security:cards:create";
public static final String CARDS_EDIT = "security:cards:update";
public static final String CARDS_EDIT_VALUE = "security:cards:value"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java | public static final String CARDS_CARDS_DELETE = "security:cards:delete";
public static final String ALARM_GROUP_MANAGE = "security:alert-group:view";
public static final String ALARM_INSTANCE_MANAGE = "security:alert-plugin:view";
public static final String WORKER_GROUP_MANAGE = "security:worker-group:view";
public static final String CALENDAR_MANAGE = "security:calendar:view";
public static final String CARDS_MANAGER = "security:cards:view";
public static final String USER_MANAGER = "security:user:view";
public static final String PROJECT = "project:view";
public static final String PROJECT_CREATE = "project:create";
public static final String PROJECT_UPDATE = "project:edit";
public static final String PROJECT_DELETE = "project:delete";
public static final String WORKFLOW_DEFINITION = "project:definition:list";
public static final String WORKFLOW_CREATE = "project:definition:create";
public static final String WORKFLOW_IMPORT = "project:definition:import";
public static final String WORKFLOW_UPDATE = "project:definition:update";
public static final String WORKFLOW_START = "project:executors:start";
public static final String TIMING = "project:schedules:timing";
public static final String WORKFLOW_ONLINE_OFFLINE = "project:definition:release";
public static final String WORKFLOW_COPY = "project:definition:copy";
public static final String CRON_MANAGE = "project:schedules:corn";
public static final String WORKFLOW_DELETE = "project:definition:delete";
public static final String WORKFLOW_TREE_VIEW = "project:definition:view-tree";
public static final String WORKFLOW_EXPORT = "project:definition:export";
public static final String WORKFLOW_BATCH_COPY = "project:definition:batch-copy";
public static final String WORKFLOW_DEFINITION_EXPORT = "project:definition:batch-export";
public static final String WORKFLOW_DEFINITION_BATCH_DELETE = "project:definition:batch-delete";
public static final String WORKFLOW_SWITCH_TO_THIS_VERSION = "project:definition:version:switch";
public static final String WORKFLOW_DEFINITION_DELETE = "project:definition:version:delete";
public static final String WORKFLOW_SAVE = "project:definition:verify-name";
public static final String WORKFLOW_INSTANCE = "project:process-instance:list"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java | public static final String RERUN = "project:executors:execute";
public static final String FAILED_TO_RETRY = "project:executors:retry";
public static final String STOP = "project:executors:stop";
public static final String RECOVERY_SUSPEND = "project:executors:recover";
public static final String PAUSE = "project:executors:pause";
public static final String INSTANCE_DELETE = "project:process-instance:delete";
public static final String INSTANCE_BATCH_DELETE = "project:process-instance:batch-delete";
public static final String FORCED_SUCCESS = "project:task-instance:force-success";
public static final String VIEW_LOG = "project:log:detail";
public static final String DOWNLOAD_LOG = "project:log:download-log";
public static final String PROJECT_OVERVIEW = "project:overview:view";
public static final String WORKFLOW_RELATION = "project:lineages:view";
public static final String WORKFLOW_DEFINITION_VIEW = "project:definition:view";
public static final String WORKFLOW_INSTANCE_VIEW = "project:process-instance:view";
public static final String TASK_INSTANCE = "project:task-instance:view";
public static final String INSTANCE_UPDATE = "project:process-instance:update";
public static final String VERSION_LIST = "project:version:list";
public static final String TASK_DEFINITION = "project:task-definition:view";
public static final String TASK_DEFINITION_CREATE = "project:task-definition:create";
public static final String TASK_DEFINITION_UPDATE = "project:task-definition:edit";
public static final String TASK_DEFINITION_MOVE = "project:task-definition:move";
public static final String TASK_VERSION_VIEW = "project:task-definition:version";
public static final String TASK_DEFINITION_DELETE = "project:task-definition:delete";
public static final String VERSION_DELETE = "project:version:delete";
public static final String DATASOURCE = "datasource:view";
public static final String DATASOURCE_CREATE_DATASOURCE = "datasource:create";
public static final String DATASOURCE_UPDATE = "datasource:update";
public static final String DATASOURCE_DELETE = "datasource:delete";
public static final String DATASOURCE_LIST = "datasource:list";
public static final String DATASOURCE_PARAM_VIEW = "datasource:param-view"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java | public static final String FILE_VIEW = "resources:file:view";
public static final String FOLDER_ONLINE_CREATE = "resources:folder:online-create";
public static final String FILE_ONLINE_CREATE = "resources:file:online-create";
public static final String FILE_UPLOAD = "resources:file:upload";
public static final String FILE_UPDATE = "resources:file:update-content";
public static final String FILE_RENAME = "resources:file:rename";
public static final String FILE_DOWNLOAD = "resources:file:download";
public static final String FILE_DELETE = "resources:file:delete";
public static final String UDF_FILE_VIEW = "resources:udf:view";
public static final String UDF_FOLDER_ONLINE_CREATE = "resources:udf-folder:online-create";
public static final String UDF_UPLOAD = "resources:udf:upload";
public static final String UDF_UPDATE = "resources:udf:edit";
public static final String UDF_DOWNLOAD = "resources:udf:download";
public static final String UDF_DELETE = "resources:udf:delete";
public static final String UDF_FUNCTION_VIEW = "resources:udf-func:view";
public static final String UDF_FUNCTION_CREATE = "resources:udf-func:create";
public static final String UDF_FUNCTION_UPDATE = "resources:udf-func:update";
public static final String UDF_FUNCTION_DELETE = "resources:udf-func:delete";
public static final String TASK_GROUP_VIEW = "resources:task-group:view";
public static final String TASK_GROUP_CREATE = "resources:task-group:create";
public static final String TASK_GROUP_CLOSE = "resources:task-group:close";
public static final String TASK_GROUP_EDIT = "resources:task-group:update";
public static final String TASK_GROUP_VIEW_QUEUE = "resources:task-group:queue-view";
public static final String TASK_GROUP_QUEUE = "resources:task-group-queue:view";
public static final String TASK_GROUP_QUEUE_PRIORITY = "resources:task-group-queue:priority";
public static final String TASK_GROUP_QUEUE_START = "resources:task-group-queue:start";
public static final String MONITOR_MASTER_VIEW = "monitor:masters:view";
public static final String MONITOR_WORKER_VIEW = "monitor:workers:view";
public static final String MONITOR_DATABASES_VIEW = "monitor:databases:view";
public static final String MONITOR_STATISTICS_VIEW = "monitor:statistics:view"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/constants/ApiFuncIdentificationConstant.java | public static final String MONITOR_EVENT_LIST_VIEW = "monitor:event:view";
public static final String MONITOR_ALERT_LIST_VIEW = "monitor:alert:view";
public final static Map<ExecuteType,String> map = new HashMap<ExecuteType,String>();
static{
for(ExecuteType type : ExecuteType.values()){
switch (type){
case REPEAT_RUNNING:
map.put(type,RERUN);
break;
case RECOVER_SUSPENDED_PROCESS:
map.put(type,RECOVERY_SUSPEND);
break;
case START_FAILURE_TASK_PROCESS:
map.put(type,FAILED_TO_RETRY);
break;
case STOP:
map.put(type,STOP);
break;
case PAUSE:
map.put(type,PAUSE);
break;
case NONE:
map.put(type,null);
break;
default:
}
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | 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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.SerializationFeature; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import com.google.common.base.Joiner;
import com.google.common.io.Files;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
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.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ProgramType;
import org.apache.dolphinscheduler.common.enums.ResUploadType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.common.utils.FileUtils;
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.dolphinscheduler.service.permission.ResourcePermissionCheckService;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
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 java.io.IOException;
import java.rmi.ServerException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.common.Constants.ALIAS;
import static org.apache.dolphinscheduler.common.Constants.CONTENT;
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
import static org.apache.dolphinscheduler.common.Constants.JAR;
/**
* resources service impl
*/
@Service
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;
@Autowired(required = false)
private StorageOperate storageOperate;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * 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,
ResourceType type,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (FileUtils.directoryTraversal(name)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
String fullName = getFullName(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);
permissionPostHandle(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (DuplicateKeyException e) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | } 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;
}
private String getFullName(String currentDir, String name) {
return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name) : String.format(FORMAT_S_S, currentDir, name);
}
/**
* 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,
MultipartFile file, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | int pid,
String currentDir) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
result = verifyPid(loginUser, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String tenantCode = getTenantCode(loginUser.getId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String fullName = getFullName(currentDir, name);
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.RESOURCE_EXIST);
return result;
}
if (fullName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) {
logger.error("resource {}'s full name {}' is longer than the max length {}", RegexUtils.escapeNRT(name), fullName, Constants.RESOURCE_FULL_NAME_MAX_LENGTH);
putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR);
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);
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
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.STORE_OPERATE_CREATE_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
}
/**
* update the folder's size of the resource
*
* @param resource the current resource
* @param size size
*/
private void updateParentResourceSize(Resource resource, long size) {
if (resource.getSize() > 0) {
String[] splits = resource.getFullName().split("/");
for (int i = 1; i < splits.length; i++) {
String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i));
if (StringUtils.isNotBlank(parentFullName)) {
List<Resource> resources = resourcesMapper.queryResource(parentFullName, resource.getType().ordinal());
if (CollectionUtils.isNotEmpty(resources)) {
Resource parentResource = resources.get(0);
if (parentResource.getSize() + size >= 0) {
parentResource.setSize(parentResource.getSize() + size);
} else {
parentResource.setSize(0L);
}
resourcesMapper.updateById(parentResource);
}
}
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* 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 Boolean.TRUE.equals(existResource);
}
/**
* update resource
*
* @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) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
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 (!PropertyUtils.getResUploadStartupState()){
putMsg(result, Status.STORAGE_NOT_STARTUP);
return result;
}
if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3) && !resource.getFileName().equals(name)) {
putMsg(result, Status.S3_CANNOT_RENAME);
return result;
}
if (!canOperator(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
String originFullName = resource.getFullName();
String originResourceName = resource.getAlias();
String fullName = String.format(FORMAT_SS, originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 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 originFileName = storageOperate.getFileName(resource.getType(), tenantCode, originFullName);
try {
if (!storageOperate.exists(tenantCode, originFileName)) {
logger.error("{} not exist", originFileName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
} catch (IOException e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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 | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Date now = new Date();
long originFileSize = resource.getSize();
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 | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | 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<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).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);
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
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 {
storageOperate.delete(tenantCode, originFileName, false);
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new ServiceException(String.format("delete resource: %s failed.", originFullName));
}
}
updateParentResourceSize(resource, resource.getSize() - originFileSize);
return result;
}
String destHdfsFileName = storageOperate.getFileName(resource.getType(), tenantCode, fullName);
try {
logger.info("start copy {} -> {}", originFileName, destHdfsFileName);
storageOperate.copy(originFileName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFileName, destHdfsFileName), e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | 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 (FileUtils.directoryTraversal(name)) {
logger.error("file alias name {} verify failed", name);
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) {
logger.error("file original name {} verify failed", file.getOriginalFilename());
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
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 (!fileSuffix.equalsIgnoreCase(nameSuffix)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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;
}
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
Page<Resource> page = new Page<>(pageNo, pageSize);
if (directoryId != -1) {
Resource directory = resourcesMapper.selectById(directoryId);
if (directory == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
Set<Integer> resourcesIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourcesIds.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, directoryId, type.ordinal(), loginUser.getId(), searchVal, new ArrayList<>(resourcesIds));
pageInfo.setTotal((int) resourceIPage.getTotal());
pageInfo.setTotalList(resourceIPage.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* create directory
* xxx The steps to verify resources are cumbersome and can be optimized
*
* @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 = storageOperate.getFileName(type, tenantCode, fullName);
String resourceRootPath = storageOperate.getDir(type, tenantCode);
try {
if (!storageOperate.exists(tenantCode, resourceRootPath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
if (!storageOperate.mkdir(tenantCode, directoryName)) {
logger.error("create resource directory {} failed", directoryName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName));
}
} catch (Exception e) {
logger.error("create resource directory {} failed", directoryName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName));
}
}
/**
* upload file to hdfs |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | *
* @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 (!fileSuffix.equalsIgnoreCase(nameSuffix)) {
return false;
}
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
String fileName = storageOperate.getFileName(type, tenantCode, fullName);
String resourcePath = storageOperate.getDir(type, tenantCode);
try {
if (!storageOperate.exists(tenantCode, resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename);
storageOperate.upload(tenantCode, localFilename, fileName, true, true);
} catch (Exception e) {
FileUtils.deleteFile(localFilename);
logger.error(e.getMessage(), e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
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;
}
/**
* query resource list by program type
*
* @param loginUser login user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param type resource type
* @return resource list
*/
@Override
public Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourceIds.isEmpty()){
result.setData(Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
List<Resource> allResourceList = resourcesMapper.selectBatchIds(resourceIds);
String suffix = ".jar";
if (programType != null) {
switch (programType) {
case JAVA:
case SCALA:
break;
case PYTHON:
suffix = ".py";
break;
default:
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter();
Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources);
result.setData(resourceTreeVisitor.visit().getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* 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> resultCheck = new Result<>();
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(resultCheck, Status.RESOURCE_NOT_EXIST);
return resultCheck;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION);
return resultCheck; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (!canOperator(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String tenantCode = getTenantCode(resource.getUserId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
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())) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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;
}
String storageFilename = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName());
resourcesMapper.selectBatchIds(Arrays.asList(needDeleteResourceIdArray)).forEach(item -> {
updateParentResourceSize(item, item.getSize() * -1);
});
resourcesMapper.deleteIds(needDeleteResourceIdArray);
resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray);
storageOperate.delete(tenantCode, storageFilename, true);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* verify resource by name and type
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @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<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return 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 filename = storageOperate.getFileName(type, tenantCode, fullName);
if (storageOperate.exists(tenantCode, filename)) {
putMsg(result, Status.RESOURCE_FILE_EXIST, filename);
}
} catch (Exception e) {
logger.error("verify resource failed and the reason is {}", e.getMessage()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.STORE_OPERATE_CREATE_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(User loginUser, 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;
}
Resource resource;
if (StringUtils.isNotBlank(fullName)) {
List<Resource> resourceList = resourcesMapper.queryResource(fullName, type.ordinal());
if (CollectionUtils.isEmpty(resourceList)) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | resource = resourceList.get(0);
} else {
resource = resourcesMapper.selectById(id);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
resource = resourcesMapper.selectById(resource.getPid());
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(resource);
return result;
}
/**
* get resource by id
* @param id resource id
* @return resource
*/
@Override
public Result<Object> queryResourceById(User loginUser, Integer id) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Result<Object> result = new Result<>();
Resource resource = resourcesMapper.selectById(id);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(resource);
return result;
}
/**
* view resource file online
*
* @param resourceId resource id
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
@Override
public Result<Object> readResource(User loginUser, int resourceId, int skipLineNum, int limit) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.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 resourceFileName = storageOperate.getResourceFileName(tenantCode, resource.getFullName());
logger.info("resource path is {}", resourceFileName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | try {
if (storageOperate.exists(tenantCode, resourceFileName)) {
List<String> content = storageOperate.vimFile(tenantCode, resourceFileName, 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 storage", resourceFileName);
putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, resourceFileName);
}
} catch (Exception e) {
logger.error("Resource {} read failed", resourceFileName, 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 | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | 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 = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (FileUtils.directoryTraversal(fileName)) {
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
String nameSuffix = fileSuffix.trim();
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String fullName = getFullName(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);
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(checkResourceType(resource.getType()), loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).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 = uploadContentToStorage(loginUser, 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); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (!PropertyUtils.getResUploadStartupState()) {
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.STORAGE_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;
}
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 (!canOperator(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* updateProcessInstance resource
*
* @param resourceId resource id
* @param content content
* @return update result cod
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> updateResourceContent(User loginUser, int resourceId, String content) {
Result<Object> result = checkResourceUploadStartupState();
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 funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | List<String> strList = Arrays.asList(resourceViewSuffixes.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;
}
long originFileSize = resource.getSize();
resource.setSize(content.getBytes().length);
resource.setUpdateTime(new Date());
resourcesMapper.updateById(resource);
result = uploadContentToStorage(loginUser, resource.getFullName(), tenantCode, content);
updateParentResourceSize(resource, resource.getSize() - originFileSize);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
/**
* @param resourceName resource name
* @param tenantCode tenant code
* @param content content
* @return result
*/
private Result<Object> uploadContentToStorage(User loginUser,String resourceName, String tenantCode, String content) {
Result<Object> result = new Result<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String localFilename = "";
String storageFileName = "";
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;
}
storageFileName = storageOperate.getResourceFileName(tenantCode, resourceName);
String resourcePath = storageOperate.getResDir(tenantCode);
logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath);
if (!storageOperate.exists(tenantCode, resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
if (storageOperate.exists(tenantCode, storageFileName)) {
storageOperate.delete(tenantCode, storageFileName, false);
}
storageOperate.upload(tenantCode, localFilename, storageFileName, 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, storageFileName));
return result;
}
putMsg(result, Status.SUCCESS);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
/**
* download file
*
* @param resourceId resource id
* @return resource content
* @throws IOException exception
*/
@Override
public org.springframework.core.io.Resource downloadResource(User loginUser, 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);
return null;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DOWNLOAD : ApiFuncIdentificationConstant.UDF_DOWNLOAD;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState());
throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg());
}
if (resource.isDirectory()) {
logger.error("resource id {} is directory,can't download it", resourceId);
throw new ServiceException("can't download directory");
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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 fileName = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName());
String localFileName = FileUtils.getDownloadFilename(resource.getAlias());
logger.info("resource path is {}, download local filename is {}", fileName, localFileName);
try {
storageOperate.download(tenantCode, fileName, localFileName, false, true);
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName);
} catch (IOException e) {
logger.error("download resource error, the path is {}, and local filename is {}, the error message is {}", fileName, localFileName, e.getMessage());
throw new ServerException("download the resource file failed ,it may be related to your storage");
}
}
/**
* list all file
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | 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 (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param userId user id
* @return unauthorized result code
*/
@Override
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | *
* @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 (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<UdfFunc> udfFuncList;
if (isAdmin(loginUser)) {
udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId);
} else {
udfFuncList = udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId()));
}
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); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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 (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId);
result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result, Status.SUCCESS);
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) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
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
*/
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
Set<?> authedResourceSet;
if (CollectionUtils.isNotEmpty(authedResourceList)) {
authedResourceSet = new HashSet<>(authedResourceList);
resourceSet.removeAll(authedResourceSet);
}
}
/**
* get tenantCode by UserId |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,338 | [Bug] [Permission] Tenants and users do not need to do post-creation association operations. | ### 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
Failed to create tenant, tenants and users do not need to do post-creation association operations
### What you expected to happen
Normal
### How to reproduce
Create a tenant.
### Anything else
No Response
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10338 | https://github.com/apache/dolphinscheduler/pull/10339 | 0c25d4a3ceae0fec1cc800bcc171a0b77aae8ee4 | ffe809b2c5600593053210c42462d68fad9d6aca | 2022-06-02T06:15:10Z | java | 2022-06-05T14:34:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | *
* @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();
}
/**
* 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) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.