Merge pull request #1263 from panga/fix_response

Fix wrong response code
This commit is contained in:
Stian Thorgersen 2015-05-15 09:13:50 +02:00
commit 9a87b7f196
2 changed files with 9 additions and 11 deletions

View file

@ -11,9 +11,7 @@ import javax.ws.rs.core.Response;
public class ErrorResponse {
public static Response exists(String message) {
ErrorRepresentation error = new ErrorRepresentation();
error.setErrorMessage(message);
return Response.status(Response.Status.CONFLICT).entity(error).type(MediaType.APPLICATION_JSON).build();
return ErrorResponse.error(message, Response.Status.CONFLICT);
}
public static Response error(String message, Response.Status status) {

View file

@ -202,11 +202,11 @@ public class RealmAdminResource {
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo.getPath()).representation(rep).success();
return Response.noContent().build();
} catch (PatternSyntaxException e) {
return ErrorResponse.exists("Specified regex pattern(s) is invalid.");
return ErrorResponse.error("Specified regex pattern(s) is invalid.", Response.Status.BAD_REQUEST);
} catch (ModelDuplicateException e) {
return ErrorResponse.exists("Realm " + rep.getRealm() + " already exists.");
} catch (Exception e) {
return ErrorResponse.exists("Failed to update " + rep.getRealm() + " Realm.");
return ErrorResponse.error("Failed to update " + rep.getRealm() + " Realm.", Response.Status.INTERNAL_SERVER_ERROR);
}
}