API: Improve error reporting

This patch improves API errors messages thus fixing some issues (#6878, #3526, #4209, #5335).

`404` statuses have been replaced by omre precise ones:
* `409` when there is a conflict
* `400` when a validation problem occurs

Validation errors are also exposed in API responses.
Use `&&` instead of `and`.<br>Use the new Ruby 1.9 hash syntax.<br>Line is too long. [142/80]<br>Prefer single-quoted strings when you don't need string interpolation or special symbols.