src/org/ohmage/lib/OhmageApi.java
public void uploadSurveyResponses(final String username, 
			final String hashedPassword, final String client,
			final String campaignId, final DateTime campaignCreationTimestamp,
			final Collection<SurveyResponse> surveyResponses)
			throws ApiException, RequestErrorException {
		
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put(InputKeys.USER, username);
		parameters.put(InputKeys.PASSWORD, hashedPassword);
		parameters.put(InputKeys.CLIENT, client);
		parameters.put(InputKeys.CAMPAIGN_URN, campaignId);
		parameters.put(InputKeys.CAMPAIGN_CREATION_TIMESTAMP, DateTimeUtils.getIso8601DateString(campaignCreationTimestamp, true));
		
		JSONArray dataArray = new JSONArray();
		for(SurveyResponse response : surveyResponses) {
			if(response == null) {
				continue;
			}
			
			JSONObject responseJson;
			try {
				responseJson = response.toJson(false, false, false, 
						false, true, true, true, true, true, false, false, 
						true, true, true, true, false, false);
				
			}
			catch(JSONException e) {
				throw new ApiException("There was a problem building the JSON.", e);
			}
			catch(DomainException e) {
				throw new ApiException("There was a problem building the JSON.", e);
			}
			
			if(responseJson == null) {
				throw new ApiException("One of the survey responses could not be converted to JSON.");
			}
			
			dataArray.put(responseJson);
		}
		parameters.put(InputKeys.SURVEYS, dataArray);
		
		try {
			processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiSurveyUpload()), 
							parameters, 
							true), 
					null);
		}
		catch(MalformedURLException e) {
			throw new ApiException("The URL was incorrectly created.", e);
		}
		catch(IllegalArgumentException e) {
			throw new ApiException("The response was not proper JSON.", e);
		}
	}
/**
	 * Uploads a collection of survey responses.
	 * 
	 * @param username The username of the user for whom this survey response
	 * 				   belongs.
	 * 
	 * @param hashedPassword The hashsed password of the user that is creating
	 * 						 this point.
	 * 
	 * @param client The client value.
	 * 
	 * @param campaignId The unique identifier for the campaign for whom these
	 * 					 survey responses belong.
	 * 
	 * @param campaignCreationTimestamp The campaign's creation timestamp to
	 * 									ensure we are not uploading out-dated
	 * 									data.
	 * 
	 * @param surveyResponses The collection of survey responses to be 
	 * 						  uploaded.
	 * 
	 * @throws ApiException Thrown if there is a library error.
	 * 
	 * @throws RequestErrorException Thrown if the server returns an error.
	 */
Uploads a collection of survey responses.

@param username The username of the user for whom this survey response
belongs.

@param hashedPassword The hashsed password of the user that is creating
this point.

@param client The client value.

@param campaignId The unique identifier for the campaign for whom these
survey responses belong.

@param campaignCreationTimestamp The campaign's creation timestamp to
ensure we are not uploading out-dated
data.

@param surveyResponses The collection of survey responses to be
uploaded.

@throws ApiException Thrown if there is a library error.

@throws RequestErrorException Thrown if the server returns an error.
Uploads a collection of survey responses . @param username The username of the user for whom this survey response belongs . @param hashedPassword The hashsed password of the user that is creating this point . @param client The client value . @param campaignId The unique identifier for the campaign for whom these survey responses belong . @param campaignCreationTimestamp The campaign ' s creation timestamp to ensure we are not uploading out - dated data . @param surveyResponses The collection of survey responses to be uploaded . @throws ApiException Thrown if there is a library error . @throws RequestErrorException Thrown if the server returns an error .
public void uploadSurveyResponses(final String username, 
			final String hashedPassword, final String client,
			final String campaignId, final DateTime campaignCreationTimestamp,
			final Collection<SurveyResponse> surveyResponses)
			throws ApiException, RequestErrorException {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put(InputKeys.USER, username);
		parameters.put(InputKeys.PASSWORD, hashedPassword);
		parameters.put(InputKeys.CLIENT, client);
		parameters.put(InputKeys.CAMPAIGN_URN, campaignId);
		parameters.put(InputKeys.CAMPAIGN_CREATION_TIMESTAMP, DateTimeUtils.getIso8601DateString(campaignCreationTimestamp, true));
		JSONArray dataArray = new JSONArray();
		for(SurveyResponse response : surveyResponses) {
			if(response == null) {
				continue;
			}
			JSONObject responseJson;
			try {
				responseJson = response.toJson(false, false, false, 
						false, true, true, true, true, true, false, false, 
						true, true, true, true, false, false);
			}
			catch(JSONException e) {
				throw new ApiException("There was a problem building the JSON.", e);
			}
			catch(DomainException e) {
				throw new ApiException("There was a problem building the JSON.", e);
			}
			if(responseJson == null) {
				throw new ApiException("One of the survey responses could not be converted to JSON.");
			}
			dataArray.put(responseJson);
		}
		parameters.put(InputKeys.SURVEYS, dataArray);
		try {
			processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiSurveyUpload()), 
							parameters, 
							true), 
					null);
		}
		catch(MalformedURLException e) {
			throw new ApiException("The URL was incorrectly created.", e);
		}
		catch(IllegalArgumentException e) {
			throw new ApiException("The response was not proper JSON.", e);
		}
	}
public void uploadSurveyResponses ( final String username , final String hashedPassword , final String client , final String campaignId , final DateTime campaignCreationTimestamp , final Collection < SurveyResponse > surveyResponses ) throws ApiException , RequestErrorException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( InputKeys . USER , username ) ; parameters . put ( InputKeys . PASSWORD , hashedPassword ) ; parameters . put ( InputKeys . CLIENT , client ) ; parameters . put ( InputKeys . CAMPAIGN_URN , campaignId ) ; parameters . put ( InputKeys . CAMPAIGN_CREATION_TIMESTAMP , DateTimeUtils . getIso8601DateString ( campaignCreationTimestamp , true ) ) ; JSONArray dataArray = new JSONArray ( ) ; for ( SurveyResponse response : surveyResponses ) { if ( response == null ) { continue ; } JSONObject responseJson ; try { responseJson = response . toJson ( false , false , false , false , true , true , true , true , true , false , false , true , true , true , true , false , false ) ; } catch ( JSONException e ) { throw new ApiException ( "There was a problem building the JSON." , e ) ; } catch ( DomainException e ) { throw new ApiException ( "There was a problem building the JSON." , e ) ; } if ( responseJson == null ) { throw new ApiException ( "One of the survey responses could not be converted to JSON." ) ; } dataArray . put ( responseJson ) ; } parameters . put ( InputKeys . SURVEYS , dataArray ) ; try { processJsonResponse ( makeRequest ( new URL ( url . toString ( ) + RequestBuilder . getInstance ( ) . getApiSurveyUpload ( ) ) , parameters , true ) , null ) ; } catch ( MalformedURLException e ) { throw new ApiException ( "The URL was incorrectly created." , e ) ; } catch ( IllegalArgumentException e ) { throw new ApiException ( "The response was not proper JSON." , e ) ; } }
Uploads a collection of survey responses.
Uploads a collection of survey responses .