package org.nemesis.forum.webapp.admin.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.nemesis.forum.ForumFactory;
import org.nemesis.forum.ProfileManager;
import org.nemesis.forum.User;
import org.nemesis.forum.exception.NotFoundException;
import org.nemesis.forum.exception.UnauthorizedException;
public class DelUserAction extends BaseAction {
static protected Log log =LogFactory.getLog(DelUserAction.class);
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
//check logon
checkUser(request);
//check permission
checkPermission(request,OperationConstants.DELETE_USER);
ActionErrors errors = new ActionErrors();
try {
try {
ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
ProfileManager manager = forumFactory.getProfileManager();
User u = manager.getUser(Integer.parseInt(request.getParameter("id")));
manager.deleteUser(u);
errors.add("general", new ActionError("delUser.confirm"));
}
catch( NotFoundException fnfe ) {
errors.add("general", new ActionError("delUser.notFound"));
}
catch( UnauthorizedException ue ) {
errors.add("general", new ActionError("delUser.unauthorized"));
}
} catch (Exception e) {
String eid=this.getClass().getName()+"_"+System.currentTimeMillis();
log.error("eid:"+eid +"\nsessionID" +request.getSession().getId(),e) ;
errors.add("general", new ActionError("error.general","error id:"+eid));
}
saveErrors(request, errors);
return mapping.findForward("success");
}
}