use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.
the class EcLogAnalysisBO method buildDqLogAnalysisData.
/**
* 构建日志分析数据---必须对dqLogAnalysisDTO中的dqLogDTO成员属性进行初始化后才能调用该方法
*/
public EcLogAnalysisBO buildDqLogAnalysisData() {
try {
EcLogDTO ecLogDTO = this.ecLogAnalysisDTO.getLogDTO();
if (EcBaseUtils.isNull(ecLogDTO)) {
throw new EcBaseBusinessException(EcLogErrorCodeEnum.DQ_LOG_DTO_CANT_NULL);
}
this.ecLogAnalysisDTO.buildRunTimeMinllisTotal().buildRunTimesTotal().buildRunTimeMinllisAvg();
this.ecLogAnalysisDTO.buildRunTimeMinllisMin().buildRunTimeMinllisMax().buildLogType();
} catch (Exception e) {
e.printStackTrace();
}
return this;
}
use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.
the class EcBaseExceptionHandle method handleAndReturnData.
/**
* 基于@ExceptionHandler异常处理
*/
@ExceptionHandler
@ResponseBody
public EcBaseServiceResult handleAndReturnData(HttpServletRequest request, HttpServletResponse response, Exception ex) {
logger.error(ex.getMessage(), ex);
EcBaseServiceResult ecBaseServiceResult = EcBaseServiceResult.newInstance();
EcBaseServiceResultException serviceResultException = EcBaseServiceResultException.newInstance();
String path = request.getRequestURL().toString();
if (ex instanceof EcBaseBusinessException) {
EcBaseBusinessException dbbException = (EcBaseBusinessException) ex;
ecBaseServiceResult.buildErrorCodeAndMsg(dbbException.getErrorCode(), dbbException.getErrorMsg());
} else if (ex instanceof RuntimeException) {
ecBaseServiceResult.buildDqBaseErrorCodeInf(EcBaseErrorCodeEnum.RUNTIME_EXCEPTION);
} else {
ecBaseServiceResult.buildDqBaseErrorCodeInf(EcBaseErrorCodeEnum.SYS_EXCEPTION);
}
serviceResultException.setException(ex.getClass().getName());
serviceResultException.setFailureDetails(ex.getMessage());
serviceResultException.setTimstamp(EcDateUtils.getCurrentDate());
serviceResultException.setPath(path);
ecBaseServiceResult.buildServiceResultException(serviceResultException);
EcLogUtils.error("异常统一处理日志", ecBaseServiceResult, logger);
return ecBaseServiceResult;
}
use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.
the class SysUserServiceImpl method login.
@Override
public EcBaseServiceResult login(ServletRequest request, SysUserDTO sysUserDTO) {
if (EcStringUtils.isEmpty(sysUserDTO.getUsername())) {
String username = EcRequestUtils.getTObjFromAttribute(request, EcAuthorityConstant.USERNAME, String.class);
if (EcStringUtils.isEmpty(username)) {
throw new EcBaseBusinessException(EcBaseErrorCodeEnum.DATA_ERROR, "登录信息");
}
sysUserDTO.setUsername(username);
}
Subject subject = SecurityUtils.getSubject();
return login(subject, sysUserDTO);
}
use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.
the class EcReptileUtils method intoScheduler.
/**
* <p>
* 将要爬取数据的url放到Scheduler中
* </p>
* <p>
* <pre>
* 所需参数示例及其说明
* 参数名称 : 示例值 : 说明 : 是否必须
* </pre>
*
* @param geccoEngine : GeccoEngine : 爬虫引擎
* @param dynamicBeanDTO : EcReptileDynamicBeanDTO : 爬虫动态bean数据传输对象
* @param dataDTO : EcReptileDataDTO : 爬虫数据的数据传输对象由业务系统传入
* @author daiqi
* @创建时间 2018年6月8日 下午3:07:08
*/
public static void intoScheduler(GeccoEngine geccoEngine, EcReptileDynamicBeanDTO dynamicBeanDTO, EcReptileDataDTO dataDTO) {
List<String> matchUrls = dynamicBeanDTO.getMatchUrlList();
if (EcCollectionsUtils.isEmpty(matchUrls)) {
throw new EcBaseBusinessException("设置异常", "待设置异常");
}
for (String matchUrl : matchUrls) {
String intoUrl = matchUrl;
if (EcCollectionsUtils.isEmpty(dataDTO.getUrlKeyValueDTOs())) {
geccoEngine.getScheduler().into(new HttpGetRequest(intoUrl));
continue;
}
for (EcReptileKeyValueDTO keyValueDTO : dataDTO.getUrlKeyValueDTOs()) {
intoUrl = UrlMatcher.replaceParams(intoUrl, keyValueDTO.getKey(), keyValueDTO.getValue());
}
geccoEngine.getScheduler().into(new HttpGetRequest(intoUrl));
}
}
use of com.easy.cloud.core.exception.bo.EcBaseBusinessException in project dq-easy-cloud by dq-open-cloud.
the class EcReptileUtils method buildJavassistDynamicBean.
/**
* <p>
* 构建动态JavassistDynamicBean对象
* </p>
* <p>
* <pre>
* 所需参数示例及其说明
* 参数名称 : 示例值 : 说明 : 是否必须
* </pre>
*
* @param dynamicBeanDTO
* @return
* @author daiqi
* @创建时间 2018年6月7日 下午7:14:00
*/
private static JavassistDynamicBean buildJavassistDynamicBean(EcReptileDynamicBeanDTO dynamicBeanDTO) {
if (EcCollectionsUtils.isEmpty(dynamicBeanDTO.getMatchUrlList())) {
throw new EcBaseBusinessException(EcBaseErrorCodeEnum.LIST_NULL, "matchUrlList");
}
if (EcCollectionsUtils.isEmpty(dynamicBeanDTO.getPipelineNameList())) {
throw new EcBaseBusinessException(EcBaseErrorCodeEnum.LIST_NULL, "pipelineNameList");
}
JavassistDynamicBean dynamicBean;
if (EcStringUtils.isNotEmpty(dynamicBeanDTO.getBeanClassNameBody()) && EcStringUtils.isNotEmpty(dynamicBeanDTO.getBeanClassFullName())) {
dynamicBean = DynamicGecco.html(dynamicBeanDTO.getBeanClassFullName());
} else {
dynamicBean = DynamicGecco.html();
}
List<String> matchUrls = dynamicBeanDTO.getMatchUrlList();
// 获取matchUrl
List<String> pipelineNameList = dynamicBeanDTO.getPipelineNameList();
dynamicBean.gecco(matchUrls.toArray(new String[matchUrls.size()]), pipelineNameList.toArray(new String[pipelineNameList.size()]));
return dynamicBean;
}
Aggregations