Update of
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms
In directory
james.mmbase.org:/tmp/cvs-serv23684/src/java/com/finalist/cmsc/community/forms
Modified Files:
UserAddAction.java UserAddInitAction.java
Log Message:
cmsc-979,990 some changes about community module
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms
Index: UserAddAction.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms/UserAddAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- UserAddAction.java 10 May 2008 16:31:49 -0000 1.6
+++ UserAddAction.java 24 Jul 2008 09:05:18 -0000 1.7
@@ -17,6 +17,8 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
import com.finalist.cmsc.services.community.person.Person;
import com.finalist.cmsc.services.community.person.PersonService;
@@ -34,9 +36,11 @@
private static Log log = LogFactory.getLog(UserAddInitAction.class);
@Override
- public ActionForward execute(ActionMapping actionMapping, ActionForm
actionForm, HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse)
- throws Exception {
-
+ public ActionForward execute(ActionMapping actionMapping, ActionForm
actionForm, HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse) throws
Exception {
+ ActionMessages errors = new ActionMessages();
+ Long authId = null;
+ String tmpForward = (String)
httpServletRequest.getSession().getAttribute("forward");
if (!isCancelled(httpServletRequest)) {
UserForm userForm = (UserForm) actionForm;
@@ -48,20 +52,22 @@
PersonService ps = getPersonService();
if (userForm.getAction().equalsIgnoreCase(UserForm.ACTION_ADD)) {
- Long authenticationId =
as.getAuthenticationIdForUserId(accountName);
+
+ Long authenticationId =
as.getAuthenticationIdForUserId(userForm.getEmail());
if (authenticationId == null) {
Authentication authentication =
as.createAuthentication(userForm.getEmail(), userForm.getPasswordText());
- // Long authenticationId =
- // as.getAuthenticationIdForUserId(accountName);
if (authentication.getId() != null) {
- Person person = ps.createPerson(userForm.getFirstName(),
userForm.getPrefix(), userForm.getLastName(), authentication.getId());
- person.setEmail(userForm.getEmail()); // Also add an email
address to the user.
+ authId = authentication.getId();
+ Person person = ps
+
.createPerson(userForm.getFirstName(), userForm.getPrefix(),
userForm.getLastName(), authentication.getId());
+
person.setEmail(userForm.getEmail());
ps.updatePerson(person);
} else {
log.info("add authenticationId failed");
}
} else {
+ errors.add("email", new
ActionMessage("userform.email.exist"));
log.info("add check1 failed for: " + accountName);
}
@@ -79,12 +85,14 @@
// First retrieve the right person object from the database
Person person =
ps.getPersonByAuthenticationId(authenticationId);
- if (person == null) { // User did not exists, so create it.
+ if (person == null) { // User did not
exists, so create
+ // it.
person = new Person();
person.setAuthenticationId(authenticationId);
}
- // Also save other fields entered in the form to the right
person
+ // Also save other fields entered in
the form to the right
+ // person
// object
person.setFirstName(userForm.getFirstName());
person.setInfix(userForm.getPrefix());
@@ -103,10 +111,47 @@
}
} else {
log.info("cancelled");
+ ActionForward ret;
+ String newsletterId = (String)
httpServletRequest.getSession().getAttribute("newsletterId");
+ if (StringUtils.isNotBlank(tmpForward)) {
+ ret = new
ActionForward("/editors/newsletter/NewsletterPublicationSubscriberSearch.do?newsletterId="
+ +
httpServletRequest.getSession().getAttribute("newsletterId"));
+ ret.setRedirect(true);
+ } else {
+ ret = actionMapping.findForward(SUCCESS);
+ }
+ return ret;
+ }
+ if (errors.size() > 0) {
+ ActionForward ret = new
ActionForward("/editors/community/user.jsp");
+ saveErrors(httpServletRequest, errors);
+ return ret;
+ } else {
+ if ("newslettersubscribers".equals(tmpForward)) {
+ ActionForward ret = new
ActionForward(actionMapping.findForward("newslettersubscribers").getPath() +
"?newsletterId="
+ +
httpServletRequest.getSession().getAttribute("newsletterId"));
+
httpServletRequest.getSession().removeAttribute("forward");
+
httpServletRequest.getSession().removeAttribute("newsletterId");
+ ret.setRedirect(true);
+ return ret;
+ } else if ("newslettersubscription".equals(tmpForward))
{
+ ActionForward ret;
+ if (((UserForm)
actionForm).getAction().equalsIgnoreCase(UserForm.ACTION_ADD)) {
+ ret = new
ActionForward(actionMapping.findForward("newslettersubscription").getPath() +
"?newsletterId="
+ +
httpServletRequest.getSession().getAttribute("newsletterId") + "&authid=" +
authId);
+ ret.setRedirect(true);
+ } else {
+ ret = new
ActionForward(actionMapping.findForward("newslettersubscribers").getPath() +
"?newsletterId="
+ +
httpServletRequest.getSession().getAttribute("newsletterId"));
}
+
httpServletRequest.getSession().removeAttribute("forward");
+
httpServletRequest.getSession().removeAttribute("newsletterId");
+ ret.setRedirect(true);
+ return ret;
+ }
+ }
removeFromSession(httpServletRequest, actionForm);
-
return actionMapping.findForward(SUCCESS);
}
}
Index: UserAddInitAction.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/community/forms/UserAddInitAction.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- UserAddInitAction.java 31 Mar 2008 19:49:01 -0000 1.5
+++ UserAddInitAction.java 24 Jul 2008 09:05:18 -0000 1.6
@@ -12,6 +12,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
@@ -51,7 +52,7 @@
userForm.setAccount(auth.getUserId());
PersonService ps = getPersonService();
- //Returns null when no Person object was found!
+ // Returns null when no Person object was found!
Person person = ps.getPersonByAuthenticationId(auth.getId());
if (person != null) {
@@ -66,7 +67,15 @@
// new
userForm.setAction(UserForm.ACTION_ADD);
}
-
+ if (StringUtils.isNotBlank(request.getParameter("forward"))) {
+ // ActionForward ret= new
+ //
ActionForward(actionMapping.findForward(SUCCESS).getPath());
+ request.getSession().setAttribute("newsletterId",
request.getParameter("newsletterId"));
+ request.getSession().setAttribute("forward",
request.getParameter("forward"));
+ // return ret;
+ }
+ // else{
return actionMapping.findForward(SUCCESS);
+ // }
}
}
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs