Return 422 if entity from request body cannot be processed

If a group/project/account which is referenced in the body of a request
cannot be found or is not processable the response code should be '422
Unprocessable Entity'. At the moment we are throwing '404 Not Found' or
'400 Bad Request'. '404 Not Found' is wrong since this status code must
only be used if the resource from the URL is not found. '400 Bad
Request' would be okay, but should rather be used if the request body
is not parseable.

Change-Id: Idcfff67c81eac2e3ea19d73078d2a7ff599d7d02
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-03-08 15:42:05 +01:00
parent d54de1cbb6
commit 7abdd70b76
15 changed files with 179 additions and 226 deletions

View File

@@ -195,7 +195,7 @@ public class GroupPropertiesIT extends AbstractDaemonTest {
in = new GroupOwnerInput();
in.owner = "Non-Existing Group";
r = session.put(url, in);
assertEquals(HttpStatus.SC_BAD_REQUEST, r.getStatusCode());
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
r.consume();
}