|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hudsonci.rest.common.RestPreconditions
public abstract class RestPreconditions
Preconditions to check common arguments to REST calls
| Field Summary | |
|---|---|
protected static org.slf4j.Logger |
log
|
| Constructor Summary | |
|---|---|
protected |
RestPreconditions()
|
| Method Summary | ||
|---|---|---|
static int |
checkBuilderIndex(int index)
Check a project builder index for shallow validity |
|
static int |
checkBuildNumber(int buildNumber)
Check a project buildNumber for being greater than zero. |
|
static int |
checkBuildStateIndex(int index)
Check a project build state index for shallow validity. |
|
static String |
checkDocumentId(String id)
Check a DocumentDTO ID for shallow validity |
|
static
|
checkNotNull(T reference,
Class<T> clazz)
IF the passed reference is null, throws a WebApplicationException with status 400 and generates a response body containing suitable client message. |
|
static
|
checkNotNull(T reference,
String msgKey)
Check an argument for null. |
|
static String |
checkProjectName(String projectName)
Check the projectName for shallow validity |
|
protected static void |
checkUUID(String uuid)
Check a uuid string for validity. |
|
protected static boolean |
isNegative(int index)
DSL style negative checking |
|
static void |
throwBadRequest(String message)
Throws a WebApplicationException with status 400 and generates a response body containing the specified message. |
|
static void |
throwConflict(String message)
Throws a WebApplicationException with status 409 and generates a response body containing the specified message. |
|
static void |
throwWebApplicationException(javax.ws.rs.core.Response.Status status,
String message)
Throws a WebApplicationException with specified status and generates a response body containing the specified message. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.slf4j.Logger log
| Constructor Detail |
|---|
protected RestPreconditions()
| Method Detail |
|---|
public static int checkBuildNumber(int buildNumber)
buildNumber - buildNumber to test for validity
javax.ws.rs.WebApplicationException - with Response.Status#BAD_REQUEST if buildNumber is less than onepublic static int checkBuildStateIndex(int index)
index - a value that should be non-negative
javax.ws.rs.WebApplicationException - with Response.Status#BAD_REQUEST if index is negativepublic static int checkBuilderIndex(int index)
index -
javax.ws.rs.WebApplicationException - with Response.Status#BAD_REQUEST if index is negativepublic static String checkProjectName(String projectName)
projectName - the project name to check
javax.ws.rs.WebApplicationException - status 400 if projectName is not a valid format or nullpublic static String checkDocumentId(String id)
projectName - the project name to check
javax.ws.rs.WebApplicationException - status 400 if document id is not a valid format or nullprotected static void checkUUID(String uuid)
uuid -
javax.ws.rs.WebApplicationException - status 400 if UUID cannot be parsed from uuid string
public static <T> T checkNotNull(T reference,
String msgKey)
throwBadRequest(String).
reference - msgKey - the key to lookup the value name
public static <T> T checkNotNull(T reference,
Class<T> clazz)
While not itself a precondition, this is a common operation if a precondition fails and can be used when custom validation was performed for a rest argument.
T - reference to a value to check for nullreference - reference to a value to check for nullclazz - the type of reference, may be null
public static void throwBadRequest(String message)
While not itself a precondition, this is a common operation if a precondition fails and can be used when custom validation was performed for a rest argument.
message - the message to include in the response to the client
javax.ws.rs.WebApplicationException - status 400 with message included as response entitypublic static void throwConflict(String message)
While not itself a precondition, this is a common operation if a precondition fails and can be used when custom validation was performed for a rest argument.
message - the message to include in the response to the client
javax.ws.rs.WebApplicationException - status 400 with message included as response entity
public static void throwWebApplicationException(javax.ws.rs.core.Response.Status status,
String message)
While not itself a precondition, this is a common operation if a precondition fails and can be used when custom validation was performed for a rest argument.
message - the message to include in the response to the clientstatus - the status code of the response in the exception
javax.ws.rs.WebApplicationException - status 400 with message included as response entityprotected static boolean isNegative(int index)
index -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||