src/org/ohmage/lib/OhmageApi.java
public String createDocument(final String authenticationToken, 
			final String client, final String name, final String description,
			final Document.PrivacyState privacyState,
			final File document,
			final Map<String, Document.Role> campaignAndDocumentRoleMap,
			final Map<String, Document.Role> classAndDocumentRoleMap)
			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_NAME, name);
		parameters.put(InputKeys.DESCRIPTION, description);
		parameters.put(InputKeys.PRIVACY_STATE, privacyState);
		parameters.put(InputKeys.DOCUMENT, document);
		
		if(campaignAndDocumentRoleMap != null) {
			parameters.put(
					InputKeys.DOCUMENT_CAMPAIGN_ROLE_LIST, 
					StringUtils.mapToStringList(
							campaignAndDocumentRoleMap, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classAndDocumentRoleMap != null) {
			parameters.put(
					InputKeys.DOCUMENT_CLASS_ROLE_LIST, 
					StringUtils.mapToStringList(
							classAndDocumentRoleMap, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		
		try {
			return processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiDocumentCreate()), 
							parameters, 
							true), 
					DocumentCreationRequest.KEY_DOCUMENT_ID);
		}
		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);
		}
	}
/**
	 * Creates a new document.
	 * 
	 * @param authenticationToken The user's authentication token.
	 * 
	 * @param client The client value.
	 * 
	 * @param name The document's name including an optional extension.
	 * 
	 * @param description An optional description for the document. Set this to
	 * 					  null to omit it.
	 * 
	 * @param privacyState The document's initial privacy state.
	 * 
	 * @param document A File object referencing the document to be uploaded.
	 * 
	 * @param campaignAndDocumentRoleMap A map of campaign IDs to document 
	 * 									 roles to be sent to the server. Either
	 * 									 this or 'classAndDocumentRoleMap' must
	 * 									 be non-null and not empty.
	 * 
	 * @param classAndDocumentRoleMap A map of class IDs to document roles to 
	 * 								  be sent to the server. Either this or
	 * 								  'campaignAndDocumentRoleMap' must be
	 * 								  non-null and not empty.
	 * 
	 * @return Returns the new document's unique identifier.
	 * 
	 * @throws ApiException Thrown if there is a library error.
	 * 
	 * @throws RequestErrorException Thrown if the server returns an error.
	 */
Creates a new document.

@param authenticationToken The user's authentication token.

@param client The client value.

@param name The document's name including an optional extension.

@param description An optional description for the document. Set this to
null to omit it.

@param privacyState The document's initial privacy state.

@param document A File object referencing the document to be uploaded.

@param campaignAndDocumentRoleMap A map of campaign IDs to document
roles to be sent to the server. Either
this or 'classAndDocumentRoleMap' must
be non-null and not empty.

@param classAndDocumentRoleMap A map of class IDs to document roles to
be sent to the server. Either this or
'campaignAndDocumentRoleMap' must be
non-null and not empty.

@return Returns the new document's unique identifier.

@throws ApiException Thrown if there is a library error.

@throws RequestErrorException Thrown if the server returns an error.
Creates a new document . @param authenticationToken The user ' s authentication token . @param client The client value . @param name The document ' s name including an optional extension . @param description An optional description for the document . Set this to null to omit it . @param privacyState The document ' s initial privacy state . @param document A File object referencing the document to be uploaded . @param campaignAndDocumentRoleMap A map of campaign IDs to document roles to be sent to the server . Either this or ' classAndDocumentRoleMap ' must be non - null and not empty . @param classAndDocumentRoleMap A map of class IDs to document roles to be sent to the server . Either this or ' campaignAndDocumentRoleMap ' must be non - null and not empty . @return Returns the new document ' s unique identifier . @throws ApiException Thrown if there is a library error . @throws RequestErrorException Thrown if the server returns an error .
public String createDocument(final String authenticationToken, 
			final String client, final String name, final String description,
			final Document.PrivacyState privacyState,
			final File document,
			final Map<String, Document.Role> campaignAndDocumentRoleMap,
			final Map<String, Document.Role> classAndDocumentRoleMap)
			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_NAME, name);
		parameters.put(InputKeys.DESCRIPTION, description);
		parameters.put(InputKeys.PRIVACY_STATE, privacyState);
		parameters.put(InputKeys.DOCUMENT, document);
		if(campaignAndDocumentRoleMap != null) {
			parameters.put(
					InputKeys.DOCUMENT_CAMPAIGN_ROLE_LIST, 
					StringUtils.mapToStringList(
							campaignAndDocumentRoleMap, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		if(classAndDocumentRoleMap != null) {
			parameters.put(
					InputKeys.DOCUMENT_CLASS_ROLE_LIST, 
					StringUtils.mapToStringList(
							classAndDocumentRoleMap, 
							InputKeys.ENTITY_ROLE_SEPARATOR, 
							InputKeys.LIST_ITEM_SEPARATOR));
		}
		try {
			return processJsonResponse(
					makeRequest(
							new URL(url.toString() + RequestBuilder.getInstance().getApiDocumentCreate()), 
							parameters, 
							true), 
					DocumentCreationRequest.KEY_DOCUMENT_ID);
		}
		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 String createDocument ( final String authenticationToken , final String client , final String name , final String description , final Document . PrivacyState privacyState , final File document , final Map < String , Document . Role > campaignAndDocumentRoleMap , final Map < String , Document . Role > classAndDocumentRoleMap ) 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_NAME , name ) ; parameters . put ( InputKeys . DESCRIPTION , description ) ; parameters . put ( InputKeys . PRIVACY_STATE , privacyState ) ; parameters . put ( InputKeys . DOCUMENT , document ) ; if ( campaignAndDocumentRoleMap != null ) { parameters . put ( InputKeys . DOCUMENT_CAMPAIGN_ROLE_LIST , StringUtils . mapToStringList ( campaignAndDocumentRoleMap , InputKeys . ENTITY_ROLE_SEPARATOR , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } if ( classAndDocumentRoleMap != null ) { parameters . put ( InputKeys . DOCUMENT_CLASS_ROLE_LIST , StringUtils . mapToStringList ( classAndDocumentRoleMap , InputKeys . ENTITY_ROLE_SEPARATOR , InputKeys . LIST_ITEM_SEPARATOR ) ) ; } try { return processJsonResponse ( makeRequest ( new URL ( url . toString ( ) + RequestBuilder . getInstance ( ) . getApiDocumentCreate ( ) ) , parameters , true ) , DocumentCreationRequest . KEY_DOCUMENT_ID ) ; } 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 ) ; } }
Creates a new document.
Creates a new document .