break60 4 years ago
parent
commit
ea3c29aad9
  1. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java
  2. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java
  3. 18
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java
  4. 28
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
  5. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java
  6. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  7. 14
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java

@ -75,7 +75,7 @@ public class AlertGroupService extends BaseService{
public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -83,7 +83,7 @@ public class AlertGroupService extends BaseService{
IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage( IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage(
page, searchVal); page, searchVal);
PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize); PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int)alertGroupIPage.getTotal()); pageInfo.setTotalCount((int) alertGroupIPage.getTotal());
pageInfo.setLists(alertGroupIPage.getRecords()); pageInfo.setLists(alertGroupIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo); result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
@ -103,7 +103,7 @@ public class AlertGroupService extends BaseService{
public Map<String, Object> createAlertgroup(User loginUser, String groupName, AlertType groupType, String desc) { public Map<String, Object> createAlertgroup(User loginUser, String groupName, AlertType groupType, String desc) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -140,7 +140,7 @@ public class AlertGroupService extends BaseService{
public Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, AlertType groupType, String desc) { public Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, AlertType groupType, String desc) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -183,7 +183,7 @@ public class AlertGroupService extends BaseService{
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
//check exist //check exist
@ -213,7 +213,7 @@ public class AlertGroupService extends BaseService{
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java

@ -46,13 +46,13 @@ public class BaseService {
} }
/** /**
* check admin * isNotAdmin
* *
* @param loginUser login user * @param loginUser login user
* @param result result code * @param result result code
* @return true if administrator, otherwise false * @return true if not administrator, otherwise false
*/ */
protected boolean checkAdmin(User loginUser, Map<String, Object> result) { protected boolean isNotAdmin(User loginUser, Map<String, Object> result) {
//only admin can operate //only admin can operate
if (!isAdmin(loginUser)) { if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM); putMsg(result, Status.USER_NO_OPERATION_PERM);

18
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java

@ -60,7 +60,7 @@ public class QueueService extends BaseService {
*/ */
public Map<String, Object> queryList(User loginUser) { public Map<String, Object> queryList(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -75,14 +75,14 @@ public class QueueService extends BaseService {
* query queue list paging * query queue list paging
* *
* @param loginUser login user * @param loginUser login user
* @param pageNo page number * @param pageNo page number
* @param searchVal search value * @param searchVal search value
* @param pageSize page size * @param pageSize page size
* @return queue list * @return queue list
*/ */
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -105,13 +105,13 @@ public class QueueService extends BaseService {
* create queue * create queue
* *
* @param loginUser login user * @param loginUser login user
* @param queue queue * @param queue queue
* @param queueName queue name * @param queueName queue name
* @return create result * @return create result
*/ */
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) { public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -153,14 +153,14 @@ public class QueueService extends BaseService {
* update queue * update queue
* *
* @param loginUser login user * @param loginUser login user
* @param queue queue * @param queue queue
* @param id queue id * @param id queue id
* @param queueName queue name * @param queueName queue name
* @return update result code * @return update result code
*/ */
public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) { public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }

28
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java

@ -1158,20 +1158,20 @@ public class ResourcesService extends BaseService {
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
List<ResourceComponent> list ; List<ResourceComponent> list;
if (CollectionUtils.isNotEmpty(resourceList)) { if (CollectionUtils.isNotEmpty(resourceList)) {
Visitor visitor = new ResourceTreeVisitor(resourceList); Visitor visitor = new ResourceTreeVisitor(resourceList);
list = visitor.visit().getChildren(); list = visitor.visit().getChildren();
}else { } else {
list = new ArrayList<>(0); list = new ArrayList<>(0);
} }
result.put(Constants.DATA_LIST, list); result.put(Constants.DATA_LIST, list);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
@ -1185,23 +1185,23 @@ public class ResourcesService extends BaseService {
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
List<Resource> list ; List<Resource> list;
if (resourceList != null && resourceList.size() > 0) { if (resourceList != null && resourceList.size() > 0) {
Set<Resource> resourceSet = new HashSet<>(resourceList); Set<Resource> resourceSet = new HashSet<>(resourceList);
List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId); List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId);
getAuthorizedResourceList(resourceSet, authedResourceList); getAuthorizedResourceList(resourceSet, authedResourceList);
list = new ArrayList<>(resourceSet); list = new ArrayList<>(resourceSet);
}else { } else {
list = new ArrayList<>(0); list = new ArrayList<>(0);
} }
Visitor visitor = new ResourceTreeVisitor(list); Visitor visitor = new ResourceTreeVisitor(list);
result.put(Constants.DATA_LIST, visitor.visit().getChildren()); result.put(Constants.DATA_LIST, visitor.visit().getChildren());
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
@ -1215,7 +1215,7 @@ public class ResourcesService extends BaseService {
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -1231,13 +1231,11 @@ public class ResourcesService extends BaseService {
resultList = new ArrayList<>(udfFuncSet); resultList = new ArrayList<>(udfFuncSet);
} }
result.put(Constants.DATA_LIST, resultList); result.put(Constants.DATA_LIST, resultList);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
/** /**
* authorized udf function * authorized udf function
* *
@ -1247,12 +1245,12 @@ public class ResourcesService extends BaseService {
*/ */
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId);
result.put(Constants.DATA_LIST, udfFuncs); result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
@ -1266,7 +1264,7 @@ public class ResourcesService extends BaseService {
*/ */
public Map<String, Object> authorizedFile(User loginUser, Integer userId) { public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId); List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId);

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkerGroupService.java

@ -70,7 +70,7 @@ public class WorkerGroupService extends BaseService {
Integer toIndex = (pageNo - 1) * pageSize + pageSize; Integer toIndex = (pageNo - 1) * pageSize + pageSize;
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -293,7 +293,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
*/ */
public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) { public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
/** /**
@ -344,7 +344,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
public Map<String, Object> queryAuthorizedProject(User loginUser, Integer userId) { public Map<String, Object> queryAuthorizedProject(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -364,7 +364,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
public Map<String, Object> queryProjectCreatedByUser(User loginUser) { public Map<String, Object> queryProjectCreatedByUser(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }

14
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java

@ -89,7 +89,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -134,14 +134,14 @@ public class TenantServiceImpl extends BaseService implements TenantService {
* *
* @param loginUser login user * @param loginUser login user
* @param searchVal search value * @param searchVal search value
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @return tenant list page * @return tenant list page
*/ */
public Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -174,7 +174,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
@ -227,7 +227,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
* delete tenant * delete tenant
* *
* @param loginUser login user * @param loginUser login user
* @param id tenant id * @param id tenant id
* @return delete result code * @return delete result code
* @throws Exception exception * @throws Exception exception
*/ */
@ -235,7 +235,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception { public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }

Loading…
Cancel
Save