|
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.utils.CheckUtils;
|
|
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.Flag; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; |
|
|
|
@ -40,11 +41,13 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
|
import org.apache.dolphinscheduler.service.permission.PermissionCheck; |
|
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
@ -69,6 +72,8 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(TaskDefinitionServiceImpl.class); |
|
|
|
|
|
|
|
|
|
private static final String RELEASESTATE = "releaseState"; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ProjectMapper projectMapper; |
|
|
|
|
|
|
|
|
@ -454,6 +459,50 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> releaseTaskDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) { |
|
|
|
|
return null; |
|
|
|
|
Project project = projectMapper.queryByCode(projectCode); |
|
|
|
|
//check user access for project
|
|
|
|
|
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
|
|
|
|
Status resultStatus = (Status) result.get(Constants.STATUS); |
|
|
|
|
if (resultStatus != Status.SUCCESS) { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
if (null == releaseState) { |
|
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(code); |
|
|
|
|
if (taskDefinition == null) { |
|
|
|
|
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, code); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (releaseState) { |
|
|
|
|
case OFFLINE: |
|
|
|
|
taskDefinition.setFlag(Flag.NO); |
|
|
|
|
taskDefinitionMapper.updateById(taskDefinition); |
|
|
|
|
break; |
|
|
|
|
case ONLINE: |
|
|
|
|
String resourceIds = taskDefinition.getResourceIds(); |
|
|
|
|
if (StringUtils.isNotBlank(resourceIds)) { |
|
|
|
|
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(",")).map(Integer::parseInt).toArray(Integer[]::new); |
|
|
|
|
PermissionCheck<Integer> permissionCheck = new PermissionCheck(AuthorizationType.RESOURCE_FILE_ID,processService,resourceIdArray,loginUser.getId(),logger); |
|
|
|
|
try { |
|
|
|
|
permissionCheck.checkPermission(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
|
putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
taskDefinition.setFlag(Flag.YES); |
|
|
|
|
taskDefinitionMapper.updateById(taskDefinition); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|