Hi,
You can use Long instead of Integer which will give you a wider range, but I guess is still not what you want.
Other option is to write your own StringReader (StringReaders are used by Jersey to convert QueryParams to a particular type).
Regards,
Martin
On Feb 18, 2011, at 9:21 PM, viggo.navarsete_at_gmail.com wrote:
> I have REST endpoint defined like this:
> {code}
> @GET
> @Path("MyEndpoint")
> public Response executeMyEndpoint(
> ...
> @javax.ws.rs.QueryParam("pageSize") Integer pageSize,
> @javax.ws.rs.QueryParam("pageNumber") Integer
> pageNumber,
> ...) {
> if( pageNumber != null && ( pageNumber < 1 ||
> pageNumber > Integer.MAX_VALUE / pageSize ) ) {
> return Response.status( Status.BAD_REQUEST
> ).type( MediaType.TEXT_PLAIN )
> .entity( "Page number must be
> in the interval [1, " + Integer.MAX_VALUE + " / pageSize] (including
> endpoints) or omitted." )
> .build();
> }
> ...my code...
> }
> {code}
>
> It means that I put some additional restriction on the values of
> {{pageNumber}} (except the restriction to {{Integer}} type). If user
> passes value which is not within these boundaries, the REST endpoint
> returns the error message I specified. However, if it's not even within
> Integer datatype range, the endpoint returns always HTTP 404 error
> saying "description The requested resource () is not available", which
> is not too user friendly. Is there better option how to handle these
> corner cases than define pageNumber and pageSize as String and do the
> parsing myself?