src/org/ohmage/service/UserMobilityServices.java
public void requesterCanViewUsersMobilityData(
			final String requestersUsername, final String usersUsername) 
			throws ServiceException {
		
		try {
			if(requestersUsername.equals(usersUsername)) {
				return;
			}
			
			Set<String> campaignIds = userCampaignQueries.getCampaignIdsAndNamesForUser(usersUsername).keySet();
			for(String campaignId : campaignIds) {
				List<Campaign.Role> requestersCampaignRoles = userCampaignQueries.getUserCampaignRoles(requestersUsername, campaignId);
				
				if(requestersCampaignRoles.contains(Campaign.Role.SUPERVISOR)) {
					return;
				}
				else if(requestersCampaignRoles.contains(Campaign.Role.ANALYST) && 
						Campaign.PrivacyState.SHARED.equals(campaignQueries.getCampaignPrivacyState(campaignId))) {
					return;
				}
			}
			
			throw new ServiceException(
					ErrorCode.MOBILITY_INSUFFICIENT_PERMISSIONS, 
					"Insufficient permissions to read Mobility information about another user.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Checks if some "requesting" user can view Mobility data of another data.
	 * It may be that there is no data or that all data is private; therefore,
	 * while it is acceptable for a requester to view the data about another
	 * user, there is no data to view. For this to return true, one of the 
	 * following rules must be true:<br />
	 * <ul>
	 * <li>The requesting user is attempting to view the own Mobility data.
	 * </li>
	 * <li>The requesting user is a supervisor in any campaign to which the user
	 *   belongs.</li>
	 * <li>The requesting user is an analyst in any campaign to which the user
	 *   belongs and the campaign is shared.</li>
	 * </ul>
	 * 
	 * @param requestersUsername The username of the user that is attempting to
	 * 							 view data about another user.
	 * 
	 * @param usersUsername The username of the user whose information is being
	 * 						queried.
	 * 
	 * @throws ServiceException Thrown if the requesting user doesn't have
	 * 							sufficient permissions to read Mobility 
	 * 							information about another user or if there is
	 * 							an error.
	 */
Checks if some "requesting" user can view Mobility data of another data.
It may be that there is no data or that all data is private; therefore,
while it is acceptable for a requester to view the data about another
user, there is no data to view. For this to return true, one of the
following rules must be true:

The requesting user is attempting to view the own Mobility data.

The requesting user is a supervisor in any campaign to which the user
belongs.
The requesting user is an analyst in any campaign to which the user
belongs and the campaign is shared.


@param requestersUsername The username of the user that is attempting to
view data about another user.

@param usersUsername The username of the user whose information is being
queried.

@throws ServiceException Thrown if the requesting user doesn't have
sufficient permissions to read Mobility
information about another user or if there is
an error.
Checks if some " requesting " user can view Mobility data of another data . It may be that there is no data or that all data is private ; therefore while it is acceptable for a requester to view the data about another user there is no data to view . For this to return true one of the following rules must be true : The requesting user is attempting to view the own Mobility data . The requesting user is a supervisor in any campaign to which the user belongs . The requesting user is an analyst in any campaign to which the user belongs and the campaign is shared . @param requestersUsername The username of the user that is attempting to view data about another user . @param usersUsername The username of the user whose information is being queried . @throws ServiceException Thrown if the requesting user doesn ' t have sufficient permissions to read Mobility information about another user or if there is an error .
public void requesterCanViewUsersMobilityData(
			final String requestersUsername, final String usersUsername) 
			throws ServiceException {
		try {
			if(requestersUsername.equals(usersUsername)) {
				return;
			}
			Set<String> campaignIds = userCampaignQueries.getCampaignIdsAndNamesForUser(usersUsername).keySet();
			for(String campaignId : campaignIds) {
				List<Campaign.Role> requestersCampaignRoles = userCampaignQueries.getUserCampaignRoles(requestersUsername, campaignId);
				if(requestersCampaignRoles.contains(Campaign.Role.SUPERVISOR)) {
					return;
				}
				else if(requestersCampaignRoles.contains(Campaign.Role.ANALYST) && 
						Campaign.PrivacyState.SHARED.equals(campaignQueries.getCampaignPrivacyState(campaignId))) {
					return;
				}
			}
			throw new ServiceException(
					ErrorCode.MOBILITY_INSUFFICIENT_PERMISSIONS, 
					"Insufficient permissions to read Mobility information about another user.");
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void requesterCanViewUsersMobilityData ( final String requestersUsername , final String usersUsername ) throws ServiceException { try { if ( requestersUsername . equals ( usersUsername ) ) { return ; } Set < String > campaignIds = userCampaignQueries . getCampaignIdsAndNamesForUser ( usersUsername ) . keySet ( ) ; for ( String campaignId : campaignIds ) { List < Campaign . Role > requestersCampaignRoles = userCampaignQueries . getUserCampaignRoles ( requestersUsername , campaignId ) ; if ( requestersCampaignRoles . contains ( Campaign . Role . SUPERVISOR ) ) { return ; } else if ( requestersCampaignRoles . contains ( Campaign . Role . ANALYST ) && Campaign . PrivacyState . SHARED . equals ( campaignQueries . getCampaignPrivacyState ( campaignId ) ) ) { return ; } } throw new ServiceException ( ErrorCode . MOBILITY_INSUFFICIENT_PERMISSIONS , "Insufficient permissions to read Mobility information about another user." ) ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Checks if some "requesting" user can view Mobility data of another data.
Checks if some " requesting " user can view Mobility data of another data .