Search in sources :

Example 1 with BeanValidationException

use of org.jowidgets.cap.common.api.exception.BeanValidationException in project jo-client-platform by jo-source.

the class DefaultServiceExceptionLogger method logBeanValidationException.

protected boolean logBeanValidationException(final Class<?> serviceType, final Throwable original, final BeanException beanException) {
    if (beanException instanceof BeanValidationException) {
        if (logger.isInfoEnabled()) {
            final BeanValidationException beanValidationException = (BeanValidationException) beanException;
            final IBeanValidationResult validationResult = beanValidationException.getValidationResult();
            if (validationResult != null && validationResult.getValidationResult() != null) {
                logger.info("Bean validation failed: " + validationResult.getValidationResult().getAll() + " for bean: " + beanValidationException.getBeanId());
            } else {
                logger.info("Bean validation failed for bean: " + beanValidationException.getBeanId());
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : IBeanValidationResult(org.jowidgets.cap.common.api.validation.IBeanValidationResult) BeanValidationException(org.jowidgets.cap.common.api.exception.BeanValidationException)

Example 2 with BeanValidationException

use of org.jowidgets.cap.common.api.exception.BeanValidationException in project jo-client-platform by jo-source.

the class BeanExceptionConverterImpl method convertBeansValidationException.

private IBeanMessage convertBeansValidationException(final String shortMessage, final List<? extends IBeanProxy<?>> processedBeans, final int destinationBeanIndex, final IBeanProxy<?> destinationBean, final BeansValidationException exception) {
    final Map<Object, IBeanValidationResult> validationResults = exception.getValidationResults();
    final IBeanValidationResult validationResult;
    if (KeyType.INDEX.equals(exception.getKeyType())) {
        validationResult = validationResults.get(Integer.valueOf(destinationBeanIndex));
    } else {
        validationResult = validationResults.get(destinationBean.getId());
    }
    if (validationResult != null) {
        return convertBeanValidationException(shortMessage, destinationBean, new BeanValidationException(destinationBean.getId(), validationResult));
    } else {
        return new BeanMessageImpl(BeanMessageType.WARNING, shortMessage, VALIDATION_OF_OTHER_DATASETS_FAILED.get(), exception);
    }
}
Also used : IBeanValidationResult(org.jowidgets.cap.common.api.validation.IBeanValidationResult) BeanValidationException(org.jowidgets.cap.common.api.exception.BeanValidationException)

Aggregations

BeanValidationException (org.jowidgets.cap.common.api.exception.BeanValidationException)2 IBeanValidationResult (org.jowidgets.cap.common.api.validation.IBeanValidationResult)2