Skip to content

Commit

Permalink
[INLONG-7837][Manager] Fix the Admin user cannot modify streamSource …
Browse files Browse the repository at this point in the history
…when it is not the responsible person (#7838)
  • Loading branch information
fuweng11 committed Apr 13, 2023
1 parent adb752b commit 1a82f43
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -19,10 +19,13 @@

import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
import org.apache.inlong.manager.common.enums.GroupStatus;
import org.apache.inlong.manager.common.enums.UserTypeEnum;
import org.apache.inlong.manager.common.exceptions.BusinessException;
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.inlong.manager.dao.entity.InlongGroupEntity;
import org.apache.inlong.manager.dao.entity.UserEntity;
import org.apache.inlong.manager.dao.mapper.InlongGroupEntityMapper;
import org.apache.inlong.manager.dao.mapper.UserEntityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand All @@ -37,6 +40,8 @@ public class GroupCheckService {

@Autowired
private InlongGroupEntityMapper groupMapper;
@Autowired
private UserEntityMapper userMapper;

/**
* Check whether the inlong group status is temporary
Expand All @@ -50,8 +55,10 @@ public InlongGroupEntity checkGroupStatus(String groupId, String operator) {
throw new BusinessException(String.format("InlongGroup does not exist with InlongGroupId=%s", groupId));
}

UserEntity userEntity = userMapper.selectByName(operator);
List<String> managers = Arrays.asList(inlongGroupEntity.getInCharges().split(","));
Preconditions.expectTrue(managers.contains(operator),
Preconditions.expectTrue(
managers.contains(operator) || UserTypeEnum.ADMIN.getCode().equals(userEntity.getAccountType()),
String.format(ErrorCodeEnum.USER_IS_NOT_MANAGER.getMessage(), operator, managers));

GroupStatus status = GroupStatus.forCode(inlongGroupEntity.getStatus());
Expand Down

0 comments on commit 1a82f43

Please sign in to comment.