类javax.validation.ConstraintDefinitionException源码实例Demo

下面列出了怎么用javax.validation.ConstraintDefinitionException的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public Response toResponse(ValidationException exception) {
    if (exception instanceof ConstraintDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ConstraintDeclarationException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof GroupDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ResteasyViolationException) {
        ResteasyViolationException resteasyViolationException = ResteasyViolationException.class.cast(exception);
        Exception e = resteasyViolationException.getException();
        if (e != null) {
            return buildResponse(unwrapException(e), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
        } else if (resteasyViolationException.getReturnValueViolations().size() == 0) {
            return buildViolationReportResponse(resteasyViolationException, Status.BAD_REQUEST);
        } else {
            return buildViolationReportResponse(resteasyViolationException, Status.INTERNAL_SERVER_ERROR);
        }
    }
    return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
 
@Override
public Response toResponse(ValidationException exception) {
    if (exception instanceof ConstraintDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ConstraintDeclarationException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof GroupDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ResteasyViolationException) {
        ResteasyViolationException resteasyViolationException = ResteasyViolationException.class.cast(exception);
        Exception e = resteasyViolationException.getException();
        if (e != null) {
            return buildResponse(unwrapException(e), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
        } else if (resteasyViolationException.getReturnValueViolations().size() == 0) {
            return buildViolationReportResponse(resteasyViolationException, Status.BAD_REQUEST);
        } else {
            return buildViolationReportResponse(resteasyViolationException, Status.INTERNAL_SERVER_ERROR);
        }
    }
    return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
 
源代码3 项目: tomee   文件: ClassValidationData.java
private static List<ConstraintD<?>> getConstraints(final ApacheValidatorFactory factory, final Method method) {
    final List<ConstraintD<?>> constraints = new ArrayList<>();

    final Meta.ForMethod meta = new Meta.ForMethod(method);
    for (final Annotation annotation : method.getAnnotations()) {
        try {
            final ConstraintD constraint = new ConstraintD(annotation, Scope.LOCAL_ELEMENT, meta, factory);
            constraints.add(constraint);
        } catch (ConstraintDefinitionException e) {
            // ignore
        }
    }
    return constraints;
}
 
源代码4 项目: fess   文件: UriTypeValidator.java
@Override
public void initialize(final UriType uriType) {
    switch (uriType.protocolType()) {
    case WEB:
        protocols = ComponentUtil.getFessConfig().getCrawlerWebProtocolsAsArray();
        break;
    case FILE:
        protocols = ComponentUtil.getFessConfig().getCrawlerFileProtocolsAsArray();
        break;
    default:
        throw new ConstraintDefinitionException("protocolType is emtpy.");
    }
}
 
 类所在包
 同包方法