src/org/ohmage/service/DocumentServices.java
public void ensureRoleNotLessThanRoles(final Document.Role role, 
			final Collection<Document.Role> roles) throws ServiceException {
		
		if(roles == null) {
			throw new IllegalArgumentException("The list of roles is null.");
		}
		
		if(Document.Role.OWNER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.OWNER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke document ownership when they are not an owner themselves.");
		}
		else if(Document.Role.WRITER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.WRITER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke the document write ability when they are not a document writer themselves.");
		}
		else if(Document.Role.READER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.READER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke the document read ability when they are not a document readers themselves.");
		}
		else if(roles.size() != 0) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke permissions when they are not associated with the document.");
		}
	}
/**
	 * Verifies that a role is not less than any of the other roles in a List
	 * of roles. If so, it will fail the request stating that the user is
	 * attempting to grant or revoke more permissions than they have. If the 
	 * role is null or not a valid role, this will still succeed if the list of
	 * roles is empty. If the List is null, it will throw an exception.
	 * 
	 * @param role The document role that cannot be less than any other roles 
	 * 			   in the List.
	 * 
	 * @param roles A List of document roles where no role can be greater than
	 * 				'role'.
	 * 
	 * @throws ServiceException Thrown if the role is less than some role in
	 * 							the List.
	 * 
	 * @throws IllegalArgumentException The List of roles is null.
	 */
Verifies that a role is not less than any of the other roles in a List
of roles. If so, it will fail the request stating that the user is
attempting to grant or revoke more permissions than they have. If the
role is null or not a valid role, this will still succeed if the list of
roles is empty. If the List is null, it will throw an exception.

@param role The document role that cannot be less than any other roles
in the List.

@param roles A List of document roles where no role can be greater than
'role'.

@throws ServiceException Thrown if the role is less than some role in
the List.

@throws IllegalArgumentException The List of roles is null.
Verifies that a role is not less than any of the other roles in a List of roles . If so it will fail the request stating that the user is attempting to grant or revoke more permissions than they have . If the role is null or not a valid role this will still succeed if the list of roles is empty . If the List is null it will throw an exception . @param role The document role that cannot be less than any other roles in the List . @param roles A List of document roles where no role can be greater than ' role ' . @throws ServiceException Thrown if the role is less than some role in the List . @throws IllegalArgumentException The List of roles is null .
public void ensureRoleNotLessThanRoles(final Document.Role role, 
			final Collection<Document.Role> roles) throws ServiceException {
		if(roles == null) {
			throw new IllegalArgumentException("The list of roles is null.");
		}
		if(Document.Role.OWNER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.OWNER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke document ownership when they are not an owner themselves.");
		}
		else if(Document.Role.WRITER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.WRITER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke the document write ability when they are not a document writer themselves.");
		}
		else if(Document.Role.READER.equals(role)) {
			return;
		}
		else if(roles.contains(Document.Role.READER)) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke the document read ability when they are not a document readers themselves.");
		}
		else if(roles.size() != 0) {
			throw new ServiceException(
					ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
					"The user is attempting to grant or revoke permissions when they are not associated with the document.");
		}
	}
public void ensureRoleNotLessThanRoles ( final Document . Role role , final Collection < Document . Role > roles ) throws ServiceException { if ( roles == null ) { throw new IllegalArgumentException ( "The list of roles is null." ) ; } if ( Document . Role . OWNER . equals ( role ) ) { return ; } else if ( roles . contains ( Document . Role . OWNER ) ) { throw new ServiceException ( ErrorCode . DOCUMENT_INSUFFICIENT_PERMISSIONS , "The user is attempting to grant or revoke document ownership when they are not an owner themselves." ) ; } else if ( Document . Role . WRITER . equals ( role ) ) { return ; } else if ( roles . contains ( Document . Role . WRITER ) ) { throw new ServiceException ( ErrorCode . DOCUMENT_INSUFFICIENT_PERMISSIONS , "The user is attempting to grant or revoke the document write ability when they are not a document writer themselves." ) ; } else if ( Document . Role . READER . equals ( role ) ) { return ; } else if ( roles . contains ( Document . Role . READER ) ) { throw new ServiceException ( ErrorCode . DOCUMENT_INSUFFICIENT_PERMISSIONS , "The user is attempting to grant or revoke the document read ability when they are not a document readers themselves." ) ; } else if ( roles . size ( ) != 0 ) { throw new ServiceException ( ErrorCode . DOCUMENT_INSUFFICIENT_PERMISSIONS , "The user is attempting to grant or revoke permissions when they are not associated with the document." ) ; } }
Verifies that a role is not less than any of the other roles in a List
 of roles.
Verifies that a role is not less than any of the other roles in a List of roles .