public User removeUser(String userName, boolean broadcast) throws Exception {
if (log.isTraceEnabled()) {
Tools.logMethodIn(log, LogLevel.TRACE, "removeUser", new Object[] { "userName", userName, "broadcast", broadcast });
}
IdentitySession session = service_.getIdentitySession();
org.picketlink.idm.api.User foundUser = null;
try {
orgService.flush();
foundUser = session.getPersistenceManager().findUser(userName);
} catch (Exception e) {
handleException("Cannot obtain user: " + userName + "; ", e);
}
if (foundUser == null) {
return null;
}
try {
// Remove all memberships and profile first
orgService.getMembershipHandler().removeMembershipByUser(userName, false);
orgService.getUserProfileHandler().removeUserProfile(userName, false);
} catch (Exception e) {
handleException("Cannot cleanup user relationships: " + userName + "; ", e);
}
User exoUser = getPopulatedUser(userName, session);
if (broadcast) {
preDelete(exoUser);
}
try {
session.getPersistenceManager().removeUser(foundUser, true);
} catch (Exception e) {
handleException("Cannot remove user: " + userName + "; ", e);
}