Update of /var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms In directory james.mmbase.org:/tmp/cvs-serv23782/community/src/java/com/finalist/cmsc/community/forms
Modified Files: UserAddInitAction.java Log Message: first working See also: http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms Index: UserAddInitAction.java =================================================================== RCS file: /var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms/UserAddInitAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- UserAddInitAction.java 29 Jan 2008 09:59:40 -0000 1.2 +++ UserAddInitAction.java 31 Jan 2008 13:47:27 -0000 1.3 @@ -1,28 +1,66 @@ /* -This software is OSI Certified Open Source Software. -OSI Certified is a certification mark of the Open Source Initiative. + This software is OSI Certified Open Source Software. + OSI Certified is a certification mark of the Open Source Initiative. -The license (Mozilla version 1.0) can be read at the MMBase site. -See http://www.MMBase.org/license + The license (Mozilla version 1.0) can be read at the MMBase site. + See http://www.MMBase.org/license -*/package com.finalist.cmsc.community.forms; + */ +package com.finalist.cmsc.community.forms; 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.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import com.finalist.cmsc.services.community.person.Person; +import com.finalist.cmsc.services.community.person.PersonService; +import com.finalist.cmsc.services.community.security.Authentication; +import com.finalist.cmsc.services.community.security.AuthenticationService; + /** * @author Remco Bos + * @author Wouter Heijke */ public class UserAddInitAction extends AbstractCommunityAction { + private static Log log = LogFactory.getLog(UserAddInitAction.class); + + public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse httpServletResponse) throws Exception { + + String id = request.getParameter(USERID); + UserForm userForm = (UserForm) actionForm; + if (id != null) { + userForm.setAction(ACTION_EDIT); + + AuthenticationService as = getAuthenticationService(); + Authentication auth = as.findAuthentication(id); + if (auth != null) { + userForm.setEmail(auth.getUserId()); + + PersonService ps = getPersonService(); + Person person = ps.getPersonByUserId(id); + if (person != null) { + userForm.setVoornaam(person.getFirstName()); + userForm.setTussenVoegsels(person.getInfix()); + userForm.setAchterNaam(person.getLastName()); + } else { + log.info("person failed"); + } + } else { + log.info("auth failed"); + } + + } else { + // new + userForm.setAction(ACTION_ADD); + } - public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { - UserForm userForm = (UserForm)actionForm; - userForm.setAction("add"); - return actionMapping.findForward("success"); + return actionMapping.findForward(SUCCESS); } } \ No newline at end of file _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs