src/org/ohmage/service/UserCampaignServices.java
public void verifyUserCanGrantOrRevokeRoles(final String username, 
			final String campaignId, final Collection<Campaign.Role> roles) 
			throws ServiceException {
		
		try {
			List<Campaign.Role> usersRoles = userCampaignQueries.getUserCampaignRoles(username, campaignId);
			
			if(usersRoles.contains(Campaign.Role.SUPERVISOR)) {
				return;
			}
			
			if(usersRoles.contains(Campaign.Role.AUTHOR)) {
				if(! roles.contains(Campaign.Role.SUPERVISOR)) {
					return;
				}
				
				throw new ServiceException(
						ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
						"The user is not allowed to grant the supervisor privilege.");
			}
			
			throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"The user is not allowed to grant privileges.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Verifies that the user is allowed to grant or revoke all of the roles in
	 * the collection.
	 * 
	 * @param username The username of the user.
	 * 
	 * @param campaignId The unique identifier for the campaign where the user
	 * 					 is attempting to add or revoke roles.
	 * 
	 * @param roles The roles to check if the user can grant or revoke.
	 * 
	 * @throws ServiceException Thrown if the user is not allowed to grant or
	 * 							revoke some role or if there is an error.
	 */
Verifies that the user is allowed to grant or revoke all of the roles in
the collection.

@param username The username of the user.

@param campaignId The unique identifier for the campaign where the user
is attempting to add or revoke roles.

@param roles The roles to check if the user can grant or revoke.

@throws ServiceException Thrown if the user is not allowed to grant or
revoke some role or if there is an error.
Verifies that the user is allowed to grant or revoke all of the roles in the collection . @param username The username of the user . @param campaignId The unique identifier for the campaign where the user is attempting to add or revoke roles . @param roles The roles to check if the user can grant or revoke . @throws ServiceException Thrown if the user is not allowed to grant or revoke some role or if there is an error .
public void verifyUserCanGrantOrRevokeRoles(final String username, 
			final String campaignId, final Collection<Campaign.Role> roles) 
			throws ServiceException {
		try {
			List<Campaign.Role> usersRoles = userCampaignQueries.getUserCampaignRoles(username, campaignId);
			if(usersRoles.contains(Campaign.Role.SUPERVISOR)) {
				return;
			}
			if(usersRoles.contains(Campaign.Role.AUTHOR)) {
				if(! roles.contains(Campaign.Role.SUPERVISOR)) {
					return;
				}
				throw new ServiceException(
						ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
						"The user is not allowed to grant the supervisor privilege.");
			}
			throw new ServiceException(
					ErrorCode.CAMPAIGN_INSUFFICIENT_PERMISSIONS, 
					"The user is not allowed to grant privileges.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void verifyUserCanGrantOrRevokeRoles ( final String username , final String campaignId , final Collection < Campaign . Role > roles ) throws ServiceException { try { List < Campaign . Role > usersRoles = userCampaignQueries . getUserCampaignRoles ( username , campaignId ) ; if ( usersRoles . contains ( Campaign . Role . SUPERVISOR ) ) { return ; } if ( usersRoles . contains ( Campaign . Role . AUTHOR ) ) { if ( ! roles . contains ( Campaign . Role . SUPERVISOR ) ) { return ; } throw new ServiceException ( ErrorCode . CAMPAIGN_INSUFFICIENT_PERMISSIONS , "The user is not allowed to grant the supervisor privilege." ) ; } throw new ServiceException ( ErrorCode . CAMPAIGN_INSUFFICIENT_PERMISSIONS , "The user is not allowed to grant privileges." ) ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Verifies that the user is allowed to grant or revoke all of the roles in
 the collection.
Verifies that the user is allowed to grant or revoke all of the roles in the collection .