Search in sources :

Example 1 with EcBaseBusinessException

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;
}
Also used : EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) EcLogDTO(com.easy.cloud.core.common.log.pojo.dto.EcLogDTO)

Example 2 with EcBaseBusinessException

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;
}
Also used : EcBaseServiceResultException(com.easy.cloud.core.exception.dto.EcBaseServiceResultException) EcBaseServiceResult(com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with EcBaseBusinessException

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);
}
Also used : EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException) Subject(org.apache.shiro.subject.Subject)

Example 4 with EcBaseBusinessException

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));
    }
}
Also used : EcReptileKeyValueDTO(com.easy.cloud.core.reptile.common.pojo.dto.EcReptileKeyValueDTO) HttpGetRequest(com.geccocrawler.gecco.request.HttpGetRequest) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException)

Example 5 with EcBaseBusinessException

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;
}
Also used : JavassistDynamicBean(com.geccocrawler.gecco.dynamic.JavassistDynamicBean) EcBaseBusinessException(com.easy.cloud.core.exception.bo.EcBaseBusinessException)

Aggregations

EcBaseBusinessException (com.easy.cloud.core.exception.bo.EcBaseBusinessException)10 EcLockAnnotation (com.easy.cloud.core.lock.annotation.EcLockAnnotation)2 AlipaySystemOauthTokenRequest (com.alipay.api.request.AlipaySystemOauthTokenRequest)1 AlipayUserInfoShareRequest (com.alipay.api.request.AlipayUserInfoShareRequest)1 AlipaySystemOauthTokenResponse (com.alipay.api.response.AlipaySystemOauthTokenResponse)1 AlipayUserInfoShareResponse (com.alipay.api.response.AlipayUserInfoShareResponse)1 EcBaseServiceResult (com.easy.cloud.core.basic.pojo.dto.EcBaseServiceResult)1 EcLogDTO (com.easy.cloud.core.common.log.pojo.dto.EcLogDTO)1 EcBaseServiceResultException (com.easy.cloud.core.exception.dto.EcBaseServiceResultException)1 EcBaseOauthResourceDTO (com.easy.cloud.core.oauth.client.base.pojo.dto.EcBaseOauthResourceDTO)1 EcBaseOauthResourceResponse (com.easy.cloud.core.oauth.client.base.response.token.EcBaseOauthResourceResponse)1 SysRoleEntity (com.easy.cloud.core.operator.sysrole.pojo.entity.SysRoleEntity)1 SysRoleQuery (com.easy.cloud.core.operator.sysrole.pojo.query.SysRoleQuery)1 EcReptileKeyValueDTO (com.easy.cloud.core.reptile.common.pojo.dto.EcReptileKeyValueDTO)1 JavassistDynamicBean (com.geccocrawler.gecco.dynamic.JavassistDynamicBean)1 HttpGetRequest (com.geccocrawler.gecco.request.HttpGetRequest)1 ArrayList (java.util.ArrayList)1 Subject (org.apache.shiro.subject.Subject)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)1