Changeset 453

Show
Ignore:
Timestamp:
05/05/06 10:34:40
Author:
douglm
Message:

Client code recognizes "newCalPath" for adding event ref. Needs stylesheet changes to work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventRefAction.java

    r441 r453  
    5656 
    5757import org.bedework.appcommon.BedeworkDefs; 
    58 import org.bedework.calfacade.BwCalendar; 
    59 import org.bedework.calfacade.BwEventProxy; 
    60 import org.bedework.calfacade.CalFacadeException; 
    61 import org.bedework.calfacade.svc.EventInfo; 
    62 import org.bedework.calsvci.CalSvcI; 
    6358 
    6459import javax.servlet.http.HttpServletRequest; 
     
    7065 * <p>Forwards to:<ul> 
    7166 *      <li>"doNothing"    when request seems wrong.</li> 
    72  *      <li>"notPersonal"  when this is not a personal calendar.</li> 
     67 *      <li>"eventNotFound"  no such event.</li> 
     68 *      <li>"calendarNotFound"  no such target calendar.</li> 
    7369 *      <li>"duplicate"    duplicate guid.</li> 
    7470 *      <li>"success"      added ok.</li> 
     
    8177  public String doAction(HttpServletRequest request, 
    8278                         BwActionForm form) throws Throwable { 
    83     if (form.getGuest()) { 
    84       return "doNothing"; 
     79    String fwd = addEventRef(request, form); 
     80    if (fwd != null) { 
     81      return fwd; 
    8582    } 
    8683 
    87     CalSvcI svci = form.fetchSvci(); 
     84    String start = form.getEditEvent().getDtstart().getDate().substring(0, 8); 
     85    BwGoToAction.gotoDateView(this, form, start, 
     86                              BedeworkDefs.dayView, debug); 
    8887 
    89     EventInfo ei = findEvent(request, form); 
     88    form.refreshIsNeeded(); 
    9089 
    91     if (ei == null) { 
    92       // Do nothing 
    93       return "doNothing"; 
    94     } 
    95  
    96     /* Create an event to act as a reference to the targeted event and copy 
    97      * the appropriate fields from the target 
    98      */ 
    99     BwEventProxy proxy = BwEventProxy.makeAnnotation(ei.getEvent(), 
    100                                                 ei.getEvent().getOwner()); 
    101  
    102     BwCalendar cal = svci.getPreferredCalendar(); 
    103     proxy.setOwner(svci.getUser()); 
    104  
    105     try { 
    106       svci.addEvent(cal, proxy, null); 
    107       form.getMsg().emit("org.bedework.client.message.added.eventrefs", 1); 
    108  
    109       BwGoToAction.gotoDateView(this, form, 
    110                                 proxy.getDtstart().getDate().substring(0, 8), 
    111                                 BedeworkDefs.dayView, 
    112                                 debug); 
    113  
    114       form.refreshIsNeeded(); 
    115  
    116       return "success"; 
    117     } catch (CalFacadeException cfe) { 
    118       if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) { 
    119         form.getErr().emit("org.bedework.client.error.duplicate.guid"); 
    120         return "duplicate"; 
    121       } 
    122  
    123       throw cfe; 
    124     } 
     90    return "success"; 
    12591  } 
    12692} 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r436 r453  
    6161import org.bedework.calfacade.BwCategory; 
    6262import org.bedework.calfacade.BwEvent; 
     63import org.bedework.calfacade.BwEventProxy; 
    6364import org.bedework.calfacade.BwLocation; 
    6465import org.bedework.calfacade.BwSponsor; 
     
    551552 
    552553  /** Refetch an event given a copy of that event. Calnedar guid and possibly 
    553    * recurrecne id must be set. 
     554   * recurrence id must be set. 
    554555   * 
    555556   * @param event   BwEvent to refetch 
     
    602603 
    603604    return ev; 
     605  } 
     606 
     607  /** Add an event ref. The calendar to add it to is defined by the request 
     608   * parameter newCalPath. 
     609   * 
     610   * @param request 
     611   * @param form 
     612   * @return String forward for an errot or null for OK. 
     613   * @throws Throwable 
     614   */ 
     615  protected String addEventRef(HttpServletRequest request, 
     616                               BwActionFormBase form) throws Throwable { 
     617    if (form.getGuest()) { 
     618      return "doNothing"; 
     619    } 
     620 
     621    CalSvcI svci = form.fetchSvci(); 
     622 
     623    EventInfo ei = findEvent(request, form); 
     624 
     625    if (ei == null) { 
     626      // Do nothing 
     627      return "eventNotFound"; 
     628    } 
     629 
     630    /* Create an event to act as a reference to the targeted event and copy 
     631     * the appropriate fields from the target 
     632     */ 
     633    BwEventProxy proxy = BwEventProxy.makeAnnotation(ei.getEvent(), 
     634                                                     ei.getEvent().getOwner()); 
     635    form.setEditEvent(proxy); // Make it available 
     636 
     637    String path = getReqPar(request, "newCalPath"); 
     638    BwCalendar cal; 
     639 
     640    if (path == null) { 
     641      cal = svci.getPreferredCalendar(); 
     642    } else { 
     643      cal = svci.getCalendar(path); 
     644      if (cal == null) { 
     645        form.getErr().emit("org.bedework.client.error.nosuchcalendar", path); 
     646        return "calendarNotFound"; 
     647      } 
     648    } 
     649    proxy.setOwner(svci.getUser()); 
     650 
     651    try { 
     652      svci.addEvent(cal, proxy, null); 
     653      form.getMsg().emit("org.bedework.client.message.added.eventrefs", 1); 
     654    } catch (CalFacadeException cfe) { 
     655      if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) { 
     656        form.getErr().emit("org.bedework.client.error.duplicate.guid"); 
     657        return "duplicate"; 
     658      } 
     659 
     660      throw cfe; 
     661    } 
     662 
     663    return null; 
    604664  } 
    605665 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/FetchCalendarAction.java

    r436 r453  
    7070 * 
    7171 * <p>Forwards to:<ul> 
    72  *      <li>"noAccess"     user not authorised.</li> 
    73  *      <li>"notFound"     no such event.</li> 
    74  *      <li>"continue"     continue on to update page.</li> 
     72 *      <li>"noAccess"       user not authorised.</li> 
     73 *      <li>"notFound"       no such calendar.</li> 
     74 *      <li>"continue"       continue on to update page.</li> 
    7575 * </ul> 
    7676 *