users@jsr311.java.net

Re: Valid paramer types and exception handling

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Sat, 17 Jan 2009 11:56:59 +0100

Sergey Beryozkin wrote:
> Section 3.2 says that types which have a constructor that accepts a
> single String argument or a static method valueOf(String) are
> supported. Also, the section says that WebApplicationException needs
> to be thrown if exception occurs during the object construction (using
> constructor or valueOf)
>
> few questions.
>
> 1. what should happen if a given parameter type has no valid
> constructor or valueOf() - should an exception be thrown or a null
> value returned ?
I agree with Marc for status 500, because the developer uses a type
which is not supported. This is an internal error.
> 2. Some Java types such as java.util.UUID have no valueOf(String) but
> have fromString(String) method instead. Would it make sense to have
> such methods evaluated too ?
I think, it's good in general. Perhaps we end up in a long list of
static methods to check? Perhaps we could use an annotation to define
the name of the static method to call?
Support for enums seems good to me!
> 3. What HTTP status code should be set if an exception occurs during a
> @FormParam parameter construction - 404 or 400
Marc, 400 is good.

best regards
  Stephan