src/org/ohmage/service/UserCampaignServices.java
public void verifyCampaignXmlCanBeUpdated(
			final String username,
			final String campaignId,
			final String id,
			final String name) 
			throws ServiceException {
		
		try {
		    	// If the campaign already has survey responses, then it cannot be
			// updated by anyone.
			if(campaignSurveyResponseQueries
				.getNumberOfSurveyResponsesForCampaign(campaignId) != 0) {
				
				throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"Survey responses exist; therefore the XML can no longer be modified.");
			}
			
			// Check to ensure that the ID of the campaign hasn't changed.
			if(! campaignId.equals(id)) {
				throw new ServiceException(
					ErrorCode.CAMPAIGN_XML_HEADER_CHANGED, 
					"The campaign's ID in the new XML must be the same as the original XML.");
			}
			
			// Check to ensure that the name of the campaign hasn't changed.
			if(! campaignQueries.getName(campaignId).equals(name)) {
				throw new ServiceException(
					ErrorCode.CAMPAIGN_XML_HEADER_CHANGED, 
					"The campaign's name in the new XML must be the same as the original XML.");
			}
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Verifies that a user is allowed to update a campaign's XML.
	 *  
	 * @param username The username of the user.
	 * 
	 * @param campaignId The campaign's unique identifier.
	 * 
	 * @param id The ID from the new XML.
	 * 
	 * @param name The name from the new XML.
	 * 
	 * @throws ServiceException Thrown if the user isn't allowed to modify the
	 * 							campaign, if the user is allowed to modify the
	 * 							campaign but responses exist, or if there is an
	 * 							error.
	 */
Verifies that a user is allowed to update a campaign's XML.

@param username The username of the user.

@param campaignId The campaign's unique identifier.

@param id The ID from the new XML.

@param name The name from the new XML.

@throws ServiceException Thrown if the user isn't allowed to modify the
campaign, if the user is allowed to modify the
campaign but responses exist, or if there is an
error.
Verifies that a user is allowed to update a campaign ' s XML . @param username The username of the user . @param campaignId The campaign ' s unique identifier . @param id The ID from the new XML . @param name The name from the new XML . @throws ServiceException Thrown if the user isn ' t allowed to modify the campaign if the user is allowed to modify the campaign but responses exist or if there is an error .
public void verifyCampaignXmlCanBeUpdated(
			final String username,
			final String campaignId,
			final String id,
			final String name) 
			throws ServiceException {
		try {
			if(campaignSurveyResponseQueries
				.getNumberOfSurveyResponsesForCampaign(campaignId) != 0) {
				throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"Survey responses exist; therefore the XML can no longer be modified.");
			}
			if(! campaignId.equals(id)) {
				throw new ServiceException(
					ErrorCode.CAMPAIGN_XML_HEADER_CHANGED, 
					"The campaign's ID in the new XML must be the same as the original XML.");
			}
			if(! campaignQueries.getName(campaignId).equals(name)) {
				throw new ServiceException(
					ErrorCode.CAMPAIGN_XML_HEADER_CHANGED, 
					"The campaign's name in the new XML must be the same as the original XML.");
			}
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void verifyCampaignXmlCanBeUpdated ( final String username , final String campaignId , final String id , final String name ) throws ServiceException { try { if ( campaignSurveyResponseQueries . getNumberOfSurveyResponsesForCampaign ( campaignId ) != 0 ) { throw new ServiceException ( ErrorCode . CAMPAIGN_INSUFFICIENT_PERMISSIONS , "Survey responses exist; therefore the XML can no longer be modified." ) ; } if ( ! campaignId . equals ( id ) ) { throw new ServiceException ( ErrorCode . CAMPAIGN_XML_HEADER_CHANGED , "The campaign's ID in the new XML must be the same as the original XML." ) ; } if ( ! campaignQueries . getName ( campaignId ) . equals ( name ) ) { throw new ServiceException ( ErrorCode . CAMPAIGN_XML_HEADER_CHANGED , "The campaign's name in the new XML must be the same as the original XML." ) ; } } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Verifies that a user is allowed to update a campaign's XML.
Verifies that a user is allowed to update a campaign ' s XML .
// If the campaign already has survey responses, then it cannot be // updated by anyone. // Check to ensure that the ID of the campaign hasn't changed. // Check to ensure that the name of the campaign hasn't changed.