You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/05/18 05:12:43 UTC

[GitHub] [incubator-dolphinscheduler] lenboo commented on a change in pull request #2732: fix #2598::allow to update resource suffix,but if it is authorized to other users,it is not allowed

lenboo commented on a change in pull request #2732:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/2732#discussion_r426354405



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
##########
@@ -355,12 +352,21 @@ public Result updateResource(User loginUser,
         String nameWithSuffix = name;
 
         if (!resource.isDirectory()) {
-            //get the file suffix
-            String suffix = originResourceName.substring(originResourceName.lastIndexOf("."));
-
-            //if the name without suffix then add it ,else use the origin name
-            if(!name.endsWith(suffix)){
-                nameWithSuffix = nameWithSuffix + suffix;
+            //get the origin file suffix
+            String originSuffix = FileUtils.suffix(originFullName);
+            String suffix = FileUtils.suffix(fullName);
+            if (!suffix.equals(originSuffix)) {
+                //need verify whether this resource is authorized to other users
+                Map<String, Object> columnMap = new HashMap<String, Object>();
+                columnMap.put("resources_id", resourceId);
+
+                List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
+                if (CollectionUtils.isNotEmpty(resourcesUsers)) {
+                    String users = resourcesUsers.stream().map(t -> t.getUserId()).collect(Collectors.toList()).toString();
+                    logger.error("resource is authorized to user {},suffix not allowed to be modified", users);

Review comment:
       change the message the user name is better.

##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
##########
@@ -355,12 +352,21 @@ public Result updateResource(User loginUser,
         String nameWithSuffix = name;
 
         if (!resource.isDirectory()) {
-            //get the file suffix
-            String suffix = originResourceName.substring(originResourceName.lastIndexOf("."));
-
-            //if the name without suffix then add it ,else use the origin name
-            if(!name.endsWith(suffix)){
-                nameWithSuffix = nameWithSuffix + suffix;
+            //get the origin file suffix
+            String originSuffix = FileUtils.suffix(originFullName);
+            String suffix = FileUtils.suffix(fullName);
+            if (!suffix.equals(originSuffix)) {
+                //need verify whether this resource is authorized to other users
+                Map<String, Object> columnMap = new HashMap<String, Object>();
+                columnMap.put("resources_id", resourceId);
+
+                List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
+                if (CollectionUtils.isNotEmpty(resourcesUsers)) {
+                    String users = resourcesUsers.stream().map(t -> t.getUserId()).collect(Collectors.toList()).toString();
+                    logger.error("resource is authorized to user {},suffix not allowed to be modified", users);

Review comment:
       or do not print user name?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org