View Javadoc
1 package com.gotjava.web.struts.actions; 2 3 import org.apache.struts.action.*; 4 import org.apache.commons.beanutils.PropertyUtils; 5 6 import javax.servlet.http.HttpServletRequest; 7 import javax.servlet.http.HttpServletResponse; 8 9 import com.gotjava.model.signon.JLCPUser; 10 import com.gotjava.model.calendar.CalendarEvent; 11 import com.gotjava.system.signon.HTTPUtils; 12 import com.gotjava.system.calendar.CalendarManager; 13 import com.gotjava.system.calendar.exceptions.CalendarException; 14 15 import java.text.SimpleDateFormat; 16 17 import java.util.Date; 18 import java.net.URL; 19 20 /*** 21 * Created by IntelliJ IDEA. 22 * User: farra 23 * Date: Apr 3, 2003 24 * Time: 4:20:57 AM 25 * To change this template use Options | File Templates. 26 */ 27 public class AddEventAction extends Action { 28 29 30 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 31 ActionErrors errors = new ActionErrors(); 32 33 JLCPUser user = HTTPUtils.getInstance().getCurrentUser(request); 34 if (user == null) { 35 return mapping.findForward("logon"); 36 } 37 38 /*** Retrieve all the properties from our form **/ 39 String link = (String) PropertyUtils.getSimpleProperty(form, "url"); 40 String summary = (String) PropertyUtils.getSimpleProperty(form, "summary"); 41 if (summary.length() > 3000) { 42 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.link.descTooBig")); 43 saveErrors(request, errors); 44 return mapping.findForward("failure"); 45 } 46 long categoryId = Long.parseLong(request.getParameter("categoryId")); 47 int priority = Integer.parseInt( request.getParameter("priority")); 48 String status = request.getParameter("status"); 49 String location = (String) PropertyUtils.getSimpleProperty(form, "location"); 50 51 String sdate = (String) PropertyUtils.getSimpleProperty(form, "startDate"); 52 String edate = (String) PropertyUtils.getSimpleProperty(form, "endDate"); 53 SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); 54 55 56 Date startDate = format.parse(sdate); 57 Date endDate = format.parse(edate); 58 59 CalendarEvent event = new CalendarEvent(); 60 61 event.setDtstart(startDate); 62 event.setDtend(endDate); 63 event.setSummary(summary); 64 event.setUser(user); 65 event.setUrl(link); 66 event.setCategory("0"+categoryId); 67 event.setStatus(status); 68 event.setLocation(location); 69 event.setPriority(priority); 70 71 /*** todo enable classifications **/ 72 event.setClassification("PRIVATE"); 73 try { 74 CalendarManager.getInstance().addEvent(event); 75 } catch (CalendarException e) { 76 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.calendar.persistanceError")); 77 saveErrors(request, errors); 78 return mapping.findForward("failure"); 79 } 80 return mapping.findForward("success"); 81 } 82 83 private final String USER_KEY = "jlcp.user"; 84 }

This page was automatically generated by Maven