From d4e2a38b36571a211babd4bf5d25f101cd10acac Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 10 Aug 2004 21:06:31 +0000 Subject: [PATCH] - Don't delete accounts that are already deleted! - Don't use "-" when deleting accounts. - Truncate only after we've prepended the number and =. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1480 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/servlet/user/UserRepository.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java b/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java index 477aea99..49b5f8e6 100644 --- a/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java +++ b/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java @@ -344,6 +344,10 @@ public class UserRepository extends JORARepository public void deleteUser (final User user) throws PersistenceException { + if (user.isDeleted()) { + return; + } + execute(new Operation () { public Object invoke (Connection conn, DatabaseLiaison liaison) throws PersistenceException, SQLException @@ -357,20 +361,15 @@ public class UserRepository extends JORARepository // set the password to unusable user.password = ""; - String join = "="; - String newName = user.username; - if (newName.length() > 21) { - newName = newName.substring(0,21); - join = "-"; - } - // 'disable' their email address String newEmail = user.email.replace('@','#'); user.email = newEmail; + String oldName = user.username; for (int ii = 0; ii < 100; ii++) { try { - user.username = ii + join + newName; + user.username = StringUtil.truncate( + ii + "=" + oldName, 24); _utable.update(user, mask); return null; // nothing to return } catch (SQLException se) {