Skip to content

Commit c9e373e

Browse files
authored
[Fix-18304][API] Remove dead code after t_ds_relation_user_alertgroup table dropped (#18316)
1 parent 9a86abe commit c9e373e

15 files changed

Lines changed: 0 additions & 206 deletions

File tree

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.dolphinscheduler.api.controller;
1919

20-
import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_USER_ERROR;
2120
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_USER_ERROR;
2221
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_USER_BY_ID_ERROR;
2322
import static org.apache.dolphinscheduler.api.enums.Status.GET_USER_INFO_ERROR;
@@ -26,7 +25,6 @@
2625
import static org.apache.dolphinscheduler.api.enums.Status.GRANT_PROJECT_ERROR;
2726
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_USER_LIST_PAGING_ERROR;
2827
import static org.apache.dolphinscheduler.api.enums.Status.REVOKE_PROJECT_ERROR;
29-
import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_USER_ERROR;
3028
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_USER_ERROR;
3129
import static org.apache.dolphinscheduler.api.enums.Status.USER_LIST_ERROR;
3230
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_USERNAME_ERROR;
@@ -314,30 +312,6 @@ public Result verifyUserName(@Parameter(hidden = true) @RequestAttribute(value =
314312
return usersService.verifyUserName(userName);
315313
}
316314

317-
@Operation(summary = "unauthorizedUser", description = "UNAUTHORIZED_USER_NOTES")
318-
@Parameters({
319-
@Parameter(name = "alertgroupId", description = "ALERT_GROUP_ID", required = true, schema = @Schema(implementation = String.class))
320-
})
321-
@GetMapping(value = "/unauth-user")
322-
@ResponseStatus(HttpStatus.OK)
323-
@ApiException(UNAUTHORIZED_USER_ERROR)
324-
public Result<List<User>> unauthorizedUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
325-
@RequestParam("alertgroupId") Integer alertgroupId) {
326-
return Result.success(usersService.unauthorizedUser(loginUser, alertgroupId));
327-
}
328-
329-
@Operation(summary = "authorizedUser", description = "AUTHORIZED_USER_NOTES")
330-
@Parameters({
331-
@Parameter(name = "alertgroupId", description = "ALERT_GROUP_ID", required = true, schema = @Schema(implementation = String.class))
332-
})
333-
@GetMapping(value = "/authed-user")
334-
@ResponseStatus(HttpStatus.OK)
335-
@ApiException(AUTHORIZED_USER_ERROR)
336-
public Result<List<User>> authorizedUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
337-
@RequestParam("alertgroupId") Integer alertgroupId) {
338-
return Result.success(usersService.authorizedUser(loginUser, alertgroupId));
339-
}
340-
341315
@Operation(summary = "registerUser", description = "REGISTER_USER_NOTES")
342316
@Parameters({
343317
@Parameter(name = "userName", description = "USER_NAME", required = true, schema = @Schema(implementation = String.class)),

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public enum Status {
6363
LIST_PAGING_ALERT_GROUP_ERROR(10029, "list paging alert group error", "分页查询告警组错误"),
6464
UPDATE_ALERT_GROUP_ERROR(10030, "update alert group error", "更新告警组错误"),
6565
DELETE_ALERT_GROUP_ERROR(10031, "delete alert group error", "删除告警组错误"),
66-
ALERT_GROUP_GRANT_USER_ERROR(10032, "alert group grant user error", "告警组授权用户错误"),
6766
CREATE_DATASOURCE_ERROR(10033, "create datasource error", "创建数据源错误"),
6867
UPDATE_DATASOURCE_ERROR(10034, "update datasource error", "更新数据源错误"),
6968
QUERY_DATASOURCE_ERROR(10035, "query datasource error", "查询数据源错误"),
@@ -123,8 +122,6 @@ public enum Status {
123122
GET_USER_INFO_ERROR(10098, "get user info error", "获取用户信息错误"),
124123
USER_LIST_ERROR(10099, "user list error", "查询用户列表错误"),
125124
VERIFY_USERNAME_ERROR(10100, "verify username error", "用户名验证错误"),
126-
UNAUTHORIZED_USER_ERROR(10101, "unauthorized user error", "查询未授权用户错误"),
127-
AUTHORIZED_USER_ERROR(10102, "authorized user error", "查询授权用户错误"),
128125
QUERY_TASK_INSTANCE_LOG_ERROR(10103, "view task instance log error: {0}", "查询任务实例日志错误: {0}"),
129126
DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR(10104, "download task instance log file error", "下载任务日志文件错误"),
130127
CREATE_WORKFLOW_DEFINITION_ERROR(10105, "create workflow definition error", "创建工作流错误"),

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,6 @@ User updateUser(User loginUser,
154154
*/
155155
Result<Object> verifyUserName(String userName);
156156

157-
/**
158-
* users not yet authorized to the given alert group
159-
*/
160-
List<User> unauthorizedUser(User loginUser, Integer alertGroupId);
161-
162-
/**
163-
* users authorized to the given alert group
164-
*/
165-
List<User> authorizedUser(User loginUser, Integer alertGroupId);
166-
167157
/**
168158
* registry user, default state is 0, default tenant_id is 1, no phone, no queue
169159
*/

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@
5656
import java.util.Arrays;
5757
import java.util.Date;
5858
import java.util.HashMap;
59-
import java.util.HashSet;
6059
import java.util.List;
6160
import java.util.Map;
6261
import java.util.Objects;
63-
import java.util.Set;
6462
import java.util.stream.Collectors;
6563

6664
import lombok.extern.slf4j.Slf4j;
@@ -830,55 +828,6 @@ public Result<Object> verifyUserName(String userName) {
830828
return result;
831829
}
832830

833-
/**
834-
* unauthorized user
835-
*
836-
* @param loginUser login user
837-
* @param alertgroupId alert group id
838-
* @return unauthorize result code
839-
*/
840-
@Override
841-
public List<User> unauthorizedUser(User loginUser, Integer alertgroupId) {
842-
// only admin can operate
843-
if (!isAdmin(loginUser)) {
844-
log.warn("Only admin can deauthorize user.");
845-
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
846-
}
847-
848-
List<User> userList = userDao.queryAll();
849-
List<User> resultUsers = new ArrayList<>();
850-
Set<User> userSet;
851-
if (userList != null && !userList.isEmpty()) {
852-
userSet = new HashSet<>(userList);
853-
854-
List<User> authedUserList = userDao.queryUserListByAlertGroupId(alertgroupId);
855-
856-
if (authedUserList != null && !authedUserList.isEmpty()) {
857-
Set<User> authedUserSet = new HashSet<>(authedUserList);
858-
userSet.removeAll(authedUserSet);
859-
}
860-
resultUsers = new ArrayList<>(userSet);
861-
}
862-
return resultUsers;
863-
}
864-
865-
/**
866-
* authorized user
867-
*
868-
* @param loginUser login user
869-
* @param alertGroupId alert group id
870-
* @return authorized result code
871-
*/
872-
@Override
873-
public List<User> authorizedUser(User loginUser, Integer alertGroupId) {
874-
// only admin can operate
875-
if (!isAdmin(loginUser)) {
876-
log.warn("Only admin can authorize user.");
877-
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
878-
}
879-
return userDao.queryUserListByAlertGroupId(alertGroupId);
880-
}
881-
882831
/**
883832
* @param tenantId tenant id
884833
* @return true if tenant exists, otherwise return false

dolphinscheduler-api/src/main/resources/i18n/messages.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,8 @@ PROJECT_CODE=project code
189189
GET_USER_INFO_NOTES=get user info
190190
LIST_USER_NOTES=list user
191191
VERIFY_USER_NAME_NOTES=verify user name
192-
UNAUTHORIZED_USER_NOTES=cancel authorization
193192
ALERT_GROUP_ID=alert group id
194193
ALERT_INSTANCE_IDS=alert instance ids(string format, multiple instances separated by ",")
195-
AUTHORIZED_USER_NOTES=authorized user
196194
GRANT_DATASOURCE_NOTES=grant datasource
197195
DATASOURCE_IDS=datasource ids(string format, multiple datasources separated by ",")
198196
QUERY_PARENT_WORKFLOW_INSTANCE_BY_SUB_WORKFLOW_INSTANCE_ID_NOTES=query parent workflow instance info by sub workflow instance id

dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,8 @@ PROJECT_CODE=project code
220220
GET_USER_INFO_NOTES=get user info
221221
LIST_USER_NOTES=list user
222222
VERIFY_USER_NAME_NOTES=verify user name
223-
UNAUTHORIZED_USER_NOTES=cancel authorization
224223
ALERT_GROUP_ID=alert group id
225224
ALERT_INSTANCE_IDS=alert instance ids(string format, multiple instances separated by ",")
226-
AUTHORIZED_USER_NOTES=authorized user
227225
RESOURCE_CURRENTDIR=dir of the current resource
228226
RESOURCE_FULL_NAME=resource full name
229227
GRANT_DATASOURCE_NOTES=grant datasource

dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,8 @@ GET_USER_INFO_NOTES=\u83B7\u53D6\u7528\u6237\u4FE1\u606F
205205
QUERY_WORKFLOW_DEFINITION_BY_NAME_NOTES=\u901A\u8FC7\u540D\u79F0\u67E5\u8BE2\u6D41\u7A0B\u5B9A\u4E49
206206
LIST_USER_NOTES=\u7528\u6237\u5217\u8868
207207
VERIFY_USER_NAME_NOTES=\u9A8C\u8BC1\u7528\u6237\u540D
208-
UNAUTHORIZED_USER_NOTES=\u53D6\u6D88\u6388\u6743
209208
ALERT_GROUP_ID=\u544A\u8B66\u7EC4ID
210209
ALERT_INSTANCE_IDS=\u544A\u8B66\u5B9E\u4F8BID\u5217\u8868(\u5B57\u7B26\u4E32\u683C\u5F0F\uFF0C\u591A\u4E2A\u544A\u8B66\u5B9E\u4F8BID\u4EE5","\u5206\u5272)
211-
AUTHORIZED_USER_NOTES=\u6388\u6743\u7528\u6237
212210
GRANT_DATASOURCE_NOTES=\u6388\u6743\u6570\u636E\u6E90
213211
DATASOURCE_IDS=\u6570\u636E\u6E90ID\u5217\u8868(\u5B57\u7B26\u4E32\u683C\u5F0F\uFF0C\u591A\u4E2A\u6570\u636E\u6E90ID\u4EE5","\u5206\u5272)
214212
QUERY_PARENT_WORKFLOW_INSTANCE_BY_SUB_WORKFLOW_INSTANCE_ID_NOTES=\u901A\u8FC7\u5B50\u6D41\u7A0B\u5B9E\u4F8BID\u67E5\u8BE2\u7236\u6D41\u7A0B\u5B9E\u4F8B\u4FE1\u606F

dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/UsersControllerTest.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -190,44 +190,6 @@ public void testListAll() throws Exception {
190190
logger.info(mvcResult.getResponse().getContentAsString());
191191
}
192192

193-
// todo: there is a sql error, the table t_ds_relation_user_alertgroup has already been dropped
194-
@Disabled
195-
@Test
196-
public void testAuthorizedUser() throws Exception {
197-
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
198-
paramsMap.add("alertgroupId", "1");
199-
200-
MvcResult mvcResult = mockMvc.perform(get("/users/authed-user")
201-
.header(SESSION_ID, sessionId)
202-
.params(paramsMap))
203-
.andExpect(status().isOk())
204-
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
205-
.andReturn();
206-
207-
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
208-
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
209-
logger.info(mvcResult.getResponse().getContentAsString());
210-
}
211-
212-
// todo: t_ds_relation_user_alertgroup has already been dropped
213-
@Disabled
214-
@Test
215-
public void testUnauthorizedUser() throws Exception {
216-
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
217-
paramsMap.add("alertgroupId", "1");
218-
219-
MvcResult mvcResult = mockMvc.perform(get("/users/unauth-user")
220-
.header(SESSION_ID, sessionId)
221-
.params(paramsMap))
222-
.andExpect(status().isOk())
223-
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
224-
.andReturn();
225-
226-
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
227-
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
228-
logger.info(mvcResult.getResponse().getContentAsString());
229-
}
230-
231193
@Test
232194
public void testVerifyUserName() throws Exception {
233195
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();

dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -577,33 +577,6 @@ public void testVerifyUserName() {
577577
Assertions.assertEquals(Status.USER_NAME_EXIST.getMsg(), result.getMsg());
578578
}
579579

580-
@Test
581-
public void testUnauthorizedUser() {
582-
User loginUser = new User();
583-
when(userDao.queryAll()).thenReturn(getUserList());
584-
when(userDao.queryUserListByAlertGroupId(2)).thenReturn(getUserList());
585-
// no operate
586-
assertThrowsServiceException(Status.USER_NO_OPERATION_PERM,
587-
() -> usersService.unauthorizedUser(loginUser, 2));
588-
// success
589-
loginUser.setUserType(UserType.ADMIN_USER);
590-
List<User> users = usersService.unauthorizedUser(loginUser, 2);
591-
Assertions.assertNotNull(users);
592-
}
593-
594-
@Test
595-
public void testAuthorizedUser() {
596-
User loginUser = new User();
597-
when(userDao.queryUserListByAlertGroupId(2)).thenReturn(getUserList());
598-
// no operate
599-
assertThrowsServiceException(Status.USER_NO_OPERATION_PERM,
600-
() -> usersService.authorizedUser(loginUser, 2));
601-
// success
602-
loginUser.setUserType(UserType.ADMIN_USER);
603-
List<User> users = usersService.authorizedUser(loginUser, 2);
604-
Assertions.assertFalse(users.isEmpty());
605-
}
606-
607580
@Test
608581
public void testRegisterUser() {
609582
String userName = "userTest0002~";

dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UserMapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ IPage<User> queryUserPaging(Page page,
8888
*/
8989
User queryDetailsById(@Param("userId") int userId);
9090

91-
/**
92-
* query user list by alertgroupId
93-
*
94-
* @param alertgroupId alertgroupId
95-
* @return user list
96-
*/
97-
List<User> queryUserListByAlertGroupId(@Param("alertgroupId") int alertgroupId);
98-
9991
/**
10092
* query user list by tenantId
10193
*

0 commit comments

Comments
 (0)