src/org/ohmage/service/UserCampaignServices.java
public void userCanDeleteCampaign(final String username, 
			final String campaignId) throws ServiceException {
		
		try {
			List<Campaign.Role> roles = userCampaignQueries.getUserCampaignRoles(username, campaignId);
			
			if(roles.contains(Campaign.Role.SUPERVISOR)) {
				return;
			}
			
			if(roles.contains(Campaign.Role.AUTHOR)) {
				long numberOfResponses = campaignSurveyResponseQueries.getNumberOfSurveyResponsesForCampaign(campaignId);
				
				if(numberOfResponses == 0) {
					return;
				}
				else {
					throw new ServiceException(
							ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
							"The campaign has responses; therefore, you can no longer delete it.");
				}
			}
			
			throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"You do not have sufficient permissoins to delete this campaign.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Ensures that the user can delete the campaign. At least one of the 
	 * following must be true to delete a campaign:
	 * <ul>
	 *   <li>The user is a supervisor.</li>
	 *   <li>The user is an author and there are no responses.</li>
	 * </ul>
	 * <br />
	 * 
	 * @param username The user's username.
	 * 
	 * @param campaignId The campaign's unique identifier.
	 * 
	 * @throws ServiceException Thrown if the user doesn't have sufficient
	 * 							permissions to delete the campaign or if there
	 * 							is an error.
	 */
Ensures that the user can delete the campaign. At least one of the
following must be true to delete a campaign:

The user is a supervisor.
The user is an author and there are no responses.



@param username The user's username.

@param campaignId The campaign's unique identifier.

@throws ServiceException Thrown if the user doesn't have sufficient
permissions to delete the campaign or if there
is an error.
Ensures that the user can delete the campaign . At least one of the following must be true to delete a campaign : The user is a supervisor . The user is an author and there are no responses . @param username The user ' s username . @param campaignId The campaign ' s unique identifier . @throws ServiceException Thrown if the user doesn ' t have sufficient permissions to delete the campaign or if there is an error .
public void userCanDeleteCampaign(final String username, 
			final String campaignId) throws ServiceException {
		try {
			List<Campaign.Role> roles = userCampaignQueries.getUserCampaignRoles(username, campaignId);
			if(roles.contains(Campaign.Role.SUPERVISOR)) {
				return;
			}
			if(roles.contains(Campaign.Role.AUTHOR)) {
				long numberOfResponses = campaignSurveyResponseQueries.getNumberOfSurveyResponsesForCampaign(campaignId);
				if(numberOfResponses == 0) {
					return;
				}
				else {
					throw new ServiceException(
							ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
							"The campaign has responses; therefore, you can no longer delete it.");
				}
			}
			throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"You do not have sufficient permissoins to delete this campaign.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void userCanDeleteCampaign ( final String username , final String campaignId ) throws ServiceException { try { List < Campaign . Role > roles = userCampaignQueries . getUserCampaignRoles ( username , campaignId ) ; if ( roles . contains ( Campaign . Role . SUPERVISOR ) ) { return ; } if ( roles . contains ( Campaign . Role . AUTHOR ) ) { long numberOfResponses = campaignSurveyResponseQueries . getNumberOfSurveyResponsesForCampaign ( campaignId ) ; if ( numberOfResponses == 0 ) { return ; } else { throw new ServiceException ( ErrorCode . CAMPAIGN_INSUFFICIENT_PERMISSIONS , "The campaign has responses; therefore, you can no longer delete it." ) ; } } throw new ServiceException ( ErrorCode . CAMPAIGN_INSUFFICIENT_PERMISSIONS , "You do not have sufficient permissoins to delete this campaign." ) ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Ensures that the user can delete the campaign.
Ensures that the user can delete the campaign .