Search in sources :

Example 1 with LogResult

use of org.sakuli.datamodel.actions.LogResult in project sakuli by ConSol.

the class RhinoAspect method doHandleRhinoException.

/**
     * Aspect to fetch all Logs from the Sahi-Proxy by the method {@link net.sf.sahi.ant.Report} and do an trusty
     * exception handling on top of that.
     *
     * @param joinPoint injected joinPoint of the execution
     */
@Before("execution(* net.sf.sahi.report.Report.addResult(..))")
public void doHandleRhinoException(JoinPoint joinPoint) {
    // Read out all args
    Object[] args = joinPoint.getArgs();
    ResultType resultType;
    if (args[1] instanceof ResultType) {
        resultType = (ResultType) args[1];
    } else {
        resultType = ResultType.getType((String) args[1]);
    }
    LogResult logResult = new LogResult((String) args[0], resultType, (String) args[2], (String) args[3]);
    if (logResult.getFailureMsg() == null || !logResult.getFailureMsg().contains(ALREADY_PROCESSED)) {
        //log and handle exception from sahi actions
        if (ResultType.ERROR.equals(resultType) || ResultType.FAILURE.equals(resultType)) {
            BaseActionLoader environmentLoader = BeanLoader.loadBaseActionLoader();
            environmentLoader.getExceptionHandler().handleException(logResult);
        } else /**
             * all Actions in Package {@link org.sakuli.actions} should be already logged by
             * {@link #doAddActionLog(org.aspectj.lang.JoinPoint, org.sakuli.actions.logging.LogToResult)}.
             */
        if (logResult.getDebugInfo() == null || !logResult.getDebugInfo().startsWith("org.sakuli.actions.")) {
            logger.info(logResult.getMessage());
        }
    }
}
Also used : LogResult(org.sakuli.datamodel.actions.LogResult) ResultType(net.sf.sahi.report.ResultType) Before(org.aspectj.lang.annotation.Before)

Aggregations

ResultType (net.sf.sahi.report.ResultType)1 Before (org.aspectj.lang.annotation.Before)1 LogResult (org.sakuli.datamodel.actions.LogResult)1