users@jersey.java.net

Re: [Jersey] Re: Custom Invalid Parameter Handling

From: Chris Carrier <ctcarrier_at_gmail.com>
Date: Wed, 14 Apr 2010 16:20:29 -0700

Nope it's not handled transparently but you also don't call it for
each parameter, you call it on the complete object after marshalling.
Right now I'm only using this kind of validation for Post methods
where Jersey is taking care of the marshalling but it'd work fine if
you are marshalling manually. I'm using a generic superclass so I
just have a 'create' method that all POSTs inherit and they pass the
marshalled object up and it gets validated with the code I posted. If
it's not annotated with validation annotations it'll just pass
through.

So far I've only dealt with domain classes that I created so I haven't
run into the issue of not being able to annotate the classes. Though
I really like how clean this approach is and it's gotten somewhat
integrated into my platform so I would probably create a wrapper class
or subclass or something like that to add the annotations and allow my
validation code to do the rest. It's not great but it'd work. This
approach probably works best where the majority of your classes you
want to validate are accessible to you.

Chris

On Wed, Apr 14, 2010 at 4:03 PM, Dan Forward <dan-nabble_at_forwardhome.com> wrote:
>
> How do you hook this into Jersey? Do you have to call the validate method for
> each parameter at the top of each resource method or is it handled
> transparently?
>
> What about classes you cannot annotate? For example, I use Joda Time's
> LocalDate for birth dates.
>
> Sincerely,
>
> Dan Forward
> --
> View this message in context: http://n2.nabble.com/Custom-Invalid-Parameter-Handling-tp4904335p4904617.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>