caishunfeng commented on a change in pull request #8637:
URL: https://github.com/apache/dolphinscheduler/pull/8637#discussion_r819217958



##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
##########
@@ -756,20 +749,19 @@ private boolean upload(User loginUser, String fullName, 
MultipartFile file, Reso
             Tenant tenant = tenantMapper.queryById(loginUser.getTenantId());
             if (tenant != null) {
                 String tenantCode = tenant.getTenantCode();
-
                 try {
-                    String hdfsFilename = 
HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
-                    if (HadoopUtils.getInstance().exists(hdfsFilename)) {
-                        logger.error("resource type:{} name:{} has exist in 
hdfs {}, can't create again.", type, RegexUtils.escapeNRT(fullName), 
hdfsFilename);
-                        putMsg(result, 
Status.RESOURCE_FILE_EXIST,hdfsFilename);
+                    //xxx

Review comment:
       remove it.

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java
##########
@@ -37,6 +35,7 @@
 
 /**
  * base service impl
+ * @author Terry.Dai

Review comment:
       Please remove it.

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
##########
@@ -28,54 +32,23 @@
 import org.apache.dolphinscheduler.common.Constants;
 import org.apache.dolphinscheduler.common.enums.Flag;
 import org.apache.dolphinscheduler.common.enums.UserType;
+import org.apache.dolphinscheduler.common.storage.StorageOperate;
 import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
-import org.apache.dolphinscheduler.common.utils.HadoopUtils;
 import org.apache.dolphinscheduler.common.utils.PropertyUtils;
-import org.apache.dolphinscheduler.dao.entity.AlertGroup;
-import org.apache.dolphinscheduler.dao.entity.DatasourceUser;
-import org.apache.dolphinscheduler.dao.entity.Project;
-import org.apache.dolphinscheduler.dao.entity.ProjectUser;
-import org.apache.dolphinscheduler.dao.entity.Resource;
-import org.apache.dolphinscheduler.dao.entity.ResourcesUser;
-import org.apache.dolphinscheduler.dao.entity.Tenant;
-import org.apache.dolphinscheduler.dao.entity.UDFUser;
-import org.apache.dolphinscheduler.dao.entity.User;
-import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
-import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
-import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
-import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
-import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
-import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
-import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
-import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
-import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
-import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
-import org.apache.dolphinscheduler.dao.mapper.UserMapper;
+import org.apache.dolphinscheduler.dao.entity.*;

Review comment:
       please avoid to import *

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
##########
@@ -462,34 +433,32 @@ public Result queryUserList(User loginUser, String 
searchVal, Integer pageNo, In
                         if (CollectionUtils.isNotEmpty(udfResourceList)) {
                             ResourceTreeVisitor resourceTreeVisitor = new 
ResourceTreeVisitor(udfResourceList);
                             ResourceComponent resourceComponent = 
resourceTreeVisitor.visit();
-                            copyResourceFiles(resourceComponent, oldUdfsPath, 
newUdfsPath);
+                            copyResourceFiles(oldTenant.getTenantCode(), 
newTenantCode, resourceComponent, oldUdfsPath, newUdfsPath);
                         }
 
-                        //Delete the user from the old tenant directory
-                        String oldUserPath = 
HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(), userId);
-                        HadoopUtils.getInstance().delete(oldUserPath, true);
                     } else {
                         // if old tenant dir not exists , create
-                        createTenantDirIfNotExists(oldTenant.getTenantCode());
-                    }
+                        
storageOperate.createTenantDirIfNotExists(oldTenant.getTenantCode());
 
-                    if 
(HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode())))
 {
-                        //create user in the new tenant directory
-                        String newUserPath = 
HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(), user.getId());
-                        HadoopUtils.getInstance().mkdir(newUserPath);
-                    } else {
-                        // if new tenant dir not exists , create
-                        createTenantDirIfNotExists(newTenant.getTenantCode());
+                        if (!storageOperate.exists(newTenant.getTenantCode(), 
storageOperate.getDir(null,newTenant.getTenantCode()))) {
+                            
storageOperate.createTenantDirIfNotExists(newTenant.getTenantCode());
+                        }
                     }
-
+                } catch (Exception e) {
+                    logger.error("create tenant {} failed ,the reason is {}", 
oldTenant, e.getMessage());
                 }
-            }
+
             user.setTenantId(tenantId);
+            try {
+                
storageOperate.createTenantDirIfNotExists(newTenant.getTenantCode());
+            } catch (Exception e) {
+                logger.error("create tenant {} failed ,the reason is {}", 
newTenant, e.getMessage());
+            }
+            }

Review comment:
       code format?




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to