users@jsr311.java.net

bad request response

From: Reto Bachmann-Gmür <reto_at_gmuer.ch>
Date: Mon, 11 Aug 2008 10:55:20 +0200

I'm sure there is an easier way than this to give a bad-request answer.

if ((userName == null) || (email == null)) {
        throw new WebApplicationException(new Response() {
                @Override
                public Object getEntity() {
                         return "must provide username and email";
                }

                @Override
                public int getStatus() {
                        return Status.BAD_REQUEST.getStatusCode();
                }

                @Override
                public MultivaluedMap<String, Object> getMetadata() {
                        return null;
                }
        });
}

Since the last methos should probably return an empty MultivalueMap
instead of null, having a default implementation in JaxRs would be handy.

Reto