Skip to content

Commit

Permalink
Finished error checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
dabinett committed Apr 22, 2012
1 parent f7fde6a commit 3512084
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 4 deletions.
Binary file added gwt-unitCache/gwt-unitCache-00000136D73FB49F
Binary file not shown.
Binary file added gwt-unitCache/gwt-unitCache-00000136D742C83E
Binary file not shown.
Binary file added gwt-unitCache/gwt-unitCache-00000136D749D07C
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion src/edu/unlv/cs/whoseturn/server/UsersServiceImpl.java
Expand Up @@ -110,7 +110,7 @@ public String addNewUser(String username, String email, Boolean admin)
{
return errorMessage;
}

// A Valid username will return "Valid"
// An invalid username will return "Invalid username"
// A duplicate username will return "Username already exists"
Expand Down
25 changes: 23 additions & 2 deletions src/edu/unlv/cs/whoseturn/shared/FieldVerifier.java
Expand Up @@ -43,18 +43,19 @@ public static String isEmailValid(String email)
return errorMessage;
}


// The following checks for a duplicate email address in the database of current users
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(edu.unlv.cs.whoseturn.domain.User.class);

//List<String[]> resultStringList = new ArrayList<String[]>();
List<edu.unlv.cs.whoseturn.domain.User> results;

results = (List<edu.unlv.cs.whoseturn.domain.User>) query.execute();
if (!results.isEmpty())
{
for (edu.unlv.cs.whoseturn.domain.User e : results)
{
if (email == e.getEmail())
if (email.equals(e.getEmail()))
{
errorMessage = "Email already exists";
return errorMessage;
Expand All @@ -72,6 +73,7 @@ public static String isEmailValid(String email)
* @param username the username to validate
* @return true if valid, false if invalid
*/
@SuppressWarnings("unchecked")
public static String isUsernameValid(String username)
{
// The username can't be less than 3 characters
Expand All @@ -87,6 +89,25 @@ public static String isUsernameValid(String username)
errorMessage = "Username must be under 30 characters";
return errorMessage;
}

// The following checks for a duplicate username in the database of current users
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(edu.unlv.cs.whoseturn.domain.User.class);

List<edu.unlv.cs.whoseturn.domain.User> results;

results = (List<edu.unlv.cs.whoseturn.domain.User>) query.execute();
if (!results.isEmpty())
{
for (edu.unlv.cs.whoseturn.domain.User e : results)
{
if (username.equals(e.getUsername()))
{
errorMessage = "Username already exists";
return errorMessage;
}
}
}

// If we're here, the username is new and within the specified bounds
errorMessage = "Valid";
Expand Down
2 changes: 1 addition & 1 deletion war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -1,4 +1,4 @@
<!-- Indices written at Sat, 21 Apr 2012 22:26:15 UTC -->
<!-- Indices written at Sat, 21 Apr 2012 16:47:51 PDT -->

<datastore-indexes/>

Binary file modified war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown.
Binary file not shown.

0 comments on commit 3512084

Please sign in to comment.