src/org/ohmage/service/AccessRequestServices.java
public void createAccessRequest(
			final String requestId, 
			final String username,
			final String emailAddress,
			final String requestType,
			final JSONObject requestContent) 
			throws ServiceException {
		
		String defaultStatus = AccessRequest.getDefaultStatus().toString();
		
		try {			
			// Check whether the request already exists
			checkRequestExistence(requestId, false);
			
			// Check whether there are other pending request from the same user.
			// There can only be one PENDING request per type. 
			if (userSetupRequestQueries.getRequestExists(username, requestType, defaultStatus))
				throw new ServiceException(ErrorCode.USER_ACCESS_REQUEST_EXECUTION_ERROR,
						"There is already a pending request from the same user and type.");
			
			// user_setup request
			if (requestType.equals(AccessRequest.Type.USER_SETUP.toString())) {
			// Check whether the user already has the user setup privileges
			// (i.e. both class creation and user setup)
				if (userSetupRequestQueries.getUserSetupPrivilegesExist(username))
					throw new ServiceException(ErrorCode.USER_ACCESS_REQUEST_EXECUTION_ERROR,
							"The user already has the privileges.");
			}
			
			// Create a request with pending status
			userSetupRequestQueries.createAccessRequest(requestId, username, emailAddress, 
					requestContent, requestType, defaultStatus);
			

		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Creates a new user setup request in the system.
	 * 
	 * @param requestId The unique identifier for the new request.
	 * 
	 * @param username The username associated with the request.
	 * 
	 * @param emailAddress The user's email address.
	 * 
	 * @param requestContent The request content
	 * 
	 * @throws ServiceException Thrown if there is an error.
	 */
Creates a new user setup request in the system.

@param requestId The unique identifier for the new request.

@param username The username associated with the request.

@param emailAddress The user's email address.

@param requestContent The request content

@throws ServiceException Thrown if there is an error.
Creates a new user setup request in the system . @param requestId The unique identifier for the new request . @param username The username associated with the request . @param emailAddress The user ' s email address . @param requestContent The request content @throws ServiceException Thrown if there is an error .
public void createAccessRequest(
			final String requestId, 
			final String username,
			final String emailAddress,
			final String requestType,
			final JSONObject requestContent) 
			throws ServiceException {
		String defaultStatus = AccessRequest.getDefaultStatus().toString();
		try {			
			checkRequestExistence(requestId, false);
			if (userSetupRequestQueries.getRequestExists(username, requestType, defaultStatus))
				throw new ServiceException(ErrorCode.USER_ACCESS_REQUEST_EXECUTION_ERROR,
						"There is already a pending request from the same user and type.");
			if (requestType.equals(AccessRequest.Type.USER_SETUP.toString())) {
				if (userSetupRequestQueries.getUserSetupPrivilegesExist(username))
					throw new ServiceException(ErrorCode.USER_ACCESS_REQUEST_EXECUTION_ERROR,
							"The user already has the privileges.");
			}
			userSetupRequestQueries.createAccessRequest(requestId, username, emailAddress, 
					requestContent, requestType, defaultStatus);
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void createAccessRequest ( final String requestId , final String username , final String emailAddress , final String requestType , final JSONObject requestContent ) throws ServiceException { String defaultStatus = AccessRequest . getDefaultStatus ( ) . toString ( ) ; try { checkRequestExistence ( requestId , false ) ; if ( userSetupRequestQueries . getRequestExists ( username , requestType , defaultStatus ) ) throw new ServiceException ( ErrorCode . USER_ACCESS_REQUEST_EXECUTION_ERROR , "There is already a pending request from the same user and type." ) ; if ( requestType . equals ( AccessRequest . Type . USER_SETUP . toString ( ) ) ) { if ( userSetupRequestQueries . getUserSetupPrivilegesExist ( username ) ) throw new ServiceException ( ErrorCode . USER_ACCESS_REQUEST_EXECUTION_ERROR , "The user already has the privileges." ) ; } userSetupRequestQueries . createAccessRequest ( requestId , username , emailAddress , requestContent , requestType , defaultStatus ) ; } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Creates a new user setup request in the system.
Creates a new user setup request in the system .
// Check whether the request already exists // Check whether there are other pending request from the same user. // There can only be one PENDING request per type.  // user_setup request // Check whether the user already has the user setup privileges // (i.e. both class creation and user setup) // Create a request with pending status