src/org/ohmage/lib/OhmageApi.java
public void updateCampaign(final String authenticationToken,
			final String client, final String campaignId,
			final Campaign.RunningState runningState,
			final Campaign.PrivacyState privacyState,
			final String xml, final String description,
			final Collection<String> classesToAdd,
			final Collection<String> classesToRemove,
			final Map<String, Set<Campaign.Role>> usersToAdd, 
			final Map<String, Set<Campaign.Role>> usersToRemove)
			throws ApiException, RequestErrorException {
		
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put(InputKeys.AUTH_TOKEN, authenticationToken);
		parameters.put(InputKeys.CLIENT, client);
		parameters.put(InputKeys.CAMPAIGN_URN, campaignId);
		parameters.put(InputKeys.RUNNING_STATE, runningState);
		parameters.put(InputKeys.PRIVACY_STATE, privacyState);
		parameters.put(InputKeys.XML, xml);
		parameters.put(InputKeys.DESCRIPTION, description);
		
		if(classesToAdd != null) {
			parameters.put(InputKeys.CLASS_LIST_ADD, StringUtils.collectionToStringList(classesToAdd, InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classesToRemove != null) {
			parameters.put(InputKeys.CLASS_LIST_REMOVE, StringUtils.collectionToStringList(classesToRemove, InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(usersToAdd != null) {
			StringBuilder resultBuilder = new StringBuilder();
			for(String username : usersToAdd.keySet()) {
				for(Campaign.Role role : usersToAdd.get(username)) {
					resultBuilder.append(username).append(InputKeys.ENTITY_ROLE_SEPARATOR).append(role).append(InputKeys.LIST_ITEM_SEPARATOR);
				}
			}
			
			String result = resultBuilder.toString();
			while(result.endsWith(InputKeys.LIST_ITEM_SEPARATOR)) {
				result = result.substring(0, result.length() - 1);
			}
			
			parameters.put(InputKeys.USER_LIST_ADD, result);
		}
		if(usersToRemove != null) {
			StringBuilder resultBuilder = new StringBuilder();
			for(String username : usersToRemove.keySet()) {
				for(Campaign.Role role : usersToRemove.get(username)) {
					resultBuilder.append(username).append(InputKeys.ENTITY_ROLE_SEPARATOR).append(role).append(InputKeys.LIST_ITEM_SEPARATOR);
				}
			}
			
			String result = resultBuilder.toString();
			while(result.endsWith(InputKeys.LIST_ITEM_SEPARATOR)) {
				result = result.substring(0, result.length() - 1);
			}
			parameters.put(InputKeys.USER_LIST_REMOVE, result);
		}
		
		try {
			makeRequest(
					new URL(url.toString() + RequestBuilder.getInstance().getApiCampaignUpdate()), 
					parameters, 
					true
				);
		}
		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);
		}
	}
/**
	 * Updates a campaign.
	 * 
	 * @param authenticationToken The user's authentication token.
	 * 
	 * @param client The client value.
	 * 
	 * @param campaignId The campaign's unique identifier.
	 * 
	 * @param runningState The campaign's new running state. Optional.
	 * 
	 * @param privacyState The campaign's new privacy state. Optional.
	 * 
	 * @param xml The campaign's new XML. Optional.
	 * 
	 * @param description The campaign's new description. Optional.
	 * 
	 * @param classesToAdd A collection of classes to associate with the 
	 * 					   campaign. Optional.
	 * 
	 * @param classesToRemove A collection of classes to disassociate with the
	 * 						  campaign. Optional.
	 * 
	 * @param usersToAdd A map of usernames to a set of campaign roles to grant
	 * 					 a user a set of roles in a campaign. Optional.
	 * 
	 * @param usersToRemove A map of usernames to a set of campaign roles to
	 * 						revoke from a set of users. Optional.
	 * 
	 * @throws ApiException Thrown if there is a library error.
	 * 
	 * @throws RequestErrorException Thrown if the server returns an error.
	 */
Updates a campaign.

@param authenticationToken The user's authentication token.

@param client The client value.

@param campaignId The campaign's unique identifier.

@param runningState The campaign's new running state. Optional.

@param privacyState The campaign's new privacy state. Optional.

@param xml The campaign's new XML. Optional.

@param description The campaign's new description. Optional.

@param classesToAdd A collection of classes to associate with the
campaign. Optional.

@param classesToRemove A collection of classes to disassociate with the
campaign. Optional.

@param usersToAdd A map of usernames to a set of campaign roles to grant
a user a set of roles in a campaign. Optional.

@param usersToRemove A map of usernames to a set of campaign roles to
revoke from a set of users. Optional.

@throws ApiException Thrown if there is a library error.

@throws RequestErrorException Thrown if the server returns an error.
Updates a campaign . @param authenticationToken The user ' s authentication token . @param client The client value . @param campaignId The campaign ' s unique identifier . @param runningState The campaign ' s new running state . Optional . @param privacyState The campaign ' s new privacy state . Optional . @param xml The campaign ' s new XML . Optional . @param description The campaign ' s new description . Optional . @param classesToAdd A collection of classes to associate with the campaign . Optional . @param classesToRemove A collection of classes to disassociate with the campaign . Optional . @param usersToAdd A map of usernames to a set of campaign roles to grant a user a set of roles in a campaign . Optional . @param usersToRemove A map of usernames to a set of campaign roles to revoke from a set of users . Optional . @throws ApiException Thrown if there is a library error . @throws RequestErrorException Thrown if the server returns an error .
public void updateCampaign(final String authenticationToken,
			final String client, final String campaignId,
			final Campaign.RunningState runningState,
			final Campaign.PrivacyState privacyState,
			final String xml, final String description,
			final Collection<String> classesToAdd,
			final Collection<String> classesToRemove,
			final Map<String, Set<Campaign.Role>> usersToAdd, 
			final Map<String, Set<Campaign.Role>> usersToRemove)
			throws ApiException, RequestErrorException {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put(InputKeys.AUTH_TOKEN, authenticationToken);
		parameters.put(InputKeys.CLIENT, client);
		parameters.put(InputKeys.CAMPAIGN_URN, campaignId);
		parameters.put(InputKeys.RUNNING_STATE, runningState);
		parameters.put(InputKeys.PRIVACY_STATE, privacyState);
		parameters.put(InputKeys.XML, xml);
		parameters.put(InputKeys.DESCRIPTION, description);
		if(classesToAdd != null) {
			parameters.put(InputKeys.CLASS_LIST_ADD, StringUtils.collectionToStringList(classesToAdd, InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classesToRemove != null) {
			parameters.put(InputKeys.CLASS_LIST_REMOVE, StringUtils.collectionToStringList(classesToRemove, InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(usersToAdd != null) {
			StringBuilder resultBuilder = new StringBuilder();
			for(String username : usersToAdd.keySet()) {
				for(Campaign.Role role : usersToAdd.get(username)) {
					resultBuilder.append(username).append(InputKeys.ENTITY_ROLE_SEPARATOR).append(role).append(InputKeys.LIST_ITEM_SEPARATOR);
				}
			}
			String result = resultBuilder.toString();
			while(result.endsWith(InputKeys.LIST_ITEM_SEPARATOR)) {
				result = result.substring(0, result.length() - 1);
			}
			parameters.put(InputKeys.USER_LIST_ADD, result);
		}
		if(usersToRemove != null) {
			StringBuilder resultBuilder = new StringBuilder();
			for(String username : usersToRemove.keySet()) {
				for(Campaign.Role role : usersToRemove.get(username)) {
					resultBuilder.append(username).append(InputKeys.ENTITY_ROLE_SEPARATOR).append(role).append(InputKeys.LIST_ITEM_SEPARATOR);
				}
			}
			String result = resultBuilder.toString();
			while(result.endsWith(InputKeys.LIST_ITEM_SEPARATOR)) {
				result = result.substring(0, result.length() - 1);
			}
			parameters.put(InputKeys.USER_LIST_REMOVE, result);
		}
		try {
			makeRequest(
					new URL(url.toString() + RequestBuilder.getInstance().getApiCampaignUpdate()), 
					parameters, 
					true
				);
		}
		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 updateCampaign ( final String authenticationToken , final String client , final String campaignId , final Campaign . RunningState runningState , final Campaign . PrivacyState privacyState , final String xml , final String description , final Collection < String > classesToAdd , final Collection < String > classesToRemove , final Map < String , Set < Campaign . Role > > usersToAdd , final Map < String , Set < Campaign . Role > > usersToRemove ) throws ApiException , RequestErrorException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( InputKeys . AUTH_TOKEN , authenticationToken ) ; parameters . put ( InputKeys . CLIENT , client ) ; parameters . put ( InputKeys . CAMPAIGN_URN , campaignId ) ; parameters . put ( InputKeys . RUNNING_STATE , runningState ) ; parameters . put ( InputKeys . PRIVACY_STATE , privacyState ) ; parameters . put ( InputKeys . XML , xml ) ; parameters . put ( InputKeys . DESCRIPTION , description ) ; if ( classesToAdd != null ) { parameters . put ( InputKeys . CLASS_LIST_ADD , StringUtils . collectionToStringList ( classesToAdd , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( classesToRemove != null ) { parameters . put ( InputKeys . CLASS_LIST_REMOVE , StringUtils . collectionToStringList ( classesToRemove , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( usersToAdd != null ) { StringBuilder resultBuilder = new StringBuilder ( ) ; for ( String username : usersToAdd . keySet ( ) ) { for ( Campaign . Role role : usersToAdd . get ( username ) ) { resultBuilder . append ( username ) . append ( InputKeys . ENTITY_ROLE_SEPARATOR ) . append ( role ) . append ( InputKeys . LIST_ITEM_SEPARATOR ) ; } } String result = resultBuilder . toString ( ) ; while ( result . endsWith ( InputKeys . LIST_ITEM_SEPARATOR ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } parameters . put ( InputKeys . USER_LIST_ADD , result ) ; } if ( usersToRemove != null ) { StringBuilder resultBuilder = new StringBuilder ( ) ; for ( String username : usersToRemove . keySet ( ) ) { for ( Campaign . Role role : usersToRemove . get ( username ) ) { resultBuilder . append ( username ) . append ( InputKeys . ENTITY_ROLE_SEPARATOR ) . append ( role ) . append ( InputKeys . LIST_ITEM_SEPARATOR ) ; } } String result = resultBuilder . toString ( ) ; while ( result . endsWith ( InputKeys . LIST_ITEM_SEPARATOR ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } parameters . put ( InputKeys . USER_LIST_REMOVE , result ) ; } try { makeRequest ( new URL ( url . toString ( ) + RequestBuilder . getInstance ( ) . getApiCampaignUpdate ( ) ) , parameters , true ) ; } 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 ) ; } }
Updates a campaign.
Updates a campaign .