[Improvement][api] Introduce base service interface for clear code and unify all controllers, services and tests of api (#4798)
* [Improvement][api] Introduce base service interface for clear code * [Improvement][api] Unify all controllers, services and tests of api * [Fix][api] Fix unit tests left over from the past * [Improvement][api] Use RegexUtils.escapeNRT instead of StringUtils.replaceNRTtoUnderline for vulnerable check
This commit is contained in:
parent
68de43ad27
commit
61397b338a
|
|
@ -14,8 +14,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ACCESS_TOKEN_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ACCESS_TOKEN_ERROR;
|
||||
|
|
@ -54,7 +54,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* access token controller
|
||||
*/
|
||||
@Api(tags = "ACCESS_TOKEN_TAG", position = 1)
|
||||
@Api(tags = "ACCESS_TOKEN_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/access-token")
|
||||
public class AccessTokenController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_GROUP_ER
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -55,7 +55,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* alert group controller
|
||||
*/
|
||||
@Api(tags = "ALERT_GROUP_TAG", position = 1)
|
||||
@Api(tags = "ALERT_GROUP_TAG")
|
||||
@RestController
|
||||
@RequestMapping("alert-group")
|
||||
public class AlertGroupController extends BaseController {
|
||||
|
|
@ -87,12 +87,9 @@ public class AlertGroupController extends BaseController {
|
|||
@RequestParam(value = "groupName") String groupName,
|
||||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "alertInstanceIds") String alertInstanceIds) {
|
||||
String strUserName = StringUtils.replaceNRTtoUnderline(loginUser.getUserName());
|
||||
String strGroupName = StringUtils.replaceNRTtoUnderline(groupName);
|
||||
String strDescription = StringUtils.replaceNRTtoUnderline(description);
|
||||
String strAlertInstanceIds = StringUtils.replaceNRTtoUnderline(alertInstanceIds);
|
||||
logger.info("loginUser user {}, create alert group, groupName: {}, desc: {},alertInstanceIds:{}",
|
||||
strUserName, strGroupName, strDescription, strAlertInstanceIds);
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()), RegexUtils.escapeNRT(groupName),
|
||||
RegexUtils.escapeNRT(description), RegexUtils.escapeNRT(alertInstanceIds));
|
||||
Map<String, Object> result = alertGroupService.createAlertgroup(loginUser, groupName, description, alertInstanceIds);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
@ -173,9 +170,9 @@ public class AlertGroupController extends BaseController {
|
|||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "alertInstanceIds") String alertInstanceIds) {
|
||||
logger.info("login user {}, updateProcessInstance alert group, groupName: {}, desc: {}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(groupName),
|
||||
StringUtils.replaceNRTtoUnderline(description));
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()),
|
||||
RegexUtils.escapeNRT(groupName),
|
||||
RegexUtils.escapeNRT(description));
|
||||
Map<String, Object> result = alertGroupService.updateAlertgroup(loginUser, id, groupName, description, alertInstanceIds);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_PLUGIN_I
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -55,7 +55,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* alert plugin instance controller
|
||||
*/
|
||||
@Api(tags = "ALERT_PLUGIN_INSTANCE_TAG", position = 1)
|
||||
@Api(tags = "ALERT_PLUGIN_INSTANCE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("alert-plugin-instance")
|
||||
public class AlertPluginInstanceController extends BaseController {
|
||||
|
|
@ -89,8 +89,8 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@RequestParam(value = "instanceName") String instanceName,
|
||||
@RequestParam(value = "pluginInstanceParams") String pluginInstanceParams) {
|
||||
logger.info("login user {},create alert plugin instance, instanceName:{} ",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(instanceName));
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()),
|
||||
RegexUtils.escapeNRT(instanceName));
|
||||
Map<String, Object> result = alertPluginInstanceService.create(loginUser, pluginDefineId, instanceName, pluginInstanceParams);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@RequestParam(value = "alertPluginInstanceId") int alertPluginInstanceId,
|
||||
@RequestParam(value = "instanceName") String instanceName,
|
||||
@RequestParam(value = "pluginInstanceParams") String pluginInstanceParams) {
|
||||
logger.info("login user {},update alert plugin instance id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), alertPluginInstanceId);
|
||||
logger.info("login user {},update alert plugin instance id {}", RegexUtils.escapeNRT(loginUser.getUserName()), alertPluginInstanceId);
|
||||
Map<String, Object> result = alertPluginInstanceService.update(loginUser, alertPluginInstanceId, instanceName, pluginInstanceParams);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@ApiException(DELETE_ALERT_PLUGIN_INSTANCE_ERROR)
|
||||
public Result deleteAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@RequestParam(value = "id") int id) {
|
||||
logger.info("login user {},delete alert plugin instance id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), id);
|
||||
logger.info("login user {},delete alert plugin instance id {}", RegexUtils.escapeNRT(loginUser.getUserName()), id);
|
||||
|
||||
Map<String, Object> result = alertPluginInstanceService.delete(loginUser, id);
|
||||
return returnDataList(result);
|
||||
|
|
@ -157,7 +157,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@ApiException(GET_ALERT_PLUGIN_INSTANCE_ERROR)
|
||||
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@RequestParam(value = "id") int id) {
|
||||
logger.info("login user {},get alert plugin instance, id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), id);
|
||||
logger.info("login user {},get alert plugin instance, id {}", RegexUtils.escapeNRT(loginUser.getUserName()), id);
|
||||
Map<String, Object> result = alertPluginInstanceService.get(loginUser, id);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiException(QUERY_ALL_ALERT_PLUGIN_INSTANCE_ERROR)
|
||||
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
|
||||
logger.info("login user {}, query all alert plugin instance", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()));
|
||||
logger.info("login user {}, query all alert plugin instance", RegexUtils.escapeNRT(loginUser.getUserName()));
|
||||
Map<String, Object> result = alertPluginInstanceService.queryAll();
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
@ResponseStatus(HttpStatus.OK)
|
||||
public Result verifyGroupName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@RequestParam(value = "alertInstanceName") String alertInstanceName) {
|
||||
logger.info("login user {},verify alert instance name: {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(alertInstanceName));
|
||||
logger.info("login user {},verify alert instance name: {}", RegexUtils.escapeNRT(loginUser.getUserName()), RegexUtils.escapeNRT(alertInstanceName));
|
||||
|
||||
boolean exist = alertPluginInstanceService.checkExistPluginInstanceName(alertInstanceName);
|
||||
Result result = new Result();
|
||||
|
|
@ -227,7 +227,7 @@ public class AlertPluginInstanceController extends BaseController {
|
|||
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
logger.info("login user {}, list paging, pageNo: {}, pageSize: {}",StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), pageNo, pageSize);
|
||||
logger.info("login user {}, list paging, pageNo: {}, pageSize: {}", RegexUtils.escapeNRT(loginUser.getUserName()), pageNo, pageSize);
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.common.Constants.COMMA;
|
||||
import static org.apache.dolphinscheduler.common.Constants.HTTP_HEADER_UNKNOWN;
|
||||
import static org.apache.dolphinscheduler.common.Constants.HTTP_X_FORWARDED_FOR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.HTTP_X_REAL_IP;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -23,12 +29,11 @@ import org.apache.dolphinscheduler.common.Constants;
|
|||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.Resource;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.common.Constants.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* base controller
|
||||
|
|
|
|||
|
|
@ -14,33 +14,44 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.COMMAND_STATE_COUNT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_INSTANCE_STATE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUEUE_COUNT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.TASK_INSTANCE_STATE_COUNT_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.DataAnalysisService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
/**
|
||||
* data analysis controller
|
||||
*/
|
||||
@Api(tags = "DATA_ANALYSIS_TAG", position = 1)
|
||||
@Api(tags = "DATA_ANALYSIS_TAG")
|
||||
@RestController
|
||||
@RequestMapping("projects/analysis")
|
||||
public class DataAnalysisController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* data source controller
|
||||
*/
|
||||
@Api(tags = "DATA_SOURCE_TAG", position = 3)
|
||||
@Api(tags = "DATA_SOURCE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("datasources")
|
||||
public class DataSourceController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ import io.swagger.annotations.ApiParam;
|
|||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* execute process controller
|
||||
* executor controller
|
||||
*/
|
||||
@Api(tags = "PROCESS_INSTANCE_EXECUTOR_TAG", position = 1)
|
||||
@Api(tags = "EXECUTOR_TAG")
|
||||
@RestController
|
||||
@RequestMapping("projects/{projectName}/executors")
|
||||
public class ExecutorController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_INSTANCE_LOG_ERROR;
|
||||
|
|
@ -46,11 +46,10 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* log controller
|
||||
* logger controller
|
||||
*/
|
||||
@Api(tags = "LOGGER_TAG", position = 13)
|
||||
@Api(tags = "LOGGER_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
public class LoggerController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.IP_IS_EMPTY;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.SIGN_OUT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.USER_LOGIN_FAILURE;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
|
|
@ -25,28 +29,34 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* user login controller
|
||||
* <p>
|
||||
* swagger bootstrap ui docs refer : https://doc.xiaominfo.com/guide/enh-func.html
|
||||
* login controller
|
||||
*/
|
||||
@Api(tags = "LOGIN_TAG", position = 1)
|
||||
@Api(tags = "LOGIN_TAG")
|
||||
@RestController
|
||||
@RequestMapping("")
|
||||
public class LoginController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,31 +14,40 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.LIST_MASTERS_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.LIST_WORKERS_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_DATABASE_STATE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ZOOKEEPER_STATE_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.MonitorService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
/**
|
||||
* monitor controller
|
||||
*/
|
||||
@Api(tags = "MONITOR_TAG", position = 1)
|
||||
@Api(tags = "MONITOR_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/monitor")
|
||||
public class MonitorController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
|
|||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
|
|
@ -76,11 +77,10 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.annotations.ApiParam;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* process definition controller
|
||||
*/
|
||||
@Api(tags = "PROCESS_DEFINITION_TAG", position = 2)
|
||||
@Api(tags = "PROCESS_DEFINITION_TAG")
|
||||
@RestController
|
||||
@RequestMapping("projects/{projectName}/process")
|
||||
public class ProcessDefinitionController extends BaseController {
|
||||
|
|
@ -154,10 +154,10 @@ public class ProcessDefinitionController extends BaseController {
|
|||
@RequestParam(value = "processDefinitionIds", required = true) String processDefinitionIds,
|
||||
@RequestParam(value = "targetProjectId", required = true) int targetProjectId) {
|
||||
logger.info("batch copy process definition, login user:{}, project name:{}, process definition ids:{},target project id:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(projectName),
|
||||
StringUtils.replaceNRTtoUnderline(processDefinitionIds),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(targetProjectId)));
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()),
|
||||
RegexUtils.escapeNRT(projectName),
|
||||
RegexUtils.escapeNRT(processDefinitionIds),
|
||||
RegexUtils.escapeNRT(String.valueOf(targetProjectId)));
|
||||
|
||||
return returnDataList(
|
||||
processDefinitionService.batchCopyProcessDefinition(loginUser, projectName, processDefinitionIds, targetProjectId));
|
||||
|
|
@ -185,10 +185,10 @@ public class ProcessDefinitionController extends BaseController {
|
|||
@RequestParam(value = "processDefinitionIds", required = true) String processDefinitionIds,
|
||||
@RequestParam(value = "targetProjectId", required = true) int targetProjectId) {
|
||||
logger.info("batch move process definition, login user:{}, project name:{}, process definition ids:{},target project id:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(projectName),
|
||||
StringUtils.replaceNRTtoUnderline(processDefinitionIds),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(targetProjectId)));
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()),
|
||||
RegexUtils.escapeNRT(projectName),
|
||||
RegexUtils.escapeNRT(processDefinitionIds),
|
||||
RegexUtils.escapeNRT(String.valueOf(targetProjectId)));
|
||||
|
||||
return returnDataList(
|
||||
processDefinitionService.batchMoveProcessDefinition(loginUser, projectName, processDefinitionIds, targetProjectId));
|
||||
|
|
|
|||
|
|
@ -14,8 +14,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.BATCH_DELETE_PROCESS_INSTANCE_BY_IDS_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROCESS_INSTANCE_BY_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PARENT_PROCESS_INSTANCE_DETAIL_INFO_BY_SUB_PROCESS_INSTANCE_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_INSTANCE_ALL_VARIABLES_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_INSTANCE_BY_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROCESS_INSTANCE_LIST_PAGING_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SUB_PROCESS_INSTANCE_DETAIL_INFO_BY_TASK_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_BY_PROCESS_INSTANCE_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROCESS_INSTANCE_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessInstanceService;
|
||||
|
|
@ -27,13 +39,6 @@ import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
|||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
|
@ -42,12 +47,30 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* process instance controller
|
||||
*/
|
||||
@Api(tags = "PROCESS_INSTANCE_TAG", position = 10)
|
||||
@Api(tags = "PROCESS_INSTANCE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("projects/{projectName}/instance")
|
||||
public class ProcessInstanceController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,37 +14,53 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROJECT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROJECT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.IMPORT_PROCESS_DEFINE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.LOGIN_USER_QUERY_PROJECT_LIST_PAGING_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_AND_USER_CREATED_PROJECT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_PROJECT;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROJECT_DETAILS_BY_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_UNAUTHORIZED_PROJECT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROJECT_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
/**
|
||||
* project controller
|
||||
*/
|
||||
@Api(tags = "PROJECT_TAG", position = 1)
|
||||
@Api(tags = "PROJECT_TAG")
|
||||
@RestController
|
||||
@RequestMapping("projects")
|
||||
public class ProjectController extends BaseController {
|
||||
|
|
@ -239,8 +255,8 @@ public class ProjectController extends BaseController {
|
|||
@ApiException(QUERY_AUTHORIZED_AND_USER_CREATED_PROJECT_ERROR)
|
||||
public Result queryProjectCreatedAndAuthorizedByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
|
||||
logger.info("login user {}, query authorized and user created project by user id: {}.",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
|
||||
StringUtils.replaceNRTtoUnderline(String.valueOf(loginUser.getId())));
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()),
|
||||
RegexUtils.escapeNRT(String.valueOf(loginUser.getId())));
|
||||
Map<String, Object> result = projectService.queryProjectCreatedAndAuthorizedByUser(loginUser);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_QUEUE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_QUEUE_LIST_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_QUEUE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_QUEUE_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
|
|
@ -24,26 +29,31 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
|
||||
/**
|
||||
* queue controller
|
||||
*/
|
||||
@Api(tags = "QUEUE_TAG", position = 1)
|
||||
@Api(tags = "QUEUE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/queue")
|
||||
public class QueueController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* resources controller
|
||||
*/
|
||||
@Api(tags = "RESOURCES_TAG", position = 1)
|
||||
@Api(tags = "RESOURCES_TAG")
|
||||
@RestController
|
||||
@RequestMapping("resources")
|
||||
public class ResourcesController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
|
|||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.SchedulerService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
import org.apache.dolphinscheduler.common.enums.WarningType;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -61,9 +61,9 @@ import io.swagger.annotations.ApiParam;
|
|||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* schedule controller
|
||||
* scheduler controller
|
||||
*/
|
||||
@Api(tags = "SCHEDULER_TAG", position = 13)
|
||||
@Api(tags = "SCHEDULER_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/projects/{projectName}/schedule")
|
||||
public class SchedulerController extends BaseController {
|
||||
|
|
@ -116,7 +116,7 @@ public class SchedulerController extends BaseController {
|
|||
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
|
||||
logger.info("login user {},project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {},"
|
||||
+ "failure policy: {},processInstancePriority : {}, workGroupId:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(projectName), processDefinitionId, schedule, warningType, warningGroupId,
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()), RegexUtils.escapeNRT(projectName), processDefinitionId, schedule, warningType, warningGroupId,
|
||||
failureStrategy, processInstancePriority, workerGroup);
|
||||
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule,
|
||||
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
|
||||
|
|
@ -161,7 +161,7 @@ public class SchedulerController extends BaseController {
|
|||
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
|
||||
logger.info("login user {},project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, "
|
||||
+ "failure policy: {},processInstancePriority : {},workerGroupId:{}",
|
||||
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(projectName), id, schedule, warningType, warningGroupId, failureStrategy,
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()), RegexUtils.escapeNRT(projectName), id, schedule, warningType, warningGroupId, failureStrategy,
|
||||
processInstancePriority, workerGroup);
|
||||
|
||||
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule,
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGIN
|
|||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -54,7 +54,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
/**
|
||||
* task instance controller
|
||||
*/
|
||||
@Api(tags = "TASK_INSTANCE_TAG", position = 11)
|
||||
@Api(tags = "TASK_INSTANCE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/projects/{projectName}/task-instance")
|
||||
public class TaskInstanceController extends BaseController {
|
||||
|
|
@ -64,7 +64,6 @@ public class TaskInstanceController extends BaseController {
|
|||
@Autowired
|
||||
TaskInstanceService taskInstanceService;
|
||||
|
||||
|
||||
/**
|
||||
* query task list paging
|
||||
*
|
||||
|
|
@ -113,16 +112,16 @@ public class TaskInstanceController extends BaseController {
|
|||
@RequestParam("pageSize") Integer pageSize) {
|
||||
|
||||
logger.info("query task instance list, projectName:{}, processInstanceId:{}, processInstanceName:{}, search value:{}, taskName:{}, executorName: {}, stateType:{}, host:{}, start:{}, end:{}",
|
||||
StringUtils.replaceNRTtoUnderline(projectName),
|
||||
RegexUtils.escapeNRT(projectName),
|
||||
processInstanceId,
|
||||
StringUtils.replaceNRTtoUnderline(processInstanceName),
|
||||
StringUtils.replaceNRTtoUnderline(searchVal),
|
||||
StringUtils.replaceNRTtoUnderline(taskName),
|
||||
StringUtils.replaceNRTtoUnderline(executorName),
|
||||
RegexUtils.escapeNRT(processInstanceName),
|
||||
RegexUtils.escapeNRT(searchVal),
|
||||
RegexUtils.escapeNRT(taskName),
|
||||
RegexUtils.escapeNRT(executorName),
|
||||
stateType,
|
||||
StringUtils.replaceNRTtoUnderline(host),
|
||||
StringUtils.replaceNRTtoUnderline(startTime),
|
||||
StringUtils.replaceNRTtoUnderline(endTime));
|
||||
RegexUtils.escapeNRT(host),
|
||||
RegexUtils.escapeNRT(startTime),
|
||||
RegexUtils.escapeNRT(endTime));
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
Map<String, Object> result = taskInstanceService.queryTaskListPaging(
|
||||
loginUser, projectName, processInstanceId, processInstanceName, taskName, executorName, startTime, endTime, searchVal, stateType, host, pageNo, pageSize);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_RECORD_LIST_PAGING_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.TaskRecordService;
|
||||
|
|
@ -23,20 +25,23 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
/**
|
||||
* data quality controller
|
||||
* task record controller
|
||||
*/
|
||||
@ApiIgnore
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_OS_TENANT_CODE
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.TenantService;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
|
|
@ -53,18 +53,16 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* tenant controller
|
||||
*/
|
||||
@Api(tags = "TENANT_TAG", position = 1)
|
||||
@Api(tags = "TENANT_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/tenant")
|
||||
public class TenantController extends BaseController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TenantController.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private TenantService tenantService;
|
||||
|
||||
|
|
@ -91,15 +89,13 @@ public class TenantController extends BaseController {
|
|||
@RequestParam(value = "tenantCode") String tenantCode,
|
||||
@RequestParam(value = "queueId") int queueId,
|
||||
@RequestParam(value = "description", required = false) String description) throws Exception {
|
||||
String userReplace = StringUtils.replaceNRTtoUnderline(loginUser.getUserName());
|
||||
String tenantCodeReplace = StringUtils.replaceNRTtoUnderline(tenantCode);
|
||||
String descReplace = StringUtils.replaceNRTtoUnderline(description);
|
||||
logger.info("login user {}, create tenant, tenantCode: {}, queueId: {}, desc: {}", userReplace, tenantCodeReplace, queueId, descReplace);
|
||||
logger.info("login user {}, create tenant, tenantCode: {}, queueId: {}, desc: {}",
|
||||
RegexUtils.escapeNRT(loginUser.getUserName()), RegexUtils.escapeNRT(tenantCode),
|
||||
queueId, RegexUtils.escapeNRT(description));
|
||||
Map<String, Object> result = tenantService.createTenant(loginUser, tenantCode, queueId, description);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* query tenant list paging
|
||||
*
|
||||
|
|
@ -177,9 +173,9 @@ public class TenantController extends BaseController {
|
|||
@RequestParam(value = "tenantCode") String tenantCode,
|
||||
@RequestParam(value = "queueId") int queueId,
|
||||
@RequestParam(value = "description", required = false) String description) throws Exception {
|
||||
String userReplace = StringUtils.replaceNRTtoUnderline(loginUser.getUserName());
|
||||
String tenantCodeReplace = StringUtils.replaceNRTtoUnderline(tenantCode);
|
||||
String descReplace = StringUtils.replaceNRTtoUnderline(description);
|
||||
String userReplace = RegexUtils.escapeNRT(loginUser.getUserName());
|
||||
String tenantCodeReplace = RegexUtils.escapeNRT(tenantCode);
|
||||
String descReplace = RegexUtils.escapeNRT(description);
|
||||
logger.info("login user {}, create tenant, tenantCode: {}, queueId: {}, desc: {}", userReplace, tenantCodeReplace, queueId, descReplace);
|
||||
Map<String, Object> result = tenantService.updateTenant(loginUser, id, tenantCode, queueId, description);
|
||||
return returnDataList(result);
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ import io.swagger.annotations.ApiOperation;
|
|||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* UiPluginController
|
||||
* ui plugin controller
|
||||
* Some plugins (such as alert plugin) need to provide UI interfaces to users.
|
||||
* We use from-creat to dynamically generate UI interfaces. Related parameters are mainly provided by pluginParams.
|
||||
* From-create can generate dynamic ui based on this parameter.
|
||||
*/
|
||||
@Api(tags = "UI_PLUGINS", position = 1)
|
||||
@Api(tags = "UI_PLUGINS_TAG")
|
||||
@RestController
|
||||
@RequestMapping("ui-plugins")
|
||||
public class UiPluginController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,22 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_USER_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_USER_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_USER_BY_ID_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.GET_USER_INFO_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.GRANT_DATASOURCE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.GRANT_PROJECT_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.GRANT_RESOURCE_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.GRANT_UDF_FUNCTION_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_USER_LIST_PAGING_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_USER_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_USER_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.USER_LIST_ERROR;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_USERNAME_ERROR;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
|
|
@ -24,28 +38,34 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* user controller
|
||||
* users controller
|
||||
*/
|
||||
@Api(tags = "USERS_TAG", position = 14)
|
||||
@Api(tags = "USERS_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
public class UsersController extends BaseController {
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_LINEAGE_ERROR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
|
||||
|
||||
import org.apache.dolphinscheduler.api.service.WorkFlowLineageService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -24,21 +26,31 @@ import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
|||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.entity.WorkFlowLineage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_LINEAGE_ERROR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* work flow lineage controller
|
||||
*/
|
||||
@Api(tags = "WORK_FLOW_LINEAGE_TAG")
|
||||
@RestController
|
||||
@RequestMapping("lineages/{projectId}")
|
||||
public class WorkFlowLineageController extends BaseController {
|
||||
|
|
@ -47,7 +59,7 @@ public class WorkFlowLineageController extends BaseController {
|
|||
@Autowired
|
||||
private WorkFlowLineageService workFlowLineageService;
|
||||
|
||||
@GetMapping(value="/list-name")
|
||||
@GetMapping(value = "/list-name")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public Result<List<WorkFlowLineage>> queryWorkFlowLineageByName(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectId", value = "PROJECT_ID", required = true, example = "1") @PathVariable int projectId,
|
||||
|
|
@ -56,32 +68,30 @@ public class WorkFlowLineageController extends BaseController {
|
|||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
Map<String, Object> result = workFlowLineageService.queryWorkFlowLineageByName(searchVal,projectId);
|
||||
return returnDataList(result);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
logger.error(QUERY_WORKFLOW_LINEAGE_ERROR.getMsg(),e);
|
||||
return error(QUERY_WORKFLOW_LINEAGE_ERROR.getCode(), QUERY_WORKFLOW_LINEAGE_ERROR.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value="/list-ids")
|
||||
@GetMapping(value = "/list-ids")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public Result<Map<String, Object>> queryWorkFlowLineageByIds(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectId", value = "PROJECT_ID", required = true, example = "1") @PathVariable int projectId,
|
||||
@ApiIgnore @RequestParam(value = "ids", required = false) String ids) {
|
||||
|
||||
try {
|
||||
ids = ParameterUtils.handleEscapes(ids);
|
||||
Set<Integer> idsSet = new HashSet<>();
|
||||
if(ids != null) {
|
||||
if (ids != null) {
|
||||
String[] idsStr = ids.split(",");
|
||||
for (String id : idsStr)
|
||||
{
|
||||
for (String id : idsStr) {
|
||||
idsSet.add(Integer.parseInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = workFlowLineageService.queryWorkFlowLineageByIds(idsSet, projectId);
|
||||
return returnDataList(result);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
logger.error(QUERY_WORKFLOW_LINEAGE_ERROR.getMsg(),e);
|
||||
return error(QUERY_WORKFLOW_LINEAGE_ERROR.getCode(), QUERY_WORKFLOW_LINEAGE_ERROR.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKER_GROUP_FAIL;
|
||||
|
||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
||||
|
|
@ -23,25 +25,30 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.enums.Status.*;
|
||||
|
||||
/**
|
||||
* worker group controller
|
||||
*/
|
||||
@Api(tags = "WORKER_GROUP_TAG", position = 1)
|
||||
@Api(tags = "WORKER_GROUP_TAG")
|
||||
@RestController
|
||||
@RequestMapping("/worker-group")
|
||||
public class WorkerGroupController extends BaseController {
|
||||
|
|
@ -51,9 +58,6 @@ public class WorkerGroupController extends BaseController {
|
|||
@Autowired
|
||||
WorkerGroupService workerGroupService;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* query worker groups paging
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
|
|
|||
|
|
@ -14,23 +14,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* base service
|
||||
*/
|
||||
public class BaseService {
|
||||
public interface BaseService {
|
||||
|
||||
/**
|
||||
* check admin
|
||||
|
|
@ -38,9 +35,7 @@ public class BaseService {
|
|||
* @param user input user
|
||||
* @return ture if administrator, otherwise return false
|
||||
*/
|
||||
protected boolean isAdmin(User user) {
|
||||
return user.getUserType() == UserType.ADMIN_USER;
|
||||
}
|
||||
boolean isAdmin(User user);
|
||||
|
||||
/**
|
||||
* isNotAdmin
|
||||
|
|
@ -49,14 +44,7 @@ public class BaseService {
|
|||
* @param result result code
|
||||
* @return true if not administrator, otherwise false
|
||||
*/
|
||||
protected boolean isNotAdmin(User loginUser, Map<String, Object> result) {
|
||||
//only admin can operate
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
boolean isNotAdmin(User loginUser, Map<String, Object> result);
|
||||
|
||||
/**
|
||||
* put message to map
|
||||
|
|
@ -65,14 +53,7 @@ public class BaseService {
|
|||
* @param status status
|
||||
* @param statusParams status message
|
||||
*/
|
||||
protected void putMsg(Map<String, Object> result, Status status, Object... statusParams) {
|
||||
result.put(Constants.STATUS, status);
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams));
|
||||
} else {
|
||||
result.put(Constants.MSG, status.getMsg());
|
||||
}
|
||||
}
|
||||
void putMsg(Map<String, Object> result, Status status, Object... statusParams);
|
||||
|
||||
/**
|
||||
* put message to result object
|
||||
|
|
@ -81,16 +62,7 @@ public class BaseService {
|
|||
* @param status status
|
||||
* @param statusParams status message
|
||||
*/
|
||||
protected void putMsg(Result result, Status status, Object... statusParams) {
|
||||
result.setCode(status.getCode());
|
||||
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
result.setMsg(MessageFormat.format(status.getMsg(), statusParams));
|
||||
} else {
|
||||
result.setMsg(status.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
void putMsg(Result<Object> result, Status status, Object... statusParams);
|
||||
|
||||
/**
|
||||
* check
|
||||
|
|
@ -100,15 +72,7 @@ public class BaseService {
|
|||
* @param userNoOperationPerm status
|
||||
* @return check result
|
||||
*/
|
||||
protected boolean check(Map<String, Object> result, boolean bool, Status userNoOperationPerm) {
|
||||
//only admin can operate
|
||||
if (bool) {
|
||||
result.put(Constants.STATUS, userNoOperationPerm);
|
||||
result.put(Constants.MSG, userNoOperationPerm.getMsg());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
boolean check(Map<String, Object> result, boolean bool, Status userNoOperationPerm);
|
||||
|
||||
/**
|
||||
* create tenant dir if not exists
|
||||
|
|
@ -116,18 +80,13 @@ public class BaseService {
|
|||
* @param tenantCode tenant code
|
||||
* @throws IOException if hdfs operation exception
|
||||
*/
|
||||
protected void createTenantDirIfNotExists(String tenantCode) throws IOException {
|
||||
void createTenantDirIfNotExists(String tenantCode) throws IOException;
|
||||
|
||||
String resourcePath = HadoopUtils.getHdfsResDir(tenantCode);
|
||||
String udfsPath = HadoopUtils.getHdfsUdfDir(tenantCode);
|
||||
/**
|
||||
* init resource path and udf path
|
||||
*/
|
||||
HadoopUtils.getInstance().mkdir(resourcePath);
|
||||
HadoopUtils.getInstance().mkdir(udfsPath);
|
||||
}
|
||||
|
||||
protected boolean hasPerm(User operateUser, int createUserId) {
|
||||
return operateUser.getId() == createUserId || isAdmin(operateUser);
|
||||
}
|
||||
/**
|
||||
* has perm
|
||||
*
|
||||
* @param operateUser operate user
|
||||
* @param createUserId create user id
|
||||
*/
|
||||
boolean hasPerm(User operateUser, int createUserId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* datasource service
|
||||
* data source service
|
||||
*/
|
||||
public interface DataSourceService {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
||||
/**
|
||||
* log service
|
||||
* logger service
|
||||
*/
|
||||
public interface LoggerService {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* process definition version service
|
||||
*/
|
||||
public interface ProcessDefinitionVersionService {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.Project;
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.Session;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* session service
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* udf function service
|
||||
* udf func service
|
||||
*/
|
||||
public interface UdfFuncService {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.apache.dolphinscheduler.common.enums.PluginType;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* UiPluginService
|
||||
* ui plugin service
|
||||
*/
|
||||
public interface UiPluginService {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* work group service
|
||||
* worker group service
|
||||
*/
|
||||
public interface WorkerGroupService {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
|
|
@ -44,7 +44,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* access token service impl
|
||||
*/
|
||||
@Service
|
||||
public class AccessTokenServiceImpl extends BaseService implements AccessTokenService {
|
||||
public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTokenService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
|
|
@ -44,7 +43,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* alert group service impl
|
||||
*/
|
||||
@Service
|
||||
public class AlertGroupServiceImpl extends BaseService implements AlertGroupService {
|
||||
public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroupService {
|
||||
|
||||
@Autowired
|
||||
private AlertGroupMapper alertGroupMapper;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -54,7 +53,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
*/
|
||||
@Service
|
||||
@Lazy
|
||||
public class AlertPluginInstanceServiceImpl extends BaseService implements AlertPluginInstanceService {
|
||||
public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements AlertPluginInstanceService {
|
||||
|
||||
@Autowired
|
||||
private AlertPluginInstanceMapper alertPluginInstanceMapper;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* base service impl
|
||||
*/
|
||||
public class BaseServiceImpl implements BaseService {
|
||||
|
||||
/**
|
||||
* check admin
|
||||
*
|
||||
* @param user input user
|
||||
* @return ture if administrator, otherwise return false
|
||||
*/
|
||||
public boolean isAdmin(User user) {
|
||||
return user.getUserType() == UserType.ADMIN_USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* isNotAdmin
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param result result code
|
||||
* @return true if not administrator, otherwise false
|
||||
*/
|
||||
public boolean isNotAdmin(User loginUser, Map<String, Object> result) {
|
||||
//only admin can operate
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* put message to map
|
||||
*
|
||||
* @param result result code
|
||||
* @param status status
|
||||
* @param statusParams status message
|
||||
*/
|
||||
public void putMsg(Map<String, Object> result, Status status, Object... statusParams) {
|
||||
result.put(Constants.STATUS, status);
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams));
|
||||
} else {
|
||||
result.put(Constants.MSG, status.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* put message to result object
|
||||
*
|
||||
* @param result result code
|
||||
* @param status status
|
||||
* @param statusParams status message
|
||||
*/
|
||||
public void putMsg(Result result, Status status, Object... statusParams) {
|
||||
result.setCode(status.getCode());
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
result.setMsg(MessageFormat.format(status.getMsg(), statusParams));
|
||||
} else {
|
||||
result.setMsg(status.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check
|
||||
*
|
||||
* @param result result
|
||||
* @param bool bool
|
||||
* @param userNoOperationPerm status
|
||||
* @return check result
|
||||
*/
|
||||
public boolean check(Map<String, Object> result, boolean bool, Status userNoOperationPerm) {
|
||||
// only admin can operate
|
||||
if (bool) {
|
||||
result.put(Constants.STATUS, userNoOperationPerm);
|
||||
result.put(Constants.MSG, userNoOperationPerm.getMsg());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* create tenant dir if not exists
|
||||
*
|
||||
* @param tenantCode tenant code
|
||||
* @throws IOException if hdfs operation exception
|
||||
*/
|
||||
public void createTenantDirIfNotExists(String tenantCode) throws IOException {
|
||||
String resourcePath = HadoopUtils.getHdfsResDir(tenantCode);
|
||||
String udfsPath = HadoopUtils.getHdfsUdfDir(tenantCode);
|
||||
// init resource path and udf path
|
||||
HadoopUtils.getInstance().mkdir(resourcePath);
|
||||
HadoopUtils.getInstance().mkdir(udfsPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* has perm
|
||||
*
|
||||
* @param operateUser operate user
|
||||
* @param createUserId create user id
|
||||
*/
|
||||
public boolean hasPerm(User operateUser, int createUserId) {
|
||||
return operateUser.getId() == createUserId || isAdmin(operateUser);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.dto.CommandStateCount;
|
||||
import org.apache.dolphinscheduler.api.dto.DefineUserDto;
|
||||
import org.apache.dolphinscheduler.api.dto.TaskCountDto;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.DataAnalysisService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -60,7 +60,7 @@ import org.springframework.stereotype.Service;
|
|||
* data analysis service impl
|
||||
*/
|
||||
@Service
|
||||
public class DataAnalysisServiceImpl extends BaseService implements DataAnalysisService {
|
||||
public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnalysisService {
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.DataSourceService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -57,10 +56,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
/**
|
||||
* datasource service impl
|
||||
* data source service impl
|
||||
*/
|
||||
@Service
|
||||
public class DataSourceServiceImpl extends BaseService implements DataSourceService {
|
||||
public class DataSourceServiceImpl extends BaseServiceImpl implements DataSourceService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.ExecuteType;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ExecutorService;
|
||||
import org.apache.dolphinscheduler.api.service.MonitorService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
|
|
@ -73,7 +72,7 @@ import org.springframework.stereotype.Service;
|
|||
* executor service impl
|
||||
*/
|
||||
@Service
|
||||
public class ExecutorServiceImpl extends BaseService implements ExecutorService {
|
||||
public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -41,7 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* log service
|
||||
* logger service impl
|
||||
*/
|
||||
@Service
|
||||
public class LoggerServiceImpl implements LoggerService {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
import static org.apache.dolphinscheduler.common.utils.Preconditions.checkNotNull;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.MonitorService;
|
||||
import org.apache.dolphinscheduler.api.utils.ZookeeperMonitor;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -47,7 +46,7 @@ import com.google.common.collect.Sets;
|
|||
* monitor service impl
|
||||
*/
|
||||
@Service
|
||||
public class MonitorServiceImpl extends BaseService implements MonitorService {
|
||||
public class MonitorServiceImpl extends BaseServiceImpl implements MonitorService {
|
||||
|
||||
@Autowired
|
||||
private ZookeeperMonitor zookeeperMonitor;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.apache.dolphinscheduler.api.dto.ProcessMeta;
|
|||
import org.apache.dolphinscheduler.api.dto.treeview.Instance;
|
||||
import org.apache.dolphinscheduler.api.dto.treeview.TreeViewDto;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessInstanceService;
|
||||
|
|
@ -111,8 +110,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|||
* process definition service impl
|
||||
*/
|
||||
@Service
|
||||
public class ProcessDefinitionServiceImpl extends BaseService implements
|
||||
ProcessDefinitionService {
|
||||
public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements ProcessDefinitionService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionVersionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
|
|
@ -42,9 +41,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* process definition version service impl
|
||||
*/
|
||||
@Service
|
||||
public class ProcessDefinitionVersionServiceImpl extends BaseService implements
|
||||
ProcessDefinitionVersionService {
|
||||
public class ProcessDefinitionVersionServiceImpl extends BaseServiceImpl implements ProcessDefinitionVersionService {
|
||||
|
||||
@Autowired
|
||||
private ProcessDefinitionVersionMapper processDefinitionVersionMapper;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import static org.apache.dolphinscheduler.common.Constants.TASK_LIST;
|
|||
import org.apache.dolphinscheduler.api.dto.gantt.GanttDto;
|
||||
import org.apache.dolphinscheduler.api.dto.gantt.Task;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ExecutorService;
|
||||
import org.apache.dolphinscheduler.api.service.LoggerService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
||||
|
|
@ -94,7 +93,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* process instance service impl
|
||||
*/
|
||||
@Service
|
||||
public class ProcessInstanceServiceImpl extends BaseService implements ProcessInstanceService {
|
||||
public class ProcessInstanceServiceImpl extends BaseServiceImpl implements ProcessInstanceService {
|
||||
|
||||
@Autowired
|
||||
ProjectMapper projectMapper;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
import static org.apache.dolphinscheduler.api.utils.CheckUtils.checkDesc;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -48,10 +47,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* project service implement
|
||||
* project service impl
|
||||
**/
|
||||
@Service
|
||||
public class ProjectServiceImpl extends BaseService implements ProjectService {
|
||||
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService {
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.QueueService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -47,7 +46,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* queue service impl
|
||||
*/
|
||||
@Service
|
||||
public class QueueServiceImpl extends BaseService implements QueueService {
|
||||
public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(QueueServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor
|
|||
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ResourcesService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
|
|
@ -86,7 +85,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
|||
* resources service impl
|
||||
*/
|
||||
@Service
|
||||
public class ResourcesServiceImpl extends BaseService implements ResourcesService {
|
||||
public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
import org.apache.dolphinscheduler.api.dto.ScheduleParam;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ExecutorService;
|
||||
import org.apache.dolphinscheduler.api.service.MonitorService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
|
|
@ -69,7 +68,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* scheduler service impl
|
||||
*/
|
||||
@Service
|
||||
public class SchedulerServiceImpl extends BaseService implements SchedulerService {
|
||||
public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SchedulerServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@
|
|||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.controller.BaseController;
|
||||
import org.apache.dolphinscheduler.api.service.SessionService;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.Session;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.mapper.SessionMapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
|
@ -24,15 +33,6 @@ import java.util.UUID;
|
|||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.dolphinscheduler.api.controller.BaseController;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.SessionService;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.Session;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.mapper.SessionMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -44,7 +44,7 @@ import org.springframework.web.util.WebUtils;
|
|||
* session service implement
|
||||
*/
|
||||
@Service
|
||||
public class SessionServiceImpl extends BaseService implements SessionService {
|
||||
public class SessionServiceImpl extends BaseServiceImpl implements SessionService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SessionService.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.ProcessInstanceService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
||||
|
|
@ -54,7 +53,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* task instance service impl
|
||||
*/
|
||||
@Service
|
||||
public class TaskInstanceServiceImpl extends BaseService implements TaskInstanceService {
|
||||
public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInstanceService {
|
||||
|
||||
@Autowired
|
||||
ProjectMapper projectMapper;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import static org.apache.dolphinscheduler.common.Constants.TASK_RECORD_TABLE_HIS
|
|||
import static org.apache.dolphinscheduler.common.Constants.TASK_RECORD_TABLE_HIVE_LOG;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.TaskRecordService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -38,7 +37,7 @@ import org.springframework.stereotype.Service;
|
|||
* task record service impl
|
||||
*/
|
||||
@Service
|
||||
public class TaskRecordServiceImpl extends BaseService implements TaskRecordService {
|
||||
public class TaskRecordServiceImpl extends BaseServiceImpl implements TaskRecordService {
|
||||
|
||||
/**
|
||||
* query task record list paging
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.TenantService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.RegexUtils;
|
||||
|
|
@ -42,8 +41,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -52,12 +49,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* tenant service
|
||||
* tenant service impl
|
||||
*/
|
||||
@Service
|
||||
public class TenantServiceImpl extends BaseService implements TenantService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TenantServiceImpl.class);
|
||||
public class TenantServiceImpl extends BaseServiceImpl implements TenantService {
|
||||
|
||||
@Autowired
|
||||
private TenantMapper tenantMapper;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.UdfFuncService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -48,10 +47,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* udf function service impl
|
||||
* udf func service impl
|
||||
*/
|
||||
@Service
|
||||
public class UdfFuncServiceImpl extends BaseService implements UdfFuncService {
|
||||
public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UdfFuncServiceImpl.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.UiPluginService;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.PluginType;
|
||||
|
|
@ -34,20 +33,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* UiPluginServiceImpl
|
||||
* ui plugin service impl
|
||||
*/
|
||||
@Service
|
||||
public class UiPluginServiceImpl extends BaseService implements UiPluginService {
|
||||
public class UiPluginServiceImpl extends BaseServiceImpl implements UiPluginService {
|
||||
|
||||
@Autowired
|
||||
PluginDefineMapper pluginDefineMapper;
|
||||
|
||||
private static final String LANGUAGE_REGEX = "\"([^\"]*)\"";
|
||||
|
||||
private static final String LANGUAGE_SYMBOL = "$t";
|
||||
|
||||
private static final String ESCAPE_SYMBOL = "\\";
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryUiPluginsByType(PluginType pluginType) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
|||
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.UsersService;
|
||||
import org.apache.dolphinscheduler.api.utils.CheckUtils;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
|
|
@ -78,7 +77,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* users service impl
|
||||
*/
|
||||
@Service
|
||||
public class UsersServiceImpl extends BaseService implements UsersService {
|
||||
public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class);
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ public class UsersServiceImpl extends BaseService implements UsersService {
|
|||
private ProjectUserMapper projectUserMapper;
|
||||
|
||||
@Autowired
|
||||
private ResourceUserMapper resourcesUserMapper;
|
||||
private ResourceUserMapper resourceUserMapper;
|
||||
|
||||
@Autowired
|
||||
private ResourceMapper resourceMapper;
|
||||
|
|
@ -600,7 +599,7 @@ public class UsersServiceImpl extends BaseService implements UsersService {
|
|||
|
||||
}
|
||||
|
||||
resourcesUserMapper.deleteResourceUser(userId, 0);
|
||||
resourceUserMapper.deleteResourceUser(userId, 0);
|
||||
|
||||
if (check(result, StringUtils.isEmpty(resourceIds), Status.SUCCESS)) {
|
||||
return result;
|
||||
|
|
@ -625,7 +624,7 @@ public class UsersServiceImpl extends BaseService implements UsersService {
|
|||
|
||||
resourcesUser.setCreateTime(now);
|
||||
resourcesUser.setUpdateTime(now);
|
||||
resourcesUserMapper.insert(resourcesUser);
|
||||
resourceUserMapper.insert(resourcesUser);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.WorkFlowLineageService;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.dao.entity.WorkFlowLineage;
|
||||
|
|
@ -39,7 +38,7 @@ import org.springframework.stereotype.Service;
|
|||
* work flow lineage service impl
|
||||
*/
|
||||
@Service
|
||||
public class WorkFlowLineageServiceImpl extends BaseService implements WorkFlowLineageService {
|
||||
public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkFlowLineageService {
|
||||
|
||||
@Autowired
|
||||
private WorkFlowLineageMapper workFlowLineageMapper;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.BaseService;
|
||||
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -44,10 +43,10 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
|
||||
/**
|
||||
* work group service impl
|
||||
* worker group service impl
|
||||
*/
|
||||
@Service
|
||||
public class WorkerGroupServiceImpl extends BaseService implements WorkerGroupService {
|
||||
public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGroupService {
|
||||
|
||||
private static final String NO_NODE_EXCEPTION_REGEX = "KeeperException$NoNodeException";
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
|
|
@ -21,10 +22,12 @@ import org.apache.dolphinscheduler.api.service.SessionService;
|
|||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.junit.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
|
@ -32,12 +35,14 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
|
||||
/**
|
||||
* abstract controller test
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ApiApplicationServer.class)
|
||||
public class AbstractControllerTest {
|
||||
private static Logger logger = LoggerFactory.getLogger(AbstractControllerTest.class);
|
||||
|
||||
public static final String SESSION_ID = "sessionId";
|
||||
|
||||
protected MockMvc mockMvc;
|
||||
|
|
@ -49,6 +54,7 @@ public class AbstractControllerTest {
|
|||
private SessionService sessionService;
|
||||
|
||||
protected User user;
|
||||
|
||||
protected String sessionId;
|
||||
|
||||
@Before
|
||||
|
|
@ -57,13 +63,11 @@ public class AbstractControllerTest {
|
|||
createSession();
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
sessionService.signOut("127.0.0.1", user);
|
||||
}
|
||||
|
||||
|
||||
private void createSession(){
|
||||
|
||||
User loginUser = new User();
|
||||
|
|
|
|||
|
|
@ -14,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,16 +35,12 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* access token controller test
|
||||
*/
|
||||
public class AccessTokenControllerTest extends AbstractControllerTest{
|
||||
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
|
||||
|
||||
@Test
|
||||
public void testCreateToken() throws Exception {
|
||||
|
|
|
|||
|
|
@ -17,10 +17,16 @@
|
|||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.AlertType;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -30,12 +36,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* alert group controller test
|
||||
*/
|
||||
public class AlertGroupControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertGroupController.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,37 +14,32 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* data analysis controller test
|
||||
*/
|
||||
public class DataAnalysisControllerTest extends AbstractControllerTest{
|
||||
private static Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class);
|
||||
|
||||
@Test
|
||||
public void testCountTaskState() throws Exception {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -29,12 +36,6 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
|
||||
/**
|
||||
* data source controller test
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.springframework.util.MultiValueMap;
|
|||
* executor controller test
|
||||
*/
|
||||
public class ExecutorControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ExecutorControllerTest.class);
|
||||
|
||||
@Ignore
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -28,15 +34,10 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
|
||||
|
||||
/**
|
||||
* logger controller test
|
||||
*/
|
||||
|
||||
@Ignore
|
||||
public class LoggerControllerTest extends AbstractControllerTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,16 +34,12 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* login controller test
|
||||
*/
|
||||
public class LoginControllerTest extends AbstractControllerTest{
|
||||
private static Logger logger = LoggerFactory.getLogger(LoginControllerTest.class);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(LoginControllerTest.class);
|
||||
|
||||
@Test
|
||||
public void testLogin() throws Exception {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -26,10 +32,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* monitor controller test
|
||||
*/
|
||||
|
|
@ -37,7 +39,6 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MonitorControllerTest.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void testListMaster() throws Exception {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -29,17 +36,12 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* project controller
|
||||
* project controller test
|
||||
*/
|
||||
public class ProjectControllerTest extends AbstractControllerTest{
|
||||
private static Logger logger = LoggerFactory.getLogger(ProjectControllerTest.class);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ProjectControllerTest.class);
|
||||
|
||||
@Test
|
||||
public void testCreateProject() throws Exception {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,11 +35,6 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* queue controller test
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,13 +14,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.ResourceType;
|
||||
import org.apache.dolphinscheduler.common.enums.UdfType;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -30,15 +37,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* resources controller test
|
||||
*/
|
||||
public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourcesControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,14 +14,21 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.WarningType;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -31,15 +38,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* scheduler controller test
|
||||
*/
|
||||
public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,11 +34,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* task record controller test
|
||||
*/
|
||||
public class TaskRecordControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskRecordControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,15 +35,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* tenant controller test
|
||||
*/
|
||||
public class TenantControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TenantControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,11 +14,21 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,18 +38,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* users controller test
|
||||
*/
|
||||
public class UsersControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UsersControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -28,11 +34,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* work flow lineage controller test
|
||||
*/
|
||||
public class WorkFlowLineageControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WorkFlowLineageControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -15,11 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -29,12 +35,11 @@ import org.springframework.test.web.servlet.MvcResult;
|
|||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* worker group controller test
|
||||
*/
|
||||
public class WorkerGroupControllerTest extends AbstractControllerTest{
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WorkerGroupControllerTest.class);
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
|
@ -48,6 +49,9 @@ import org.slf4j.LoggerFactory;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* access token service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AccessTokenServiceTest {
|
||||
|
||||
|
|
@ -59,7 +63,6 @@ public class AccessTokenServiceTest {
|
|||
@Mock
|
||||
private AccessTokenMapper accessTokenMapper;
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryAccessTokenList() {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ import org.slf4j.LoggerFactory;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* alert group service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AlertGroupServiceTest {
|
||||
|
||||
|
|
@ -54,6 +57,7 @@ public class AlertGroupServiceTest {
|
|||
|
||||
@InjectMocks
|
||||
private AlertGroupServiceImpl alertGroupService;
|
||||
|
||||
@Mock
|
||||
private AlertGroupMapper alertGroupMapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ import org.mockito.Mock;
|
|||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* alert plugin instance service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AlertPluginInstanceServiceTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -33,13 +39,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.mock.web.MockCookie;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* base service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({"sun.security.*", "javax.net.*"})
|
||||
@PrepareForTest({HadoopUtils.class})
|
||||
|
|
@ -47,14 +50,14 @@ public class BaseServiceTest {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);
|
||||
|
||||
private BaseService baseService;
|
||||
private BaseServiceImpl baseService;
|
||||
|
||||
@Mock
|
||||
private HadoopUtils hadoopUtils;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
baseService = new BaseService();
|
||||
baseService = new BaseServiceImpl();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -58,6 +59,9 @@ import org.mockito.Mock;
|
|||
import org.mockito.Mockito;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
/**
|
||||
* data analysis service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class DataAnalysisServiceTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -51,16 +51,20 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
/**
|
||||
* data source service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({"sun.security.*", "javax.net.*"})
|
||||
@PrepareForTest({DataSourceFactory.class, CommonUtils.class})
|
||||
public class DataSourceServiceTest {
|
||||
|
||||
|
||||
@InjectMocks
|
||||
private DataSourceServiceImpl dataSourceService;
|
||||
|
||||
@Mock
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
|
||||
@Mock
|
||||
private DataSourceUserMapper datasourceUserMapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ import org.mockito.Mockito;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* test for ExecutorService
|
||||
* executor service 2 test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class ExecutorService2Test {
|
||||
|
|
|
|||
|
|
@ -14,12 +14,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.ExecutorServiceImpl;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -30,13 +36,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* executor service test
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ApiApplicationServer.class)
|
||||
public class ExecutorServiceTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceTest.class);
|
||||
|
||||
@Autowired
|
||||
|
|
@ -45,28 +51,22 @@ public class ExecutorServiceTest {
|
|||
@Ignore
|
||||
@Test
|
||||
public void startCheckByProcessDefinedId(){
|
||||
|
||||
Map<String, Object> map = executorService.startCheckByProcessDefinedId(1234);
|
||||
Assert.assertNull(map);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void putMsgWithParamsTest() {
|
||||
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
putMsgWithParams(map, Status.PROJECT_ALREADY_EXISTS);
|
||||
|
||||
logger.info(map.toString());
|
||||
}
|
||||
|
||||
|
||||
void putMsgWithParams(Map<String, Object> result, Status status,Object ... statusParams) {
|
||||
result.put(Constants.STATUS, status);
|
||||
if(statusParams != null && statusParams.length > 0){
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams));
|
||||
}else {
|
||||
} else {
|
||||
result.put(Constants.MSG, status.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -35,6 +36,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* logger service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@PrepareForTest({LoggerServiceImpl.class})
|
||||
public class LoggerServiceTest {
|
||||
|
|
@ -43,6 +47,7 @@ public class LoggerServiceTest {
|
|||
|
||||
@InjectMocks
|
||||
private LoggerServiceImpl loggerService;
|
||||
|
||||
@Mock
|
||||
private ProcessService processService;
|
||||
|
||||
|
|
@ -51,7 +56,6 @@ public class LoggerServiceTest {
|
|||
this.loggerService.init();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryDataSourceList() {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -24,6 +25,11 @@ import org.apache.dolphinscheduler.common.model.Server;
|
|||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
||||
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -34,10 +40,9 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* monitor service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MonitorServiceTest {
|
||||
|
||||
|
|
@ -49,7 +54,6 @@ public class MonitorServiceTest {
|
|||
@Mock
|
||||
private MonitorDBDao monitorDBDao;
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryDatabaseState(){
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* process definition service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ProcessDefinitionServiceTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* process definition version service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ProcessDefinitionVersionServiceTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* process instance service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class ProcessInstanceServiceTest {
|
||||
|
||||
|
|
@ -92,9 +95,6 @@ public class ProcessInstanceServiceTest {
|
|||
@Mock
|
||||
ProcessDefinitionVersionService processDefinitionVersionService;
|
||||
|
||||
@Mock
|
||||
ExecutorService execService;
|
||||
|
||||
@Mock
|
||||
TaskInstanceMapper taskInstanceMapper;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ import org.slf4j.LoggerFactory;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* project service test
|
||||
**/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ProjectServiceTest {
|
||||
|
||||
|
|
@ -67,7 +70,6 @@ public class ProjectServiceTest {
|
|||
@Mock
|
||||
private ProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
|
||||
private String projectName = "ProjectServiceTest";
|
||||
|
||||
private String userName = "ProjectServiceTest";
|
||||
|
|
|
|||
|
|
@ -14,10 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
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.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.QueueServiceImpl;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
|
|
@ -29,6 +28,11 @@ import org.apache.dolphinscheduler.dao.entity.Queue;
|
|||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.mapper.QueueMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
@ -41,10 +45,12 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* queue service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class QueueServiceTest {
|
||||
|
||||
|
|
@ -52,17 +58,19 @@ public class QueueServiceTest {
|
|||
|
||||
@InjectMocks
|
||||
private QueueServiceImpl queueService;
|
||||
|
||||
@Mock
|
||||
private QueueMapper queueMapper;
|
||||
|
||||
@Mock
|
||||
private UserMapper userMapper;
|
||||
|
||||
private String queueName = "QueueServiceTest";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -62,29 +63,40 @@ import org.springframework.mock.web.MockMultipartFile;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* resources service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({"sun.security.*", "javax.net.*"})
|
||||
@PrepareForTest({HadoopUtils.class, PropertyUtils.class, FileUtils.class, org.apache.dolphinscheduler.api.utils.FileUtils.class})
|
||||
public class ResourcesServiceTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class);
|
||||
|
||||
@InjectMocks
|
||||
private ResourcesServiceImpl resourcesService;
|
||||
|
||||
@Mock
|
||||
private ResourceMapper resourcesMapper;
|
||||
|
||||
@Mock
|
||||
private TenantMapper tenantMapper;
|
||||
@Mock
|
||||
private ResourceUserMapper resourceUserMapper;
|
||||
|
||||
@Mock
|
||||
private HadoopUtils hadoopUtils;
|
||||
|
||||
@Mock
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Mock
|
||||
private UdfFuncMapper udfFunctionMapper;
|
||||
|
||||
@Mock
|
||||
private ProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
@Mock
|
||||
private ResourceUserMapper resourceUserMapper;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
|
|
@ -314,6 +326,9 @@ public class ResourcesServiceTest {
|
|||
//SUCCESS
|
||||
loginUser.setTenantId(1);
|
||||
Mockito.when(hadoopUtils.delete(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true);
|
||||
Mockito.when(processDefinitionMapper.listResources()).thenReturn(getResources());
|
||||
Mockito.when(resourcesMapper.deleteIds(Mockito.any())).thenReturn(1);
|
||||
Mockito.when(resourceUserMapper.deleteResourceUserArray(Mockito.anyInt(), Mockito.any())).thenReturn(1);
|
||||
result = resourcesService.delete(loginUser, 1);
|
||||
logger.info(result.toString());
|
||||
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
|
||||
|
|
@ -688,4 +703,13 @@ public class ResourcesServiceTest {
|
|||
contentList.add("test");
|
||||
return contentList;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getResources() {
|
||||
List<Map<String, Object>> resources = new ArrayList<>();
|
||||
Map<String, Object> resource = new HashMap<>();
|
||||
resource.put("id", 1);
|
||||
resource.put("resource_ids", "1");
|
||||
resources.add(resource);
|
||||
return resources;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -47,12 +48,13 @@ import org.powermock.api.mockito.PowerMockito;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
/**
|
||||
* scheduler service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(QuartzExecutors.class)
|
||||
|
||||
public class SchedulerServiceTest {
|
||||
|
||||
|
||||
@InjectMocks
|
||||
private SchedulerServiceImpl schedulerService;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.service.impl.SessionServiceImpl;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
|
@ -29,6 +25,12 @@ import org.apache.dolphinscheduler.common.utils.StringUtils;
|
|||
import org.apache.dolphinscheduler.dao.entity.Session;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.dao.mapper.SessionMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
@ -43,7 +45,9 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.mock.web.MockCookie;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* session service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SessionServiceTest {
|
||||
|
||||
|
|
@ -61,7 +65,6 @@ public class SessionServiceTest {
|
|||
public void setUp() {
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after(){
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,16 +51,16 @@ import org.mockito.InjectMocks;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* task instance service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
@SpringBootTest(classes = ApiApplicationServer.class)
|
||||
public class TaskInstanceServiceTest {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TaskInstanceServiceTest.class);
|
||||
|
||||
@InjectMocks
|
||||
private TaskInstanceServiceImpl taskInstanceService;
|
||||
|
|
|
|||
|
|
@ -46,13 +46,16 @@ import org.mockito.Mockito;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* tenant service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TenantServiceTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TenantServiceTest.class);
|
||||
|
||||
@InjectMocks
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -53,21 +54,27 @@ import org.slf4j.LoggerFactory;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* udf func service test
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(PropertyUtils.class)
|
||||
public class UdfFuncServiceTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UdfFuncServiceTest.class);
|
||||
|
||||
@InjectMocks
|
||||
private UdfFuncServiceImpl udfFuncService;
|
||||
|
||||
@Mock
|
||||
private ResourceMapper resourceMapper;
|
||||
|
||||
@Mock
|
||||
private UdfFuncMapper udfFuncMapper;
|
||||
|
||||
@Mock
|
||||
private UDFUserMapper udfUserMapper;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PowerMockito.mockStatic(PropertyUtils.class);
|
||||
|
|
@ -165,6 +172,8 @@ public class UdfFuncServiceTest {
|
|||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
Mockito.when(udfFuncMapper.deleteById(Mockito.anyInt())).thenReturn(1);
|
||||
Mockito.when(udfUserMapper.deleteByUdfFuncId(Mockito.anyInt())).thenReturn(1);
|
||||
Result result= udfFuncService.delete(122);
|
||||
logger.info(result.toString());
|
||||
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import org.mockito.Mockito;
|
|||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* UiPluginServiceTest
|
||||
* ui plugin service test
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class UiPluginServiceTest {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue