users@jersey.java.net

Re: [Jersey] several QueryParams ?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Wed, 9 Sep 2009 14:17:43 -0700

2009/9/9 Felipe Gaúcho <fgaucho_at_gmail.com>:
> I finally adopted this:
>
>        @POST
>        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>        public PujInstitutionEntity update(@QueryParam("acronym") String acronym,
>                        @QueryParam("name") String name,
>                        @QueryParam("website") String website,
>                        @QueryParam("logo") String logo,
>                        @QueryParam("email") String email,
>                        @QueryParam("contact") String contact,
>                        @QueryParam("phone") String phone) {
>                PujInstitutionEntity institution = facade.read(
>                                PujInstitutionEntity.class, acronym);
>                if (name != null) {
>                        institution.setContact(validateNull(name));
>                }
...

Not sure if this would be useful, but I found "Java Bean Validation"
(JSR-303) -- and esp. RI from hibernate -- to be very useful for
simple validation, for things like null checks, numeric range checks
and such. Basically just let jersey (JAXB) bind data, have annotations
for fields, use bean validator to see that everything got set as
expected.

-+ Tatu +-