public void removeUser(Principal principal)
throws JetspeedSecurityException
{
if (systemUsers.contains(principal.getName()))
{
throw new UserException("[" + principal.getName() + "] is a system user and cannot be removed");
}
JetspeedUser user = getUser(principal);
Criteria criteria = new Criteria();
if (principal instanceof UserNamePrincipal)
{
criteria.add(TurbineUserPeer.LOGIN_NAME, principal.getName());
}
else if (principal instanceof UserIdPrincipal)
{
criteria.add(TurbineUserPeer.USER_ID, principal.getName());
}
else
{
throw new UserException("Invalid Principal Type in removeUser: " + principal.getClass().getName());
}
try
{
TurbineUserPeer.doDelete(criteria);
PsmlManager.removeUserDocuments(user);
}
catch(Exception e)
{
String message = "Failed to remove account '" + user.getUserName() + "'";
logger.error( message, e );
throw new UserException( message, e );
}
}