@ -14,10 +14,12 @@
* 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.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
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 ;
@ -33,6 +35,7 @@ import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.entity.* ;
import org.apache.dolphinscheduler.dao.entity.* ;
import org.apache.dolphinscheduler.dao.mapper.* ;
import org.apache.dolphinscheduler.dao.mapper.* ;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils ;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils ;
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 ;
@ -83,13 +86,13 @@ public class UsersService extends BaseService {
/ * *
/ * *
* create user , only system admin have permission
* create user , only system admin have permission
*
*
* @param loginUser login user
* @param loginUser login user
* @param userName user name
* @param userName user name
* @param userPassword user password
* @param userPassword user password
* @param email email
* @param email email
* @param tenantId tenant id
* @param tenantId tenant id
* @param phone phone
* @param phone phone
* @param queue queue
* @param queue queue
* @return create result code
* @return create result code
* @throws Exception exception
* @throws Exception exception
* /
* /
@ -109,7 +112,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 +129,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 ) ;
}
}
@ -142,12 +145,12 @@ public class UsersService extends BaseService {
@Transactional ( rollbackFor = RuntimeException . class )
@Transactional ( rollbackFor = RuntimeException . class )
public User createUser ( String userName ,
public User createUser ( String userName ,
String userPassword ,
String userPassword ,
String email ,
String email ,
int tenantId ,
int tenantId ,
String phone ,
String phone ,
String queue ,
String queue ,
int state ) {
int state ) {
User user = new User ( ) ;
User user = new User ( ) ;
Date now = new Date ( ) ;
Date now = new Date ( ) ;
@ -161,7 +164,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 ) ;
@ -173,6 +176,7 @@ public class UsersService extends BaseService {
/ * *
/ * *
* query user by id
* query user by id
*
* @param id id
* @param id id
* @return user info
* @return user info
* /
* /
@ -182,6 +186,7 @@ public class UsersService extends BaseService {
/ * *
/ * *
* query user
* query user
*
* @param name name
* @param name name
* @return user info
* @return user info
* /
* /
@ -192,7 +197,7 @@ public class UsersService extends BaseService {
/ * *
/ * *
* query user
* query user
*
*
* @param name name
* @param name name
* @param password password
* @param password password
* @return user info
* @return user info
* /
* /
@ -203,6 +208,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
* /
* /
@ -225,9 +231,9 @@ public class UsersService extends BaseService {
* query user list
* query user list
*
*
* @param loginUser login user
* @param loginUser login user
* @param pageNo page number
* @param pageNo page number
* @param searchVal search avlue
* @param searchVal search avlue
* @param pageSize page size
* @param pageSize page size
* @return user list page
* @return user list page
* /
* /
public Map < String , Object > queryUserList ( User loginUser , String searchVal , Integer pageNo , Integer pageSize ) {
public Map < String , Object > queryUserList ( User loginUser , String searchVal , Integer pageNo , Integer pageSize ) {
@ -242,7 +248,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 ) ;
@ -253,13 +259,13 @@ public class UsersService extends BaseService {
/ * *
/ * *
* updateProcessInstance user
* updateProcessInstance user
*
*
* @param userId user id
* @param userId user id
* @param userName user name
* @param userName user name
* @param userPassword user password
* @param userPassword user password
* @param email email
* @param email email
* @param tenantId tennat id
* @param tenantId tennat id
* @param phone phone
* @param phone phone
* @param queue queue
* @param queue queue
* @return update result code
* @return update result code
* @throws Exception exception
* @throws Exception exception
* /
* /
@ -283,8 +289,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 ;
}
}
@ -297,23 +303,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 ) ;
@ -329,19 +335,19 @@ 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 ) ;
//file resources list
//file resources list
List < Resource > fileResourcesList = resourceMapper . queryResourceList (
List < Resource > fileResourcesList = resourceMapper . queryResourceList (
null , userId , ResourceType . FILE . ordinal ( ) ) ;
null , userId , ResourceType . FILE . ordinal ( ) ) ;
if ( CollectionUtils . isNotEmpty ( fileResourcesList ) ) {
if ( CollectionUtils . isNotEmpty ( fileResourcesList ) ) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor ( fileResourcesList ) ;
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor ( fileResourcesList ) ;
ResourceComponent resourceComponent = resourceTreeVisitor . visit ( ) ;
ResourceComponent resourceComponent = resourceTreeVisitor . visit ( ) ;
@ -350,7 +356,7 @@ public class UsersService extends BaseService {
//udf resources
//udf resources
List < Resource > udfResourceList = resourceMapper . queryResourceList (
List < Resource > udfResourceList = resourceMapper . queryResourceList (
null , userId , ResourceType . UDF . ordinal ( ) ) ;
null , userId , ResourceType . UDF . ordinal ( ) ) ;
if ( CollectionUtils . isNotEmpty ( udfResourceList ) ) {
if ( CollectionUtils . isNotEmpty ( udfResourceList ) ) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor ( udfResourceList ) ;
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor ( udfResourceList ) ;
ResourceComponent resourceComponent = resourceTreeVisitor . visit ( ) ;
ResourceComponent resourceComponent = resourceTreeVisitor . visit ( ) ;
@ -358,18 +364,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 ( ) ) ;
}
}
@ -389,7 +395,7 @@ public class UsersService extends BaseService {
* delete user
* delete user
*
*
* @param loginUser login user
* @param loginUser login user
* @param id user id
* @param id user id
* @return delete result code
* @return delete result code
* @throws Exception exception when operate hdfs
* @throws Exception exception when operate hdfs
* /
* /
@ -411,7 +417,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 ) ;
}
}
@ -427,8 +433,8 @@ public class UsersService extends BaseService {
/ * *
/ * *
* grant project
* grant project
*
*
* @param loginUser login user
* @param loginUser login user
* @param userId user id
* @param userId user id
* @param projectIds project id array
* @param projectIds project id array
* @return grant result code
* @return grant result code
* /
* /
@ -477,8 +483,8 @@ public class UsersService extends BaseService {
/ * *
/ * *
* grant resource
* grant resource
*
*
* @param loginUser login user
* @param loginUser login user
* @param userId user id
* @param userId user id
* @param resourceIds resource id array
* @param resourceIds resource id array
* @return grant result code
* @return grant result code
* /
* /
@ -490,7 +496,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 ;
}
}
@ -501,7 +507,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 ) ;
}
}
@ -528,7 +534,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 ;
@ -555,7 +561,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 ) ;
}
}
@ -575,8 +581,8 @@ public class UsersService extends BaseService {
* grant udf function
* grant udf function
*
*
* @param loginUser login user
* @param loginUser login user
* @param userId user id
* @param userId user id
* @param udfIds udf id array
* @param udfIds udf id array
* @return grant result code
* @return grant result code
* /
* /
@Transactional ( rollbackFor = RuntimeException . class )
@Transactional ( rollbackFor = RuntimeException . class )
@ -588,7 +594,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 ;
}
}
@ -621,9 +627,9 @@ public class UsersService extends BaseService {
/ * *
/ * *
* grant datasource
* grant datasource
*
*
* @param loginUser login user
* @param loginUser login user
* @param userId user id
* @param userId user id
* @param datasourceIds data source id array
* @param datasourceIds data source id array
* @return grant result code
* @return grant result code
* /
* /
@Transactional ( rollbackFor = RuntimeException . class )
@Transactional ( rollbackFor = RuntimeException . class )
@ -636,7 +642,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 ;
}
}
@ -676,23 +682,11 @@ public class UsersService extends BaseService {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
User user = null ;
User user ;
if ( loginUser . getUserType ( ) = = UserType . ADMIN_USER ) {
if ( loginUser . getUserType ( ) = = UserType . ADMIN_USER ) {
user = loginUser ;
user = loginUser ;
} else {
} else {
user = userMapper . queryDetailsById ( loginUser . getId ( ) ) ;
user = userMapper . queryDetailsById ( loginUser . getId ( ) ) ;
List < AlertGroup > alertGroups = alertGroupMapper . queryByUserId ( loginUser . getId ( ) ) ;
StringBuilder sb = new StringBuilder ( ) ;
if ( alertGroups ! = null & & alertGroups . size ( ) > 0 ) {
for ( int i = 0 ; i < alertGroups . size ( ) - 1 ; i + + ) {
sb . append ( alertGroups . get ( i ) . getGroupName ( ) + "," ) ;
}
sb . append ( alertGroups . get ( alertGroups . size ( ) - 1 ) ) ;
user . setAlertGroup ( sb . toString ( ) ) ;
}
}
}
result . put ( Constants . DATA_LIST , user ) ;
result . put ( Constants . DATA_LIST , user ) ;
@ -735,7 +729,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 ) ;
@ -767,7 +761,7 @@ public class UsersService extends BaseService {
/ * *
/ * *
* unauthorized user
* unauthorized user
*
*
* @param loginUser login user
* @param loginUser login user
* @param alertgroupId alert group id
* @param alertgroupId alert group id
* @return unauthorize result code
* @return unauthorize result code
* /
* /
@ -779,7 +773,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 ) {
@ -804,7 +798,7 @@ public class UsersService extends BaseService {
/ * *
/ * *
* authorized user
* authorized user
*
*
* @param loginUser login user
* @param loginUser login user
* @param alertgroupId alert group id
* @param alertgroupId alert group id
* @return authorized result code
* @return authorized result code
* /
* /
@ -824,8 +818,8 @@ public class UsersService extends BaseService {
/ * *
/ * *
* check
* check
*
*
* @param result result
* @param result result
* @param bool bool
* @param bool bool
* @param userNoOperationPerm status
* @param userNoOperationPerm status
* @return check result
* @return check result
* /
* /
@ -848,7 +842,6 @@ public class UsersService extends BaseService {
}
}
/ * *
/ * *
*
* @param userName
* @param userName
* @param password
* @param password
* @param email
* @param email
@ -877,35 +870,36 @@ 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
* @throws IOException io exception
* @throws IOException io exception
* /
* /
private void copyResourceFiles ( ResourceComponent resourceComponent , String srcBasePath , String dstBasePath ) throws IOException {
private void copyResourceFiles ( ResourceComponent resourceComponent , String srcBasePath , String dstBasePath ) throws IOException {
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 ) ;
}
}
}
}
}
}
@ -929,7 +923,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 ;
}
}
@ -959,7 +953,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 ;
}
}