1 package hero.struts.actions; 2 3 import java.io.IOException ; 4 import javax.servlet.ServletException ; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 import org.apache.struts.action.ActionError; 8 import org.apache.struts.action.ActionErrors; 9 import org.apache.struts.action.ActionForm; 10 import org.apache.struts.action.ActionMapping; 11 import org.apache.struts.action.ActionForward; 12 13 import hero.struts.forms.*; 14 import hero.interfaces.*; 15 16 17 23 24 public class UserPreferencesAction extends AbstStrutsActionBase 25 { 26 public boolean authenticate(String username, String password) 27 { 28 return(true); 29 } 30 38 public ActionForward perform(ActionMapping mapping, ActionForm form, 39 HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 40 { 41 ActionForward actionForward; 42 ActionErrors errors = new ActionErrors(); 44 45 actionForward = mapping.findForward(LOGIN); 46 47 UserPreferencesForm upForm = (UserPreferencesForm) form; 48 String startMail = request.getParameter("startMail"); 49 String startJabber = request.getParameter("startJabber"); 50 String terminateMail = request.getParameter("terminateMail"); 51 String terminateJabber = request.getParameter("terminateJabber"); 52 String addNodeMail = request.getParameter("addNodeMail"); 53 String addNodeJabber = request.getParameter("addNodeJabber"); 54 String addEdgeMail = request.getParameter("addEdgeMail"); 55 String addEdgeJabber = request.getParameter("addEdgeJabber"); 56 String nodeStateMail = request.getParameter("nodeStateMail"); 57 String nodeStateJabber = request.getParameter("nodeStateJabber"); 58 String nodeDeadlineMail = request.getParameter("nodeDeadlineMail"); 59 String nodeDeadlineJabber = request.getParameter("nodeDeadlineJabber"); 60 61 62 try 63 { 64 hero.interfaces.UserRegistrationLocalHome userh = (UserRegistrationLocalHome)hero.interfaces.UserRegistrationUtil.getLocalHome(); 65 hero.interfaces.UserRegistrationLocal user = userh.create(); 66 if (!isCancelled(request)) 67 { 68 69 String username = (String )request.getSession(true).getAttribute("newusername"); 70 71 user.setUserProperty(username,hero.util.EventConstants.START+"Mail",startMail); 72 user.setUserProperty(username,hero.util.EventConstants.START+"Jabber",startJabber); 73 user.setUserProperty(username,hero.util.EventConstants.TERMINATED+"Mail",terminateMail); 74 user.setUserProperty(username,hero.util.EventConstants.TERMINATED+"Jabber",terminateJabber); 75 user.setUserProperty(username,hero.util.EventConstants.ADDNODE+"Mail",addNodeMail); 76 user.setUserProperty(username,hero.util.EventConstants.ADDNODE+"Jabber",addNodeJabber); 77 user.setUserProperty(username,hero.util.EventConstants.ADDEDGE+"Mail",addEdgeMail); 78 user.setUserProperty(username,hero.util.EventConstants.ADDEDGE+"Jabber",addEdgeJabber); 79 80 user.setUserProperty(username,hero.util.EventConstants.SETNODESTATE+"Mail",nodeStateMail); 81 user.setUserProperty(username,hero.util.EventConstants.SETNODESTATE+"Jabber",nodeStateJabber); 82 user.setUserProperty(username,hero.util.EventConstants.SETNODEDEADLINE+"Mail",nodeDeadlineMail); 83 user.setUserProperty(username,hero.util.EventConstants.SETNODEDEADLINE+"Jabber",nodeDeadlineJabber); 84 } 85 86 }catch(Exception e1){errors.add("user_error", new ActionError("error.setProperty.mismatch"));} 87 if (!errors.empty()) { 88 saveErrors(request, errors); 89 } 90 91 return (actionForward); 93 } 94 } 95
| Popular Tags
|