提交 b3418c8f 编写于 作者: L lgcareer 提交者: qiaozhanwei

update method listUnauthorizedResource in order to fix issues 1770 (#1797)

上级 ba859c9d
......@@ -27,7 +27,10 @@ import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.queue.ITaskQueue;
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.IpUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.*;
import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
......@@ -41,7 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.apache.dolphinscheduler.common.Constants.*;
/**
......@@ -1774,12 +1777,14 @@ public class ProcessDao {
public List<String> listUnauthorizedResource(int userId,String[] resNames){
List<String> resultList = new ArrayList<String>();
if(ArrayUtils.isNotEmpty(resNames)){
List<String> originResList = Arrays.asList(resNames);
if (ArrayUtils.isNotEmpty(resNames)) {
Set<String> originResSet = new HashSet<String>(Arrays.asList(resNames));
List<Resource> authorizedResourceList = resourceMapper.listAuthorizedResource(userId, resNames);
List<String> authorizedResNames = authorizedResourceList.stream().map(t -> t.getAlias()).collect(toList());
resultList = originResList.stream().filter(item -> !authorizedResNames.contains(item)).collect(toList());
Set<String> authorizedResNames = authorizedResourceList.stream().map(t -> t.getAlias()).collect(toSet());
originResSet.removeAll(authorizedResNames);
resultList.addAll(originResSet);
}
return resultList;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册