src/org/ohmage/service/SurveyResponseServices.java
public void deleteSurveyResponse(final UUID surveyResponseId) 
			throws ServiceException {
		
		try {
			List<UUID> imageIds = surveyResponseImageQueries.getImageIdsFromSurveyResponse(surveyResponseId);

			// TODO:
			// Here we are deleting the images then deleting the survey 
			// response. If this fails, the entire service is aborted, but the
			// individual services that deleted the images are not rolled back.
			// This leads to an appropriate division of labor in the code; 
			// otherwise, the deleteSurveyResponse() function would need to 
			// modify the url_based_resource table and file system. If an image
			// deletion fails, the survey response will exist, but the images 
			// from the survey response that were deleted will be deleted. Not 
			// all of them will be deleted, however; the one that caused the
			// exception will remain. While this may seem like an error, I felt
			// that it would be worse to have the user stuck in a situation 
			// where no images were being deleted than one where only part of a
			// survey response was deleted. If the user is trying to delete an
			// image, this will give them the chance to delete it even if 
			// another image and/or the survey response are causing a problem.
			for(UUID imageId : imageIds) {
				if(imageId != null) {
					imageQueries.deleteImage(imageId);
				}
			}
			
			surveyResponseQueries.deleteSurveyResponse(surveyResponseId);
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Deletes all of the images associated with a survey response then deletes
	 * the survey response itself.
	 * 
	 * @param surveyResponseId The survey response's unique identifier.
	 * 
	 * @throws ServiceException Thrown if there is an error.
	 */
Deletes all of the images associated with a survey response then deletes
the survey response itself.

@param surveyResponseId The survey response's unique identifier.

@throws ServiceException Thrown if there is an error.
Deletes all of the images associated with a survey response then deletes the survey response itself . @param surveyResponseId The survey response ' s unique identifier . @throws ServiceException Thrown if there is an error .
public void deleteSurveyResponse(final UUID surveyResponseId) 
			throws ServiceException {
		try {
			List<UUID> imageIds = surveyResponseImageQueries.getImageIdsFromSurveyResponse(surveyResponseId);
			for(UUID imageId : imageIds) {
				if(imageId != null) {
					imageQueries.deleteImage(imageId);
				}
			}
			surveyResponseQueries.deleteSurveyResponse(surveyResponseId);
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void deleteSurveyResponse ( final UUID surveyResponseId ) throws ServiceException { try { List < UUID > imageIds = surveyResponseImageQueries . getImageIdsFromSurveyResponse ( surveyResponseId ) ; for ( UUID imageId : imageIds ) { if ( imageId != null ) { imageQueries . deleteImage ( imageId ) ; } } surveyResponseQueries . deleteSurveyResponse ( surveyResponseId ) ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Deletes all of the images associated with a survey response then deletes
 the survey response itself.
Deletes all of the images associated with a survey response then deletes the survey response itself .
// TODO: // Here we are deleting the images then deleting the survey  // response. If this fails, the entire service is aborted, but the // individual services that deleted the images are not rolled back. // This leads to an appropriate division of labor in the code;  // otherwise, the deleteSurveyResponse() function would need to  // modify the url_based_resource table and file system. If an image // deletion fails, the survey response will exist, but the images  // from the survey response that were deleted will be deleted. Not  // all of them will be deleted, however; the one that caused the // exception will remain. While this may seem like an error, I felt // that it would be worse to have the user stuck in a situation  // where no images were being deleted than one where only part of a // survey response was deleted. If the user is trying to delete an // image, this will give them the chance to delete it even if  // another image and/or the survey response are causing a problem.