src/org/ohmage/domain/AccessRequest.java
public static JSONObject validateRequestContent(String content) 
		throws ValidationException {
		JSONObject jsonContent = null;
		
		if (StringUtils.isEmptyOrWhitespaceOnly(content))
			return null;
	
		try {
			// get the json object
			jsonContent = new JSONObject(content);
			// extract the content JSONarray element
			JSONArray contentArray = jsonContent.getJSONArray(REQUEST_JSON_KEY_CONTENT);
			
			// check that the content is not empty
			if ((contentArray == null) || (contentArray.length() == 0)) {
				throw new ValidationException(ErrorCode.USER_ACCESS_REQUEST_INVALID_PRAMETER,
						"Invalid user setup request format. Excpect a JSONObject with non-empty '" 
						+ REQUEST_JSON_KEY_CONTENT + "' JSONArray element.");
			} 
			
		} catch (JSONException e) {
			throw new ValidationException(ErrorCode.USER_ACCESS_REQUEST_INVALID_PRAMETER,
					"Invalid user setup request format. Excpect a JSONObject with '" +
					REQUEST_JSON_KEY_CONTENT + "' element.", 
					e);
		}
		return jsonContent;
	}
/**
	 *  Validate that the request content string is a proper JSON object. The system 
	 * expect that the string contains a "content" element which is a JSON array. 
	 * The array cannot be empty. 
	 * 
	 * @param content The request content string to be validated.  
	 * 
	 * @return the JSON object representing the content string if the supplied content 
	 *         is a non-empty JSON string. Otherwise, returns null.
	 */
Validate that the request content string is a proper JSON object. The system
expect that the string contains a "content" element which is a JSON array.
The array cannot be empty.

@param content The request content string to be validated.

@return the JSON object representing the content string if the supplied content
is a non-empty JSON string. Otherwise, returns null.
Validate that the request content string is a proper JSON object . The system expect that the string contains a " content " element which is a JSON array . The array cannot be empty . @param content The request content string to be validated . @return the JSON object representing the content string if the supplied content is a non - empty JSON string . Otherwise returns null .
public static JSONObject validateRequestContent(String content) 
		throws ValidationException {
		JSONObject jsonContent = null;
		if (StringUtils.isEmptyOrWhitespaceOnly(content))
			return null;
		try {
			jsonContent = new JSONObject(content);
			JSONArray contentArray = jsonContent.getJSONArray(REQUEST_JSON_KEY_CONTENT);
			if ((contentArray == null) || (contentArray.length() == 0)) {
				throw new ValidationException(ErrorCode.USER_ACCESS_REQUEST_INVALID_PRAMETER,
						"Invalid user setup request format. Excpect a JSONObject with non-empty '" 
						+ REQUEST_JSON_KEY_CONTENT + "' JSONArray element.");
			} 
		} catch (JSONException e) {
			throw new ValidationException(ErrorCode.USER_ACCESS_REQUEST_INVALID_PRAMETER,
					"Invalid user setup request format. Excpect a JSONObject with '" +
					REQUEST_JSON_KEY_CONTENT + "' element.", 
					e);
		}
		return jsonContent;
	}
public static JSONObject validateRequestContent ( String content ) throws ValidationException { JSONObject jsonContent = null ; if ( StringUtils . isEmptyOrWhitespaceOnly ( content ) ) return null ; try { jsonContent = new JSONObject ( content ) ; JSONArray contentArray = jsonContent . getJSONArray ( REQUEST_JSON_KEY_CONTENT ) ; if ( ( contentArray == null ) || ( contentArray . length ( ) == 0 ) ) { throw new ValidationException ( ErrorCode . USER_ACCESS_REQUEST_INVALID_PRAMETER , "Invalid user setup request format. Excpect a JSONObject with non-empty '" + REQUEST_JSON_KEY_CONTENT + "' JSONArray element." ) ; } } catch ( JSONException e ) { throw new ValidationException ( ErrorCode . USER_ACCESS_REQUEST_INVALID_PRAMETER , "Invalid user setup request format. Excpect a JSONObject with '" + REQUEST_JSON_KEY_CONTENT + "' element." , e ) ; } return jsonContent ; }
Validate that the request content string is a proper JSON object.
Validate that the request content string is a proper JSON object .
// get the json object // extract the content JSONarray element // check that the content is not empty