src/org/ohmage/lib/OhmageApi.java
public void updateDocument(final String authenticationToken,
			final String client, final String documentId,
			final String newName, final String newDescription,
			final Document.PrivacyState newPrivacyState, 
			final byte[] newContents,
			final Map<String, Document.Role> campaignAndRolesToAdd,
			final Collection<String> campaignsToRemove,
			final Map<String, Document.Role> classAndRolesToAdd,
			final Collection<String> classesToRemove,
			final Map<String, Document.Role> userAndRolesToAdd,
			final Collection<String> 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.DOCUMENT_ID, documentId);
		parameters.put(InputKeys.DOCUMENT_NAME, newName);
		parameters.put(InputKeys.DESCRIPTION, newDescription);
		parameters.put(InputKeys.PRIVACY_STATE, newPrivacyState);
		parameters.put(InputKeys.DOCUMENT, newContents);
		
		if(campaignAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_CAMPAIGN_ROLE_LIST, 
					StringUtils.mapToStringList(
							campaignAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(campaignsToRemove != null) {
			parameters.put(
					InputKeys.CAMPAIGN_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							campaignsToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_CLASS_ROLE_LIST, 
					StringUtils.mapToStringList(
							classAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classesToRemove != null) {
			parameters.put(
					InputKeys.CLASS_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							classesToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(userAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_USER_ROLE_LIST, 
					StringUtils.mapToStringList(
							userAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(usersToRemove != null) {
			parameters.put(
					InputKeys.USER_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							usersToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		
		try {
			processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiDocumentUpdate()), 
							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);
		}
	}
/**
	 * Updates the information and/or contents of a document. The 
	 * authentication and document ID are required, but any of the other values
	 * may be null meaning that their values won't be updated.
	 * 
	 * @param authenticationToken The user's authentication token.
	 * 
	 * @param client The client value.
	 * 
	 * @param documentId The document's unique identifier.
	 * 
	 * @param newName The document's new name.
	 * 
	 * @param newDescription The document's new description.
	 * 
	 * @param newPrivacyState The document's new privacy state.
	 * 
	 * @param newContents The document's new contents.
	 * 
	 * @param campaignAndRolesToAdd A map of campaign IDs to document roles to
	 * 								associate with the document.
	 * 
	 * @param campaignsToRemove A list of the campaigns whose association with
	 * 							the document should be removed.
	 * 
	 * @param classAndRolesToAdd A map of class IDs to document roles to
	 * 							 associate with the document.
	 * 
	 * @param classesToRemove A list of the classes whose association with the
	 * 						  document should be removed.
	 * 
	 * @param userAndRolesToAdd A map of usernames to document roles to 
	 * 							associate with the document.
	 * 
	 * @param usersToRemove A list of usernames of users whose association with
	 * 						the document should be removed.
	 * 
	 * @throws ApiException Thrown if there is a library error.
	 * 
	 * @throws RequestErrorException Thrown if the server returns an error.
	 */
Updates the information and/or contents of a document. The
authentication and document ID are required, but any of the other values
may be null meaning that their values won't be updated.

@param authenticationToken The user's authentication token.

@param client The client value.

@param documentId The document's unique identifier.

@param newName The document's new name.

@param newDescription The document's new description.

@param newPrivacyState The document's new privacy state.

@param newContents The document's new contents.

@param campaignAndRolesToAdd A map of campaign IDs to document roles to
associate with the document.

@param campaignsToRemove A list of the campaigns whose association with
the document should be removed.

@param classAndRolesToAdd A map of class IDs to document roles to
associate with the document.

@param classesToRemove A list of the classes whose association with the
document should be removed.

@param userAndRolesToAdd A map of usernames to document roles to
associate with the document.

@param usersToRemove A list of usernames of users whose association with
the document should be removed.

@throws ApiException Thrown if there is a library error.

@throws RequestErrorException Thrown if the server returns an error.
Updates the information and / or contents of a document . The authentication and document ID are required but any of the other values may be null meaning that their values won ' t be updated . @param authenticationToken The user ' s authentication token . @param client The client value . @param documentId The document ' s unique identifier . @param newName The document ' s new name . @param newDescription The document ' s new description . @param newPrivacyState The document ' s new privacy state . @param newContents The document ' s new contents . @param campaignAndRolesToAdd A map of campaign IDs to document roles to associate with the document . @param campaignsToRemove A list of the campaigns whose association with the document should be removed . @param classAndRolesToAdd A map of class IDs to document roles to associate with the document . @param classesToRemove A list of the classes whose association with the document should be removed . @param userAndRolesToAdd A map of usernames to document roles to associate with the document . @param usersToRemove A list of usernames of users whose association with the document should be removed . @throws ApiException Thrown if there is a library error . @throws RequestErrorException Thrown if the server returns an error .
public void updateDocument(final String authenticationToken,
			final String client, final String documentId,
			final String newName, final String newDescription,
			final Document.PrivacyState newPrivacyState, 
			final byte[] newContents,
			final Map<String, Document.Role> campaignAndRolesToAdd,
			final Collection<String> campaignsToRemove,
			final Map<String, Document.Role> classAndRolesToAdd,
			final Collection<String> classesToRemove,
			final Map<String, Document.Role> userAndRolesToAdd,
			final Collection<String> 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.DOCUMENT_ID, documentId);
		parameters.put(InputKeys.DOCUMENT_NAME, newName);
		parameters.put(InputKeys.DESCRIPTION, newDescription);
		parameters.put(InputKeys.PRIVACY_STATE, newPrivacyState);
		parameters.put(InputKeys.DOCUMENT, newContents);
		if(campaignAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_CAMPAIGN_ROLE_LIST, 
					StringUtils.mapToStringList(
							campaignAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(campaignsToRemove != null) {
			parameters.put(
					InputKeys.CAMPAIGN_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							campaignsToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_CLASS_ROLE_LIST, 
					StringUtils.mapToStringList(
							classAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classesToRemove != null) {
			parameters.put(
					InputKeys.CLASS_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							classesToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(userAndRolesToAdd != null) {
			parameters.put(
					InputKeys.DOCUMENT_USER_ROLE_LIST, 
					StringUtils.mapToStringList(
							userAndRolesToAdd, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(usersToRemove != null) {
			parameters.put(
					InputKeys.USER_LIST_REMOVE, 
					StringUtils.collectionToStringList(
							usersToRemove, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		try {
			processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiDocumentUpdate()), 
							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 updateDocument ( final String authenticationToken , final String client , final String documentId , final String newName , final String newDescription , final Document . PrivacyState newPrivacyState , final byte [ ] newContents , final Map < String , Document . Role > campaignAndRolesToAdd , final Collection < String > campaignsToRemove , final Map < String , Document . Role > classAndRolesToAdd , final Collection < String > classesToRemove , final Map < String , Document . Role > userAndRolesToAdd , final Collection < String > 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 . DOCUMENT_ID , documentId ) ; parameters . put ( InputKeys . DOCUMENT_NAME , newName ) ; parameters . put ( InputKeys . DESCRIPTION , newDescription ) ; parameters . put ( InputKeys . PRIVACY_STATE , newPrivacyState ) ; parameters . put ( InputKeys . DOCUMENT , newContents ) ; if ( campaignAndRolesToAdd != null ) { parameters . put ( InputKeys . DOCUMENT_CAMPAIGN_ROLE_LIST , StringUtils . mapToStringList ( campaignAndRolesToAdd , InputKeys . ENTITY_ROLE_SEPARATOR , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( campaignsToRemove != null ) { parameters . put ( InputKeys . CAMPAIGN_LIST_REMOVE , StringUtils . collectionToStringList ( campaignsToRemove , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( classAndRolesToAdd != null ) { parameters . put ( InputKeys . DOCUMENT_CLASS_ROLE_LIST , StringUtils . mapToStringList ( classAndRolesToAdd , InputKeys . ENTITY_ROLE_SEPARATOR , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( classesToRemove != null ) { parameters . put ( InputKeys . CLASS_LIST_REMOVE , StringUtils . collectionToStringList ( classesToRemove , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( userAndRolesToAdd != null ) { parameters . put ( InputKeys . DOCUMENT_USER_ROLE_LIST , StringUtils . mapToStringList ( userAndRolesToAdd , InputKeys . ENTITY_ROLE_SEPARATOR , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( usersToRemove != null ) { parameters . put ( InputKeys . USER_LIST_REMOVE , StringUtils . collectionToStringList ( usersToRemove , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } try { processJsonResponse ( makeRequest ( new URL ( url . toString ( ) + RequestBuilder . getInstance ( ) . getApiDocumentUpdate ( ) ) , 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 ) ; } }
Updates the information and/or contents of a document.
Updates the information and / or contents of a document .