Hi!
I have a ServerResource that looks like this:

@Post
        public Representation store(Product product) {
                ProductService service =
MyThreadLocal.getServiceFactory().productService();
                if (null == getRequestAttributes().get("id")) {
                        Set<ConstraintViolation<Product>> violations =
service.validate(product);
                        if (violations.size() == 0) {
                                product = service.create(product);
                                MyJacksonRepresentation<Product> response = new 
   
MyJacksonRepresentation<Product>(product);
                                setStatus(Status.SUCCESS_CREATED);
                                return response;
                        } else {
                                setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                                JSONObject response = new JSONObject();
                                try {
                                        response.put("error", "Validation of 
this Product failed");
                                        for (ConstraintViolation<Product> cv : 
violations) {
                                                response.append("Violations", 
cv.getPropertyPath().toString() + " " +
cv.getMessage());
                                        }
                                        JsonRepresentation res = new 
JsonRepresentation(response);
                                        return res;
                                } catch (JSONException e) {
                                        setStatus(Status.SERVER_ERROR_INTERNAL, 
"Error generating the
Json-Error response.");
                                        return null;
                                }
                        }
                } else {
                        setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "You must 
not provide an id
when creating a new Product.");
                        return null;
                }
        }

When i use Restlet 2.1 Milestone5 and Post an invalid Product-Json, i get a
Response with a 400 Status Code (as expected), but an empty Response body.
However, if i use Restlet 2.0.8 i get the correct JSON Response.
Don't know what, but something seems to be wrong (or just different) in M5
that causes this behaviour...
Someone here knows what it could be?

Regards,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Bug-in-2-1M5-tp6676452p6676452.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2815725

Reply via email to