src/org/ohmage/service/SurveyResponseServices.java
public void verifyMediaFilesForMediaPromptResponses(
			final Class<? extends MediaPromptResponse> mediaClass,
			final Collection<SurveyResponse> surveyResponses,
			final Map<UUID, ? extends IMedia> mediaMap) 
			throws ServiceException {
		
			
		for(SurveyResponse surveyResponse : surveyResponses) {
			for(Response promptResponse : surveyResponse.getResponses().values()) {
				if (mediaClass.isInstance(promptResponse))	{
					Object responseValue = promptResponse.getResponse();
					if(responseValue instanceof UUID) {
						if (mediaMap.containsKey(responseValue)) {
							// validate the media against the xml
							try {
								PromptResponse pr = (PromptResponse)promptResponse;
								MediaPrompt dp = (MediaPrompt) (pr.getPrompt());
								dp.validateMediaFileSize(mediaMap.get(responseValue));
							} catch (DomainException e){
								throw new ServiceException(e);
							} catch (Exception e) {
								throw new ServiceException("Can't convert prompt to MediaPrompt", e);
							}	
							
						} else { // no media content
							throw new ServiceException(
									ErrorCode.SURVEY_INVALID_RESPONSES, 
									"A file was missing for a " + mediaClass.getSimpleName() + " prompt response: " + 
											responseValue.toString());
						}
					}
						
				} 
			}
		}
			
	}
/**
	 * Verifies that, for each media prompt responses, a corresponding file/object
	 * exists in the list of media files, and the file doesn't violate the 
	 * prompt definition.
	 * 
	 * @param 	mediaClass The particular media class that we are checking against
	 * 
	 * @param	surveyResponses The survey responses.
	 * 
	 * @param	mediaMap A map of media ID to media content
	 * 
	 * @throws ServiceException Thrown if a prompt response exists but its
	 * 							corresponding contents don't.
	 */
Verifies that, for each media prompt responses, a corresponding file/object
exists in the list of media files, and the file doesn't violate the
prompt definition.

@param       mediaClass The particular media class that we are checking against

@param       surveyResponses The survey responses.

@param       mediaMap A map of media ID to media content

@throws ServiceException Thrown if a prompt response exists but its
corresponding contents don't.
Verifies that for each media prompt responses a corresponding file / object exists in the list of media files and the file doesn ' t violate the prompt definition . @param mediaClass The particular media class that we are checking against @param surveyResponses The survey responses . @param mediaMap A map of media ID to media content @throws ServiceException Thrown if a prompt response exists but its corresponding contents don ' t .
public void verifyMediaFilesForMediaPromptResponses(
			final Class<? extends MediaPromptResponse> mediaClass,
			final Collection<SurveyResponse> surveyResponses,
			final Map<UUID, ? extends IMedia> mediaMap) 
			throws ServiceException {
		for(SurveyResponse surveyResponse : surveyResponses) {
			for(Response promptResponse : surveyResponse.getResponses().values()) {
				if (mediaClass.isInstance(promptResponse))	{
					Object responseValue = promptResponse.getResponse();
					if(responseValue instanceof UUID) {
						if (mediaMap.containsKey(responseValue)) {
							try {
								PromptResponse pr = (PromptResponse)promptResponse;
								MediaPrompt dp = (MediaPrompt) (pr.getPrompt());
								dp.validateMediaFileSize(mediaMap.get(responseValue));
							} catch (DomainException e){
								throw new ServiceException(e);
							} catch (Exception e) {
								throw new ServiceException("Can't convert prompt to MediaPrompt", e);
							}	
						} else { 
							throw new ServiceException(
									ErrorCode.SURVEY_INVALID_RESPONSES, 
									"A file was missing for a " + mediaClass.getSimpleName() + " prompt response: " + 
											responseValue.toString());
						}
					}
				} 
			}
		}
	}
public void verifyMediaFilesForMediaPromptResponses ( final Class < ? extends MediaPromptResponse > mediaClass , final Collection < SurveyResponse > surveyResponses , final Map < UUID , ? extends IMedia > mediaMap ) throws ServiceException { for ( SurveyResponse surveyResponse : surveyResponses ) { for ( Response promptResponse : surveyResponse . getResponses ( ) . values ( ) ) { if ( mediaClass . isInstance ( promptResponse ) ) { Object responseValue = promptResponse . getResponse ( ) ; if ( responseValue instanceof UUID ) { if ( mediaMap . containsKey ( responseValue ) ) { try { PromptResponse pr = ( PromptResponse ) promptResponse ; MediaPrompt dp = ( MediaPrompt ) ( pr . getPrompt ( ) ) ; dp . validateMediaFileSize ( mediaMap . get ( responseValue ) ) ; } catch ( DomainException e ) { throw new ServiceException ( e ) ; } catch ( Exception e ) { throw new ServiceException ( "Can't convert prompt to MediaPrompt" , e ) ; } } else { throw new ServiceException ( ErrorCode . SURVEY_INVALID_RESPONSES , "A file was missing for a " + mediaClass . getSimpleName ( ) + " prompt response: " + responseValue . toString ( ) ) ; } } } } } }
Verifies that, for each media prompt responses, a corresponding file/object
 exists in the list of media files, and the file doesn't violate the
 prompt definition.
Verifies that for each media prompt responses a corresponding file / object exists in the list of media files and the file doesn ' t violate the prompt definition .
// validate the media against the xml // no media content