001: package hero.struts.actions;
002:
003: import java.io.IOException;
004: import javax.servlet.ServletException;
005: import javax.servlet.http.HttpServletRequest;
006: import javax.servlet.http.HttpServletResponse;
007: import org.apache.struts.action.ActionError;
008: import org.apache.struts.action.ActionErrors;
009: import org.apache.struts.action.ActionForm;
010: import org.apache.struts.action.ActionMapping;
011: import org.apache.struts.action.ActionForward;
012:
013: import hero.struts.forms.*;
014: import hero.interfaces.*;
015:
016: /**
017: * <strong>UserPreferencesAction</strong>
018: * Action that allows the admin to add new users
019: *
020: *@author Miguel Valdes Faura
021: */
022:
023: public class UserPreferencesAction extends AbstStrutsActionBase {
024: public boolean authenticate(String username, String password) {
025: return (true);
026: }
027:
028: /**
029: * @param mapping The ActionMapping used to select this instance
030: * @param actionForm The optional AbstActionFormBase bean for this request (if any)
031: * @param request The HTTP request we are processing
032: * @param response The HTTP response we are creating
033: * @exception IOException if an input/output error occurs
034: * @exception ServletException if a servlet exception occurs
035: */
036: public ActionForward perform(ActionMapping mapping,
037: ActionForm form, HttpServletRequest request,
038: HttpServletResponse response) throws IOException,
039: ServletException {
040: ActionForward actionForward;
041: // Create the container for any errors that occur
042: ActionErrors errors = new ActionErrors();
043:
044: actionForward = mapping.findForward(LOGIN);
045:
046: UserPreferencesForm upForm = (UserPreferencesForm) form;
047: String startMail = request.getParameter("startMail");
048: String startJabber = request.getParameter("startJabber");
049: String terminateMail = request.getParameter("terminateMail");
050: String terminateJabber = request
051: .getParameter("terminateJabber");
052: String addNodeMail = request.getParameter("addNodeMail");
053: String addNodeJabber = request.getParameter("addNodeJabber");
054: String addEdgeMail = request.getParameter("addEdgeMail");
055: String addEdgeJabber = request.getParameter("addEdgeJabber");
056: String nodeStateMail = request.getParameter("nodeStateMail");
057: String nodeStateJabber = request
058: .getParameter("nodeStateJabber");
059: String nodeDeadlineMail = request
060: .getParameter("nodeDeadlineMail");
061: String nodeDeadlineJabber = request
062: .getParameter("nodeDeadlineJabber");
063:
064: try {
065: hero.interfaces.UserRegistrationLocalHome userh = (UserRegistrationLocalHome) hero.interfaces.UserRegistrationUtil
066: .getLocalHome();
067: hero.interfaces.UserRegistrationLocal user = userh.create();
068: if (!isCancelled(request)) {
069:
070: String username = (String) request.getSession(true)
071: .getAttribute("newusername");
072:
073: user.setUserProperty(username,
074: hero.util.EventConstants.START + "Mail",
075: startMail);
076: user.setUserProperty(username,
077: hero.util.EventConstants.START + "Jabber",
078: startJabber);
079: user.setUserProperty(username,
080: hero.util.EventConstants.TERMINATED + "Mail",
081: terminateMail);
082: user.setUserProperty(username,
083: hero.util.EventConstants.TERMINATED + "Jabber",
084: terminateJabber);
085: user.setUserProperty(username,
086: hero.util.EventConstants.ADDNODE + "Mail",
087: addNodeMail);
088: user.setUserProperty(username,
089: hero.util.EventConstants.ADDNODE + "Jabber",
090: addNodeJabber);
091: user.setUserProperty(username,
092: hero.util.EventConstants.ADDEDGE + "Mail",
093: addEdgeMail);
094: user.setUserProperty(username,
095: hero.util.EventConstants.ADDEDGE + "Jabber",
096: addEdgeJabber);
097:
098: user.setUserProperty(username,
099: hero.util.EventConstants.SETNODESTATE + "Mail",
100: nodeStateMail);
101: user.setUserProperty(username,
102: hero.util.EventConstants.SETNODESTATE
103: + "Jabber", nodeStateJabber);
104: user.setUserProperty(username,
105: hero.util.EventConstants.SETNODEDEADLINE
106: + "Mail", nodeDeadlineMail);
107: user.setUserProperty(username,
108: hero.util.EventConstants.SETNODEDEADLINE
109: + "Jabber", nodeDeadlineJabber);
110: }
111:
112: } catch (Exception e1) {
113: errors.add("user_error", new ActionError(
114: "error.setProperty.mismatch"));
115: }
116: if (!errors.empty()) {
117: saveErrors(request, errors);
118: }
119:
120: // Forward control to the appropriate URI as determined by the action.
121: return (actionForward);
122: }
123: }
|