public class UserRegistration { /** * Removes/Unregisters a user and all its content. * * @param pUserName the user name * @throws Exception if the user can not be deleted */ public void delete(String pUserName) throws Exception { try { DBAccess dba = (DBAccess)SessionContext.getCurrentSession().get("newDBAccess"); DBStorage dbsUser = new DBStorage(); dbsUser.setDBAccess(dba); dbsUser.setWritebackTable("USERS"); dbsUser.open(); List liBeans = dbsUser.fetchBean(new Equals("USERNAME", pUserName), null, 0, -1); //the username is unique and it's not possible that a user exists //more than once! if (liBeans.size() == 1) { //delete the user (db will cascade all user-data) dbsUser.delete(liBeans.get(0)); } else { throw new SecurityException("User '" + pUserName + "' was not found!"); } } catch (Throwable th) { throw new SecurityException("It's not possible to delete the user!", th); } } } // UserRegistration