This is an automated email from the ASF dual-hosted git repository.
journey pushed a commit to branch dev-1.2.1
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev-1.2.1 by this push:
new b3418c8 update method listUnauthorizedResource in order to fix issues
1770 (#1797)
b3418c8 is described below
commit b3418c8f48b42668bdc790ea64e0b94e4eda6214
Author: lgcareer <[email protected]>
AuthorDate: Fri Jan 10 14:31:58 2020 +0800
update method listUnauthorizedResource in order to fix issues 1770 (#1797)
---
.../org/apache/dolphinscheduler/dao/ProcessDao.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
index d80c9c5..3cf2885 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
@@ -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;