Skip to content

Commit

Permalink
catch the "username too short" exception
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2844 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
allo committed Oct 22, 2006
1 parent f32db7e commit 5a64882
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions htroot/User_p.html
Expand Up @@ -97,6 +97,8 @@ <h2>User Administration</h2><br>
generic error.
::
Passwords do not match.
::
Username too short. Username must be >= 4 Charakters.
#(/error)#
<p />
If you want to manage more Users, return to the <a href="User_p.html?change_user=true&user=#[username]#">user</a> page.
Expand Down
13 changes: 9 additions & 4 deletions htroot/User_p.java
Expand Up @@ -150,10 +150,15 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
mem.put(userDB.Entry.DOWNLOAD_RIGHT, downloadRight);
mem.put(userDB.Entry.BLOG_RIGHT, blogRight);

entry=sb.userDB.createEntry(username, mem);
sb.userDB.addEntry(entry);
prop.put("page_text_username", username);
prop.put("page_text", 1);
try{
entry=sb.userDB.createEntry(username, mem);
sb.userDB.addEntry(entry);
prop.put("page_text_username", username);
prop.put("page_text", 1);
}catch(IllegalArgumentException e){
prop.put("page_error", 3);
}


} else { //edit user

Expand Down
4 changes: 2 additions & 2 deletions source/de/anomic/data/userDB.java
Expand Up @@ -127,7 +127,7 @@ public Entry getEntry(String userName) {
}
}

public Entry createEntry(String userName, HashMap userProps) {
public Entry createEntry(String userName, HashMap userProps) throws IllegalArgumentException{
Entry entry = new Entry(userName,userProps);
return entry;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ public class Entry {
private String userName;
private Calendar oldDate, newDate;

public Entry(String userName, Map mem) {
public Entry(String userName, Map mem) throws IllegalArgumentException {
if ((userName == null) || (userName.length() == 0))
throw new IllegalArgumentException("Username needed.");
if(userName.length()>128){
Expand Down

0 comments on commit 5a64882

Please sign in to comment.