| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
package org.demosys.web.iteration.action; |
| 7 |
|
import javax.servlet.http.Cookie; |
| 8 |
|
import javax.servlet.http.HttpServletRequest; |
| 9 |
|
import javax.servlet.http.HttpServletResponse; |
| 10 |
|
import javax.swing.*; |
| 11 |
|
import org.apache.struts.action.Action; |
| 12 |
|
import org.apache.struts.action.ActionForm; |
| 13 |
|
import org.apache.struts.action.ActionForward; |
| 14 |
|
import org.apache.struts.action.ActionMapping; |
| 15 |
|
import org.demosys.web.ServiceLocator; |
| 16 |
|
import org.demosys.web.iteration.CreateIterationException; |
| 17 |
|
import org.demosys.web.iteration.IterationForm; |
| 18 |
|
|
| 19 |
|
|
| 20 |
0 |
public class NewIterationAction extends Action { |
| 21 |
|
public ActionForward execute(ActionMapping mapping, ActionForm objForm, |
| 22 |
|
HttpServletRequest request, HttpServletResponse response) { |
| 23 |
0 |
IterationForm form = (IterationForm)objForm; |
| 24 |
|
|
| 25 |
0 |
String result = null; |
| 26 |
|
|
| 27 |
|
try { |
| 28 |
0 |
ServiceLocator.getServiceLocator().getIterationService().newIteration(form |
| 29 |
|
.toIterationView()); |
| 30 |
|
|
| 31 |
0 |
String title = request.getParameter("title"); |
| 32 |
0 |
Cookie myCookieIteration = new Cookie("CookieTitle", title); |
| 33 |
0 |
myCookieIteration.setMaxAge(365 * 24 * 60 * 60); |
| 34 |
0 |
myCookieIteration.setPath("/"); |
| 35 |
0 |
response.addCookie(myCookieIteration); |
| 36 |
|
|
| 37 |
0 |
result = "success"; |
| 38 |
0 |
} |
| 39 |
|
catch (CreateIterationException e) { |
| 40 |
0 |
e.printStackTrace(); |
| 41 |
0 |
result = "failure"; |
| 42 |
0 |
} |
| 43 |
|
|
| 44 |
0 |
return mapping.findForward(result); |
| 45 |
|
} |
| 46 |
|
} |