Polish "Remove usage of `HttpStatus` in Web Endpoints"
Closes gh-10350
This commit is contained in:
parent
6c6ce7221a
commit
f43aa9444d
|
@ -42,7 +42,7 @@ public class AuditEventsWebEndpointExtension {
|
||||||
public WebEndpointResponse<AuditEventsDescriptor> eventsWithPrincipalDateAfterAndType(
|
public WebEndpointResponse<AuditEventsDescriptor> eventsWithPrincipalDateAfterAndType(
|
||||||
String principal, Date after, String type) {
|
String principal, Date after, String type) {
|
||||||
if (after == null) {
|
if (after == null) {
|
||||||
return new WebEndpointResponse<>(WebEndpointResponse.BAD_REQUEST_STATUS);
|
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
AuditEventsDescriptor auditEvents = this.delegate
|
AuditEventsDescriptor auditEvents = this.delegate
|
||||||
.eventsWithPrincipalDateAfterAndType(principal, after, type);
|
.eventsWithPrincipalDateAfterAndType(principal, after, type);
|
||||||
|
|
|
@ -34,27 +34,32 @@ public final class WebEndpointResponse<T> {
|
||||||
/**
|
/**
|
||||||
* {@code 200 OK}.
|
* {@code 200 OK}.
|
||||||
*/
|
*/
|
||||||
public static final int OK_STATUS = 200;
|
public static final int STATUS_OK = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code 400 Bad Request}.
|
* {@code 400 Bad Request}.
|
||||||
*/
|
*/
|
||||||
public static final int BAD_REQUEST_STATUS = 400;
|
public static final int STATUS_BAD_REQUEST = 400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code 404 Not Found}.
|
||||||
|
*/
|
||||||
|
public static final int STATUS_NOT_FOUND = 404;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code 429 Too Many Requests}.
|
* {@code 429 Too Many Requests}.
|
||||||
*/
|
*/
|
||||||
public static final int TOO_MANY_REQUESTS_STATUS = 429;
|
public static final int STATUS_TOO_MANY_REQUESTS = 429;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code 500 Internal Server Error}.
|
* {@code 500 Internal Server Error}.
|
||||||
*/
|
*/
|
||||||
public static final int INTERNAL_SERVER_ERROR_STATUS = 500;
|
public static final int STATUS_INTERNAL_SERVER_ERROR = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code 503 Service Unavailable}.
|
* {@code 503 Service Unavailable}.
|
||||||
*/
|
*/
|
||||||
public static final int SERVICE_UNAVAILABLE_STATUS = 503;
|
public static final int STATUS_SERVICE_UNAVAILABLE = 503;
|
||||||
|
|
||||||
private final T body;
|
private final T body;
|
||||||
|
|
||||||
|
@ -82,7 +87,7 @@ public final class WebEndpointResponse<T> {
|
||||||
* @param body the body
|
* @param body the body
|
||||||
*/
|
*/
|
||||||
public WebEndpointResponse(T body) {
|
public WebEndpointResponse(T body) {
|
||||||
this(body, OK_STATUS);
|
this(body, STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,9 +41,9 @@ public class HealthStatusHttpMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupDefaultStatusMapping() {
|
private void setupDefaultStatusMapping() {
|
||||||
addStatusMapping(Status.DOWN, WebEndpointResponse.SERVICE_UNAVAILABLE_STATUS);
|
addStatusMapping(Status.DOWN, WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
|
||||||
addStatusMapping(Status.OUT_OF_SERVICE,
|
addStatusMapping(Status.OUT_OF_SERVICE,
|
||||||
WebEndpointResponse.SERVICE_UNAVAILABLE_STATUS);
|
WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,9 +105,9 @@ public class HealthStatusHttpMapper {
|
||||||
return this.statusMapping.keySet().stream()
|
return this.statusMapping.keySet().stream()
|
||||||
.filter((key) -> code.equals(getUniformValue(key)))
|
.filter((key) -> code.equals(getUniformValue(key)))
|
||||||
.map(this.statusMapping::get).findFirst()
|
.map(this.statusMapping::get).findFirst()
|
||||||
.orElse(WebEndpointResponse.OK_STATUS);
|
.orElse(WebEndpointResponse.STATUS_OK);
|
||||||
}
|
}
|
||||||
return WebEndpointResponse.OK_STATUS;
|
return WebEndpointResponse.STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUniformValue(String code) {
|
private String getUniformValue(String code) {
|
||||||
|
|
|
@ -89,13 +89,13 @@ public class HeapDumpWebEndpoint {
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
return new WebEndpointResponse<>(
|
return new WebEndpointResponse<>(
|
||||||
WebEndpointResponse.INTERNAL_SERVER_ERROR_STATUS);
|
WebEndpointResponse.STATUS_INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
catch (HeapDumperUnavailableException ex) {
|
catch (HeapDumperUnavailableException ex) {
|
||||||
return new WebEndpointResponse<>(
|
return new WebEndpointResponse<>(
|
||||||
WebEndpointResponse.SERVICE_UNAVAILABLE_STATUS);
|
WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
return new WebEndpointResponse<>(WebEndpointResponse.TOO_MANY_REQUESTS_STATUS);
|
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_TOO_MANY_REQUESTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Resource dumpHeap(boolean live) throws IOException, InterruptedException {
|
private Resource dumpHeap(boolean live) throws IOException, InterruptedException {
|
||||||
|
|
Loading…
Reference in New Issue