@@ -200,7 +200,7 @@ public class ApiClientBase implements Cloneable, Closeable { | |||||
return new NotFoundException(request, response); | return new NotFoundException(request, response); | ||||
case FORBIDDEN: | case FORBIDDEN: | ||||
return new ForbiddenException(request, response); | return new ForbiddenException(request, response); | ||||
case UNPROCESSABLE_ENTITY: | |||||
case INVALID: | |||||
return new ValidationException(request, response); | return new ValidationException(request, response); | ||||
default: return new ApiException(request, response); | default: return new ApiException(request, response); | ||||
} | } | ||||
@@ -304,7 +304,7 @@ public class ApiRunner { | |||||
responseEntity = empty(restResponse.json) || response.isRaw() ? null : json(restResponse.json, JsonNode.class); | responseEntity = empty(restResponse.json) || response.isRaw() ? null : json(restResponse.json, JsonNode.class); | ||||
Object responseObject = responseEntity; | Object responseObject = responseEntity; | ||||
if (response.getStatus() == HttpStatusCodes.UNPROCESSABLE_ENTITY) { | |||||
if (response.getStatus() == HttpStatusCodes.INVALID) { | |||||
if (responseEntity != null) { | if (responseEntity != null) { | ||||
responseObject = new ValidationErrors( | responseObject = new ValidationErrors( | ||||
Arrays.asList(fromJsonOrDie(responseEntity, ConstraintViolationBean[].class))); | Arrays.asList(fromJsonOrDie(responseEntity, ConstraintViolationBean[].class))); | ||||
@@ -352,7 +352,7 @@ public abstract class ScriptMainBase<OPT extends ScriptMainOptionsBase> | |||||
@Override public void unexpectedResponse(ApiScript script, RestResponse restResponse) { | @Override public void unexpectedResponse(ApiScript script, RestResponse restResponse) { | ||||
final String msg; | final String msg; | ||||
switch (restResponse.status) { | switch (restResponse.status) { | ||||
case HttpStatusCodes.UNPROCESSABLE_ENTITY: | |||||
case HttpStatusCodes.INVALID: | |||||
msg = "Invalid: "+restResponse.json; | msg = "Invalid: "+restResponse.json; | ||||
break; | break; | ||||
case HttpStatusCodes.NOT_FOUND: | case HttpStatusCodes.NOT_FOUND: | ||||
@@ -355,7 +355,7 @@ public abstract class AbstractResourceIT<C extends PgRestServerConfiguration, S | |||||
} | } | ||||
protected void assertExpectedViolations(RestResponse response, String... violationMessages) throws Exception{ | protected void assertExpectedViolations(RestResponse response, String... violationMessages) throws Exception{ | ||||
assertEquals(HttpStatusCodes.UNPROCESSABLE_ENTITY, response.status); | |||||
assertEquals(HttpStatusCodes.INVALID, response.status); | |||||
final ConstraintViolationBean[] violations = JsonUtil.FULL_MAPPER.readValue(response.json, ConstraintViolationBean[].class); | final ConstraintViolationBean[] violations = JsonUtil.FULL_MAPPER.readValue(response.json, ConstraintViolationBean[].class); | ||||
assertExpectedViolations(violations, violationMessages); | assertExpectedViolations(violations, violationMessages); | ||||
} | } | ||||
@@ -13,7 +13,7 @@ import static org.cobbzilla.wizard.resources.ResourceUtil.status; | |||||
public abstract class AbstractConstraintViolationExceptionMapper<E extends Exception> { | public abstract class AbstractConstraintViolationExceptionMapper<E extends Exception> { | ||||
protected Response buildResponse(E e) { return status(HttpStatusCodes.UNPROCESSABLE_ENTITY, exception2json(e)); } | |||||
protected Response buildResponse(E e) { return status(HttpStatusCodes.INVALID, exception2json(e)); } | |||||
protected List<ConstraintViolationBean> exception2json(E e) { | protected List<ConstraintViolationBean> exception2json(E e) { | ||||
return Collections.singletonList(mapGenericExceptionToConstraintViolationBean(e)); | return Collections.singletonList(mapGenericExceptionToConstraintViolationBean(e)); | ||||
@@ -13,7 +13,7 @@ import static org.cobbzilla.wizard.resources.ResourceUtil.status; | |||||
public class MultiViolationExceptionMapper implements ExceptionMapper<MultiViolationException> { | public class MultiViolationExceptionMapper implements ExceptionMapper<MultiViolationException> { | ||||
@Override public Response toResponse(MultiViolationException e) { | @Override public Response toResponse(MultiViolationException e) { | ||||
return status(HttpStatusCodes.UNPROCESSABLE_ENTITY, e.getViolations()); | |||||
return status(HttpStatusCodes.INVALID, e.getViolations()); | |||||
} | } | ||||
} | } |
@@ -17,7 +17,7 @@ public class SimpleViolationExceptionMapper implements ExceptionMapper<SimpleVio | |||||
@Override | @Override | ||||
public Response toResponse(SimpleViolationException e) { | public Response toResponse(SimpleViolationException e) { | ||||
return status(HttpStatusCodes.UNPROCESSABLE_ENTITY, getEntity(e)); | |||||
return status(HttpStatusCodes.INVALID, getEntity(e)); | |||||
} | } | ||||
protected List<ConstraintViolationBean> getEntity(SimpleViolationException e) { | protected List<ConstraintViolationBean> getEntity(SimpleViolationException e) { | ||||
@@ -145,8 +145,8 @@ public class ResourceUtil { | |||||
public static Response unauthorized() { return status(UNAUTHORIZED); } | public static Response unauthorized() { return status(UNAUTHORIZED); } | ||||
public static ResourceHttpException unauthorizedEx() { return new ResourceHttpException(UNAUTHORIZED); } | public static ResourceHttpException unauthorizedEx() { return new ResourceHttpException(UNAUTHORIZED); } | ||||
public static Response invalid() { return status(UNPROCESSABLE_ENTITY); } | |||||
public static Response invalid(List<ConstraintViolationBean> violations) { return status(UNPROCESSABLE_ENTITY, violations); } | |||||
public static Response invalid() { return status(INVALID); } | |||||
public static Response invalid(List<ConstraintViolationBean> violations) { return status(INVALID, violations); } | |||||
public static Response invalid(ConstraintViolationBean violation) { | public static Response invalid(ConstraintViolationBean violation) { | ||||
final List<ConstraintViolationBean> violations = new ArrayList<>(); | final List<ConstraintViolationBean> violations = new ArrayList<>(); | ||||