Commit b3418c8f authored by lgcareer's avatar lgcareer Committed by qiaozhanwei
Browse files

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

parent ba859c9d
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -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.*;

/**
@@ -1775,11 +1778,13 @@ public class ProcessDao {
        List<String> resultList = new ArrayList<String>();

        if (ArrayUtils.isNotEmpty(resNames)) {
            List<String> originResList = Arrays.asList(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;