public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException {
Validate validate = method.getMethod().getAnnotation(Validate.class);
if (validate != null) {
ResourceBundle validatorBundle = ResourceBundle.getBundle(
"org.hibernate.validator.resources.DefaultValidatorMessages", request.getLocale());
FallbackResourceBundle bundle = new FallbackResourceBundle(localization.getBundle(), validatorBundle);
String[] names = provider.parameterNamesFor(method.getMethod());
for (String path : validate.params()) {
try {
Object[] paramValues = parameters.getParameters();
Object object = paramFor(names, path, paramValues);
BasicValidationErrors newErrors = new BasicValidationErrors();
HibernateLogicMethod.validateParam(locator, request, bundle, newErrors, object, path);
for (org.vraptor.i18n.ValidationMessage msg : newErrors) {
if (msg instanceof FixedMessage) {
FixedMessage m = (FixedMessage) msg;
String content = bundle.getString(m.getKey());
errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
} else if (msg instanceof Message) {
Message m = (Message) msg;
String content = bundle.getString(m.getKey());
content = MessageFormat.format(content, new Object[]{m.getParameters()});
errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
} else {
throw new IllegalArgumentException("Unsupported validation message type: " + msg.getClass().getName());
}