src/org/ohmage/validator/AuditValidators.java
public static RequestType validateRequestType(final String requestType) 
			throws ValidationException {
		
		if(StringUtils.isEmptyOrWhitespaceOnly(requestType)) {
			return null;
		}
		
		try {
			return RequestType.valueOf(requestType.trim().toUpperCase());
		}
		catch(IllegalArgumentException e) {
			throw new ValidationException(
					ErrorCode.AUDIT_INVALID_RESPONSE_TYPE, 
					"The request type must be one of '" + 
						RequestType.DELETE.toString().toLowerCase() + "', '" +
						RequestType.GET.toString().toLowerCase() + "', '" +
						RequestType.HEAD.toString().toLowerCase() + "', '" +
						RequestType.OPTIONS.toString().toLowerCase() + "', '" +
						RequestType.POST.toString().toLowerCase() + "', '" +
						RequestType.PUT.toString().toLowerCase() + "', '" +
						RequestType.TRACE.toString().toLowerCase() + "', or '" +
						RequestType.UNKNOWN.toString().toLowerCase() + "'." +
						" Given: " + requestType,
					"Invalid request type given: " + 
						requestType, 
					e
				);
		}
	}
/**
	 * Validates that the given request type is a valid RequestType and returns
	 * a RequestType object representing it or is null or whitespace only and
	 * returns null. If it is not null or whitespace only and not a valid 
	 * RequestType, a ValidationException is thrown.
	 * 
	 * @param requestType The RequestType as a String.
	 * 
	 * @return Null if 'requestType' is null or whitespace only; otherwise, a
	 * 		   RequestType that the 'requestType' represented.
	 * 
	 * @throws ValidationException Thrown if the request type is not null, not
	 * 							   whitespace only, and not a valid 
	 * 							   RequestType.
	 */
Validates that the given request type is a valid RequestType and returns
a RequestType object representing it or is null or whitespace only and
returns null. If it is not null or whitespace only and not a valid
RequestType, a ValidationException is thrown.

@param requestType The RequestType as a String.

@return Null if 'requestType' is null or whitespace only; otherwise, a
RequestType that the 'requestType' represented.

@throws ValidationException Thrown if the request type is not null, not
whitespace only, and not a valid
RequestType.
Validates that the given request type is a valid RequestType and returns a RequestType object representing it or is null or whitespace only and returns null . If it is not null or whitespace only and not a valid RequestType a ValidationException is thrown . @param requestType The RequestType as a String . @return Null if ' requestType ' is null or whitespace only ; otherwise a RequestType that the ' requestType ' represented . @throws ValidationException Thrown if the request type is not null not whitespace only and not a valid RequestType .
public static RequestType validateRequestType(final String requestType) 
			throws ValidationException {
		if(StringUtils.isEmptyOrWhitespaceOnly(requestType)) {
			return null;
		}
		try {
			return RequestType.valueOf(requestType.trim().toUpperCase());
		}
		catch(IllegalArgumentException e) {
			throw new ValidationException(
					ErrorCode.AUDIT_INVALID_RESPONSE_TYPE, 
					"The request type must be one of '" + 
						RequestType.DELETE.toString().toLowerCase() + "', '" +
						RequestType.GET.toString().toLowerCase() + "', '" +
						RequestType.HEAD.toString().toLowerCase() + "', '" +
						RequestType.OPTIONS.toString().toLowerCase() + "', '" +
						RequestType.POST.toString().toLowerCase() + "', '" +
						RequestType.PUT.toString().toLowerCase() + "', '" +
						RequestType.TRACE.toString().toLowerCase() + "', or '" +
						RequestType.UNKNOWN.toString().toLowerCase() + "'." +
						" Given: " + requestType,
					"Invalid request type given: " + 
						requestType, 
					e
				);
		}
	}
public static RequestType validateRequestType ( final String requestType ) throws ValidationException { if ( StringUtils . isEmptyOrWhitespaceOnly ( requestType ) ) { return null ; } try { return RequestType . valueOf ( requestType . trim ( ) . toUpperCase ( ) ) ; } catch ( IllegalArgumentException e ) { throw new ValidationException ( ErrorCode . AUDIT_INVALID_RESPONSE_TYPE , "The request type must be one of '" + RequestType . DELETE . toString ( ) . toLowerCase ( ) + "', '" + RequestType . GET . toString ( ) . toLowerCase ( ) + "', '" + RequestType . HEAD . toString ( ) . toLowerCase ( ) + "', '" + RequestType . OPTIONS . toString ( ) . toLowerCase ( ) + "', '" + RequestType . POST . toString ( ) . toLowerCase ( ) + "', '" + RequestType . PUT . toString ( ) . toLowerCase ( ) + "', '" + RequestType . TRACE . toString ( ) . toLowerCase ( ) + "', or '" + RequestType . UNKNOWN . toString ( ) . toLowerCase ( ) + "'." + " Given: " + requestType , "Invalid request type given: " + requestType , e ) ; } }
Validates that the given request type is a valid RequestType and returns
 a RequestType object representing it or is null or whitespace only and
 returns null.
Validates that the given request type is a valid RequestType and returns a RequestType object representing it or is null or whitespace only and returns null .