/**
 * @author dgeorge
 * 
 * $Id: AdminEditUserPopulateAction.java,v 1.4 2005-10-28 12:47:26 georgeda Exp $
 * 
 * $Log: not supported by cvs2svn $
 * Revision 1.3  2005/10/24 13:28:17  georgeda
 * Cleanup changes
 *
 * Revision 1.2  2005/10/17 16:30:24  georgeda
 * Cleanup
 *
 * Revision 1.1  2005/10/17 13:28:45  georgeda
 * Initial revision
 *
 *
 */
package gov.nih.nci.camod.webapp.action;

import java.util.Enumeration;

import gov.nih.nci.camod.domain.Person;
import gov.nih.nci.camod.service.impl.PersonManagerSingleton;
import gov.nih.nci.camod.webapp.form.EditUserForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.*;

/**
 * 
 * Used to populate the form used to assign roles to a user.
 * 
 */
public class AdminEditUserPopulateAction extends BaseAction {

	/**
	 * Action used to populate the various admin lists for the curation process
	 */
	public ActionForward execute(ActionMapping inMapping, ActionForm inForm, HttpServletRequest inRequest,
			HttpServletResponse inResponse) throws Exception {

		log.trace("Entering execute");

		EditUserForm theForm = (EditUserForm) inForm;

		String theAction = (String) inRequest.getParameter("action");

           Enumeration theEnum = inRequest.getParameterNames();
            
            while(theEnum.hasMoreElements())
            {
                System.out.println(theEnum.nextElement());
            }
            
		String theForward = "next";

		// Add a brand new user
		if (theAction.equals("Add")) {
			theForm.setLastName(null);
			theForm.setFirstName(null);
			theForm.setUsername(null);
			theForm.setId(null);
			theForm.setPrincipalInvestigator(false);
		} 
		
		// Update an existing user
		else {
			try {

				Person thePerson = PersonManagerSingleton.instance().get(theForm.getId());

				if (thePerson == null) {
					throw new IllegalArgumentException("Unknown user id: " + theForm.getId());
				}

				theForm.setLastName(thePerson.getLastName());
				theForm.setFirstName(thePerson.getFirstName());
				theForm.setUsername(thePerson.getUsername());

				Boolean isPI = thePerson.getIsPrincipalInvestigator();

				if (isPI != null) {
					theForm.setPrincipalInvestigator(isPI.booleanValue());
				} else {
					theForm.setPrincipalInvestigator(false);
				}

			} catch (Exception e) {

				theForward = "failure";
				log.error("Unable to get user: ", e);

				// Encountered an error saving the model.
				// created a new model successfully
				ActionMessages theMsg = new ActionMessages();
				theMsg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.admin.message"));
				saveErrors(inRequest, theMsg);
			}
		}
		log.trace("Exiting execute");

		return inMapping.findForward(theForward);
	}
}
@@ -69,29 +69,29 @@
 v 1.
-4
+5
  2005-1
-0-28 12:47:26
+1-11 15:38:47
  geo
@@ -142,16 +142,96 @@
 s2svn $%0A
+ * Revision 1.4  2005/10/28 12:47:26  georgeda%0A * Added delete functionality%0A *%0A
  * Revis
@@ -482,32 +482,37 @@
 ort 
-java.util.Enumeration
+gov.nih.nci.camod.Constants
 ;%0A
-%0A
 impo
@@ -605,24 +605,24 @@
 rSingleton;%0A
-
 import gov.n
@@ -661,16 +661,47 @@
 rForm;%0A%0A
+import java.util.Enumeration;%0A%0A
 import j
@@ -1348,16 +1348,35 @@
 ter(
-%22action%22
+Constants.Parameters.ACTION
 );%0A%0A

Use constant for action