Browse Source

1 word error

2 modify check project perm may NPE
3  modify checkResult  may NPE
4 update project add desc check
pull/2/head
lilin 5 years ago
parent
commit
6736765844
  1. 15
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java

15
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java

@ -121,7 +121,7 @@ public class ProjectService extends BaseService{
* @param loginUser login user * @param loginUser login user
* @param project project * @param project project
* @param projectName project name * @param projectName project name
* @return true if the login user havve permission to see the project * @return true if the login user have permission to see the project
*/ */
public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, String projectName) { public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, String projectName) {
@ -143,7 +143,7 @@ public class ProjectService extends BaseService{
public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result) { public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result) {
boolean checkResult = false; boolean checkResult = false;
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, project.getName()); putMsg(result, Status.PROJECT_NOT_FOUNT, "");
} else if (!checkReadPermission(loginUser, project)) { } else if (!checkReadPermission(loginUser, project)) {
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName()); putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName());
} else { } else {
@ -199,13 +199,14 @@ public class ProjectService extends BaseService{
if (checkResult != null) { if (checkResult != null) {
return checkResult; return checkResult;
} }
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(projectId);
if (!hasPerm(loginUser, project.getUserId())) { if (!hasPerm(loginUser, project.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM); putMsg(result, Status.USER_NO_OPERATION_PERM);
return result; return result;
} }
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(projectId);
if(processDefinitionList.size() > 0){ if(processDefinitionList.size() > 0){
putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL); putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL);
return result; return result;
@ -227,7 +228,8 @@ public class ProjectService extends BaseService{
* @return check result * @return check result
*/ */
private Map<String, Object> getCheckResult(User loginUser, Project project) { private Map<String, Object> getCheckResult(User loginUser, Project project) {
Map<String, Object> checkResult = checkProjectAndAuth(loginUser, project, project.getName()); String projectName = project == null ? null:project.getName();
Map<String, Object> checkResult = checkProjectAndAuth(loginUser, project, projectName);
Status status = (Status) checkResult.get(Constants.STATUS); Status status = (Status) checkResult.get(Constants.STATUS);
if (status != Status.SUCCESS) { if (status != Status.SUCCESS) {
return checkResult; return checkResult;
@ -247,6 +249,11 @@ public class ProjectService extends BaseService{
public Map<String, Object> update(User loginUser, Integer projectId, String projectName, String desc) { public Map<String, Object> update(User loginUser, Integer projectId, String projectName, String desc) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
Map<String, Object> descCheck = checkDesc(desc);
if (descCheck.get(Constants.STATUS) != Status.SUCCESS) {
return descCheck;
}
Project project = projectMapper.selectById(projectId); Project project = projectMapper.selectById(projectId);
boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result);
if (!hasProjectAndPerm) { if (!hasProjectAndPerm) {

Loading…
Cancel
Save