|
|
@ -14,10 +14,9 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.api.service; |
|
|
|
package org.apache.dolphinscheduler.api.service; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; |
|
|
|
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; |
|
|
|
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; |
|
|
|
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
@ -29,20 +28,49 @@ import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.common.utils.*; |
|
|
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.*; |
|
|
|
import org.apache.dolphinscheduler.common.utils.EncryptionUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.*; |
|
|
|
import org.apache.dolphinscheduler.common.utils.HadoopUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.StringUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.AlertGroup; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.DatasourceUser; |
|
|
|
|
|
|
|
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.AlertGroupMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
|
|
|
|
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.utils.ResourceProcessDefinitionUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.text.MessageFormat; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* user service |
|
|
|
* user service |
|
|
@ -109,7 +137,7 @@ public class UsersService extends BaseService { |
|
|
|
String msg = this.checkUserParams(userName, userPassword, email, phone); |
|
|
|
String msg = this.checkUserParams(userName, userPassword, email, phone); |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(msg)) { |
|
|
|
if (!StringUtils.isEmpty(msg)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,msg); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isAdmin(loginUser)) { |
|
|
|
if (!isAdmin(loginUser)) { |
|
|
@ -126,12 +154,12 @@ public class UsersService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
Tenant tenant = tenantMapper.queryById(tenantId); |
|
|
|
Tenant tenant = tenantMapper.queryById(tenantId); |
|
|
|
// resource upload startup
|
|
|
|
// resource upload startup
|
|
|
|
if (PropertyUtils.getResUploadStartupState()){ |
|
|
|
if (PropertyUtils.getResUploadStartupState()) { |
|
|
|
// if tenant not exists
|
|
|
|
// if tenant not exists
|
|
|
|
if (!HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(tenant.getTenantCode()))){ |
|
|
|
if (!HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(tenant.getTenantCode()))) { |
|
|
|
createTenantDirIfNotExists(tenant.getTenantCode()); |
|
|
|
createTenantDirIfNotExists(tenant.getTenantCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
String userPath = HadoopUtils.getHdfsUserDir(tenant.getTenantCode(),user.getId()); |
|
|
|
String userPath = HadoopUtils.getHdfsUserDir(tenant.getTenantCode(), user.getId()); |
|
|
|
HadoopUtils.getInstance().mkdir(userPath); |
|
|
|
HadoopUtils.getInstance().mkdir(userPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -161,7 +189,7 @@ public class UsersService extends BaseService { |
|
|
|
user.setUserType(UserType.GENERAL_USER); |
|
|
|
user.setUserType(UserType.GENERAL_USER); |
|
|
|
user.setCreateTime(now); |
|
|
|
user.setCreateTime(now); |
|
|
|
user.setUpdateTime(now); |
|
|
|
user.setUpdateTime(now); |
|
|
|
if (StringUtils.isEmpty(queue)){ |
|
|
|
if (StringUtils.isEmpty(queue)) { |
|
|
|
queue = ""; |
|
|
|
queue = ""; |
|
|
|
} |
|
|
|
} |
|
|
|
user.setQueue(queue); |
|
|
|
user.setQueue(queue); |
|
|
@ -171,8 +199,40 @@ public class UsersService extends BaseService { |
|
|
|
return user; |
|
|
|
return user; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* create User for ldap login |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
|
|
public User createUser(UserType userType, String userId, String email) { |
|
|
|
|
|
|
|
User user = new User(); |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.setUserName(userId); |
|
|
|
|
|
|
|
user.setEmail(email); |
|
|
|
|
|
|
|
// create general users, administrator users are currently built-in
|
|
|
|
|
|
|
|
user.setUserType(userType); |
|
|
|
|
|
|
|
user.setCreateTime(now); |
|
|
|
|
|
|
|
user.setUpdateTime(now); |
|
|
|
|
|
|
|
user.setQueue(""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// save user
|
|
|
|
|
|
|
|
userMapper.insert(user); |
|
|
|
|
|
|
|
return user; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* get user by user name |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userName user name |
|
|
|
|
|
|
|
* @return exist user or null |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public User getUserByUserName(String userName) { |
|
|
|
|
|
|
|
return userMapper.queryByUserNameAccurately(userName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* query user by id |
|
|
|
* query user by id |
|
|
|
|
|
|
|
* |
|
|
|
* @param id id |
|
|
|
* @param id id |
|
|
|
* @return user info |
|
|
|
* @return user info |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -182,6 +242,7 @@ public class UsersService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* query user |
|
|
|
* query user |
|
|
|
|
|
|
|
* |
|
|
|
* @param name name |
|
|
|
* @param name name |
|
|
|
* @return user info |
|
|
|
* @return user info |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -203,6 +264,7 @@ public class UsersService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get user id by user name |
|
|
|
* get user id by user name |
|
|
|
|
|
|
|
* |
|
|
|
* @param name user name |
|
|
|
* @param name user name |
|
|
|
* @return if name empty 0, user not exists -1, user exist user id |
|
|
|
* @return if name empty 0, user not exists -1, user exist user id |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -242,7 +304,7 @@ public class UsersService extends BaseService { |
|
|
|
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal); |
|
|
|
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal); |
|
|
|
|
|
|
|
|
|
|
|
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize); |
|
|
|
pageInfo.setTotalCount((int)scheduleList.getTotal()); |
|
|
|
pageInfo.setTotalCount((int) scheduleList.getTotal()); |
|
|
|
pageInfo.setLists(scheduleList.getRecords()); |
|
|
|
pageInfo.setLists(scheduleList.getRecords()); |
|
|
|
result.put(Constants.DATA_LIST, pageInfo); |
|
|
|
result.put(Constants.DATA_LIST, pageInfo); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
@ -286,8 +348,8 @@ public class UsersService extends BaseService { |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(userName)) { |
|
|
|
if (StringUtils.isNotEmpty(userName)) { |
|
|
|
|
|
|
|
|
|
|
|
if (!CheckUtils.checkUserName(userName)){ |
|
|
|
if (!CheckUtils.checkUserName(userName)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,userName); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -300,23 +362,23 @@ public class UsersService extends BaseService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(userPassword)) { |
|
|
|
if (StringUtils.isNotEmpty(userPassword)) { |
|
|
|
if (!CheckUtils.checkPassword(userPassword)){ |
|
|
|
if (!CheckUtils.checkPassword(userPassword)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,userPassword); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userPassword); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
user.setUserPassword(EncryptionUtils.getMd5(userPassword)); |
|
|
|
user.setUserPassword(EncryptionUtils.getMd5(userPassword)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(email)) { |
|
|
|
if (StringUtils.isNotEmpty(email)) { |
|
|
|
if (!CheckUtils.checkEmail(email)){ |
|
|
|
if (!CheckUtils.checkEmail(email)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,email); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
user.setEmail(email); |
|
|
|
user.setEmail(email); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { |
|
|
|
if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,phone); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
user.setPhone(phone); |
|
|
|
user.setPhone(phone); |
|
|
@ -332,13 +394,13 @@ public class UsersService extends BaseService { |
|
|
|
Tenant newTenant = tenantMapper.queryById(tenantId); |
|
|
|
Tenant newTenant = tenantMapper.queryById(tenantId); |
|
|
|
if (newTenant != null) { |
|
|
|
if (newTenant != null) { |
|
|
|
// if hdfs startup
|
|
|
|
// if hdfs startup
|
|
|
|
if (PropertyUtils.getResUploadStartupState() && oldTenant != null){ |
|
|
|
if (PropertyUtils.getResUploadStartupState() && oldTenant != null) { |
|
|
|
String newTenantCode = newTenant.getTenantCode(); |
|
|
|
String newTenantCode = newTenant.getTenantCode(); |
|
|
|
String oldResourcePath = HadoopUtils.getHdfsResDir(oldTenant.getTenantCode()); |
|
|
|
String oldResourcePath = HadoopUtils.getHdfsResDir(oldTenant.getTenantCode()); |
|
|
|
String oldUdfsPath = HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode()); |
|
|
|
String oldUdfsPath = HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode()); |
|
|
|
|
|
|
|
|
|
|
|
// if old tenant dir exists
|
|
|
|
// if old tenant dir exists
|
|
|
|
if (HadoopUtils.getInstance().exists(oldResourcePath)){ |
|
|
|
if (HadoopUtils.getInstance().exists(oldResourcePath)) { |
|
|
|
String newResourcePath = HadoopUtils.getHdfsResDir(newTenantCode); |
|
|
|
String newResourcePath = HadoopUtils.getHdfsResDir(newTenantCode); |
|
|
|
String newUdfsPath = HadoopUtils.getHdfsUdfDir(newTenantCode); |
|
|
|
String newUdfsPath = HadoopUtils.getHdfsUdfDir(newTenantCode); |
|
|
|
|
|
|
|
|
|
|
@ -361,18 +423,18 @@ public class UsersService extends BaseService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Delete the user from the old tenant directory
|
|
|
|
//Delete the user from the old tenant directory
|
|
|
|
String oldUserPath = HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(),userId); |
|
|
|
String oldUserPath = HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(), userId); |
|
|
|
HadoopUtils.getInstance().delete(oldUserPath, true); |
|
|
|
HadoopUtils.getInstance().delete(oldUserPath, true); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// if old tenant dir not exists , create
|
|
|
|
// if old tenant dir not exists , create
|
|
|
|
createTenantDirIfNotExists(oldTenant.getTenantCode()); |
|
|
|
createTenantDirIfNotExists(oldTenant.getTenantCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode()))){ |
|
|
|
if (HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode()))) { |
|
|
|
//create user in the new tenant directory
|
|
|
|
//create user in the new tenant directory
|
|
|
|
String newUserPath = HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(),user.getId()); |
|
|
|
String newUserPath = HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(), user.getId()); |
|
|
|
HadoopUtils.getInstance().mkdir(newUserPath); |
|
|
|
HadoopUtils.getInstance().mkdir(newUserPath); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// if new tenant dir not exists , create
|
|
|
|
// if new tenant dir not exists , create
|
|
|
|
createTenantDirIfNotExists(newTenant.getTenantCode()); |
|
|
|
createTenantDirIfNotExists(newTenant.getTenantCode()); |
|
|
|
} |
|
|
|
} |
|
|
@ -414,7 +476,7 @@ public class UsersService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
if (user != null) { |
|
|
|
if (user != null) { |
|
|
|
if (PropertyUtils.getResUploadStartupState()) { |
|
|
|
if (PropertyUtils.getResUploadStartupState()) { |
|
|
|
String userPath = HadoopUtils.getHdfsUserDir(user.getTenantCode(),id); |
|
|
|
String userPath = HadoopUtils.getHdfsUserDir(user.getTenantCode(), id); |
|
|
|
if (HadoopUtils.getInstance().exists(userPath)) { |
|
|
|
if (HadoopUtils.getInstance().exists(userPath)) { |
|
|
|
HadoopUtils.getInstance().delete(userPath, true); |
|
|
|
HadoopUtils.getInstance().delete(userPath, true); |
|
|
|
} |
|
|
|
} |
|
|
@ -493,7 +555,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
if(user == null){ |
|
|
|
if (user == null) { |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,7 +566,7 @@ public class UsersService extends BaseService { |
|
|
|
// need authorize resource id set
|
|
|
|
// need authorize resource id set
|
|
|
|
for (String resourceFullId : resourceFullIdArr) { |
|
|
|
for (String resourceFullId : resourceFullIdArr) { |
|
|
|
String[] resourceIdArr = resourceFullId.split("-"); |
|
|
|
String[] resourceIdArr = resourceFullId.split("-"); |
|
|
|
for (int i=0;i<=resourceIdArr.length-1;i++) { |
|
|
|
for (int i = 0; i <= resourceIdArr.length - 1; i++) { |
|
|
|
int resourceIdValue = Integer.parseInt(resourceIdArr[i]); |
|
|
|
int resourceIdValue = Integer.parseInt(resourceIdArr[i]); |
|
|
|
needAuthorizeResIds.add(resourceIdValue); |
|
|
|
needAuthorizeResIds.add(resourceIdValue); |
|
|
|
} |
|
|
|
} |
|
|
@ -531,7 +593,7 @@ public class UsersService extends BaseService { |
|
|
|
if (CollectionUtils.isNotEmpty(resourceIdSet)) { |
|
|
|
if (CollectionUtils.isNotEmpty(resourceIdSet)) { |
|
|
|
logger.error("can't be deleted,because it is used of process definition"); |
|
|
|
logger.error("can't be deleted,because it is used of process definition"); |
|
|
|
for (Integer resId : resourceIdSet) { |
|
|
|
for (Integer resId : resourceIdSet) { |
|
|
|
logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId)); |
|
|
|
logger.error("resource id:{} is used of process definition {}", resId, resourceProcessMap.get(resId)); |
|
|
|
} |
|
|
|
} |
|
|
|
putMsg(result, Status.RESOURCE_IS_USED); |
|
|
|
putMsg(result, Status.RESOURCE_IS_USED); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -558,7 +620,7 @@ public class UsersService extends BaseService { |
|
|
|
resourcesUser.setResourcesId(resourceIdValue); |
|
|
|
resourcesUser.setResourcesId(resourceIdValue); |
|
|
|
if (resource.isDirectory()) { |
|
|
|
if (resource.isDirectory()) { |
|
|
|
resourcesUser.setPerm(Constants.AUTHORIZE_READABLE_PERM); |
|
|
|
resourcesUser.setPerm(Constants.AUTHORIZE_READABLE_PERM); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); |
|
|
|
resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -591,7 +653,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
if(user == null){ |
|
|
|
if (user == null) { |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -639,7 +701,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
User user = userMapper.selectById(userId); |
|
|
|
if(user == null){ |
|
|
|
if (user == null) { |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
putMsg(result, Status.USER_NOT_EXIST, userId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -738,7 +800,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<User> userList = userMapper.selectList(null ); |
|
|
|
List<User> userList = userMapper.selectList(null); |
|
|
|
result.put(Constants.DATA_LIST, userList); |
|
|
|
result.put(Constants.DATA_LIST, userList); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
@ -782,7 +844,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<User> userList = userMapper.selectList(null ); |
|
|
|
List<User> userList = userMapper.selectList(null); |
|
|
|
List<User> resultUsers = new ArrayList<>(); |
|
|
|
List<User> resultUsers = new ArrayList<>(); |
|
|
|
Set<User> userSet = null; |
|
|
|
Set<User> userSet = null; |
|
|
|
if (userList != null && userList.size() > 0) { |
|
|
|
if (userList != null && userList.size() > 0) { |
|
|
@ -833,11 +895,6 @@ public class UsersService extends BaseService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
|
|
|
|
* @param userName |
|
|
|
|
|
|
|
* @param password |
|
|
|
|
|
|
|
* @param email |
|
|
|
|
|
|
|
* @param phone |
|
|
|
|
|
|
|
* @return if check failed return the field, otherwise return null |
|
|
|
* @return if check failed return the field, otherwise return null |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String checkUserParams(String userName, String password, String email, String phone) { |
|
|
|
private String checkUserParams(String userName, String password, String email, String phone) { |
|
|
@ -862,6 +919,7 @@ public class UsersService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* copy resource files |
|
|
|
* copy resource files |
|
|
|
|
|
|
|
* |
|
|
|
* @param resourceComponent resource component |
|
|
|
* @param resourceComponent resource component |
|
|
|
* @param srcBasePath src base path |
|
|
|
* @param srcBasePath src base path |
|
|
|
* @param dstBasePath dst base path |
|
|
|
* @param dstBasePath dst base path |
|
|
@ -871,26 +929,26 @@ public class UsersService extends BaseService { |
|
|
|
List<ResourceComponent> components = resourceComponent.getChildren(); |
|
|
|
List<ResourceComponent> components = resourceComponent.getChildren(); |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(components)) { |
|
|
|
if (CollectionUtils.isNotEmpty(components)) { |
|
|
|
for (ResourceComponent component:components) { |
|
|
|
for (ResourceComponent component : components) { |
|
|
|
// verify whether exist
|
|
|
|
// verify whether exist
|
|
|
|
if (!HadoopUtils.getInstance().exists(String.format("%s/%s",srcBasePath,component.getFullName()))){ |
|
|
|
if (!HadoopUtils.getInstance().exists(String.format("%s/%s", srcBasePath, component.getFullName()))) { |
|
|
|
logger.error("resource file: {} not exist,copy error",component.getFullName()); |
|
|
|
logger.error("resource file: {} not exist,copy error", component.getFullName()); |
|
|
|
throw new ServiceException(Status.RESOURCE_NOT_EXIST); |
|
|
|
throw new ServiceException(Status.RESOURCE_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!component.isDirctory()) { |
|
|
|
if (!component.isDirctory()) { |
|
|
|
// copy it to dst
|
|
|
|
// copy it to dst
|
|
|
|
HadoopUtils.getInstance().copy(String.format("%s/%s",srcBasePath,component.getFullName()),String.format("%s/%s",dstBasePath,component.getFullName()),false,true); |
|
|
|
HadoopUtils.getInstance().copy(String.format("%s/%s", srcBasePath, component.getFullName()), String.format("%s/%s", dstBasePath, component.getFullName()), false, true); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(component.getChildren())) { |
|
|
|
if (CollectionUtils.isEmpty(component.getChildren())) { |
|
|
|
// if not exist,need create it
|
|
|
|
// if not exist,need create it
|
|
|
|
if (!HadoopUtils.getInstance().exists(String.format("%s/%s",dstBasePath,component.getFullName()))) { |
|
|
|
if (!HadoopUtils.getInstance().exists(String.format("%s/%s", dstBasePath, component.getFullName()))) { |
|
|
|
HadoopUtils.getInstance().mkdir(String.format("%s/%s",dstBasePath,component.getFullName())); |
|
|
|
HadoopUtils.getInstance().mkdir(String.format("%s/%s", dstBasePath, component.getFullName())); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
copyResourceFiles(component,srcBasePath,dstBasePath); |
|
|
|
copyResourceFiles(component, srcBasePath, dstBasePath); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -914,7 +972,7 @@ public class UsersService extends BaseService { |
|
|
|
String msg = this.checkUserParams(userName, userPassword, email, ""); |
|
|
|
String msg = this.checkUserParams(userName, userPassword, email, ""); |
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(msg)) { |
|
|
|
if (!StringUtils.isEmpty(msg)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR,msg); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -944,7 +1002,7 @@ public class UsersService extends BaseService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!CheckUtils.checkUserName(userName)){ |
|
|
|
if (!CheckUtils.checkUserName(userName)) { |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); |
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|