private void validateUniquePerson(String firstName, String lastName, String email)
throws RegistrationException
{
Connection connection = null;
IStatement statement = null;
ResultSet set = null;
String trimmedEmail = email.trim().toLowerCase();
String trimmedLastName = lastName.trim().toLowerCase();
String trimmedFirstName = firstName.trim().toLowerCase();
try
{
connection = getConnection();
StatementAssembly assembly = new StatementAssembly();
assembly.newLine("SELECT PERSON_ID");
assembly.newLine("FROM PERSON");
assembly.newLine("WHERE ");
assembly.add("LOWER(EMAIL) = ");
assembly.addParameter(trimmedEmail);
statement = assembly.createStatement(connection);
set = statement.executeQuery();
if (set.next())
throw new RegistrationException("Email address is already in use by another user.");
close(null, statement, set);
assembly = new StatementAssembly();
assembly.newLine("SELECT PERSON_ID");
assembly.newLine("FROM PERSON");
assembly.newLine("WHERE ");
assembly.add("LOWER(FIRST_NAME) = ");
assembly.addParameter(trimmedFirstName);
assembly.addSep(" AND ");
assembly.add("LOWER(LAST_NAME) = ");
assembly.addParameter(trimmedLastName);
statement = assembly.createStatement(connection);
set = statement.executeQuery();
if (set.next())
throw new RegistrationException("Name provided is already in use by another user.");
}