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