Changeset 487

Show
Ignore:
Timestamp:
05/16/06 16:01:01
Author:
douglm
Message:

Subscriptions to other users calendars now work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r484 r487  
    20432043      // Assume deleted 
    20442044      val.setCalendarDeleted(true); 
    2045       updateSubscription(val); 
     2045      if (val.getId() != CalFacadeDefs.unsavedItemKey) { 
     2046        // Save the state 
     2047        updateSubscription(val); 
     2048      } 
    20462049    } else { 
    20472050      val.setCalendar(calendar); 
  • trunk/calendar3/deployment/webuser/webapp/resources/demoskins/default/default/default.xsl

    r485 r487  
    29272927    <h3>Add Subscription to User Calendar</h3> 
    29282928    <p class="note">*the subsciption name must be unique</p> 
    2929     <form name="subscribeForm" action="{$subscriptions-subscribe}" onsubmit="return setSubscriptionUri(this)" method="post"> 
     2929    <form name="subscribeForm" action="{$subscriptions-initAdd}" onsubmit="return setSubscriptionUri(this)" method="post"> 
    29302930      <table class="common" cellspacing="0"> 
    29312931        <tr> 
    29322932          <td class="fieldname">Name:</td> 
    29332933          <td> 
    2934             <input type="text" value="" name="subscription.name" size="60"/> 
     2934            <input type="text" value="" name="name" size="60"/> 
    29352935          </td> 
    29362936        </tr> 
     
    29602960          <td class="fieldname">Display:</td> 
    29612961          <td> 
    2962             <input type="radio" value="true" name="subscription.display" checked="checked"/> yes 
    2963             <input type="radio" value="false" name="subscription.display"/> no 
     2962            <input type="radio" value="true" name="display" checked="checked"/> yes 
     2963            <input type="radio" value="false" name="display"/> no 
    29642964          </td> 
    29652965        </tr> 
     
    29672967          <td class="fieldname">Affects Free/Busy:</td> 
    29682968          <td> 
    2969             <input type="radio" value="true" name="subscription.affectsFreeBusy"/> yes 
    2970             <input type="radio" value="false" name="subscription.affectsFreeBusy" checked="checked"/> no 
     2969            <input type="radio" value="true" name="affectsFreeBusy"/> yes 
     2970            <input type="radio" value="false" name="affectsFreeBusy" checked="checked"/> no 
    29712971          </td> 
    29722972        </tr> 
     
    29742974          <td class="fieldname">Style:</td> 
    29752975          <td> 
    2976             <input type="text" value="" name="subscription.style" size="60"/> 
     2976            <input type="text" value="" name="style" size="60"/> 
    29772977          </td> 
    29782978        </tr> 
  • trunk/calendar3/webclient/war/WEB-INF/struts-config.xml

    r481 r487  
    629629      <forward name="noAccess" path="/subs/showSubs.rdo" redirect="true"/> 
    630630      <forward name="cancelled" path="/subs/showSubs.rdo" redirect="true"/> 
     631      <forward name="added" path="/subs/showModForm.rdo" redirect="true" /> 
    631632      <forward name="success" path="/subs/showModForm.rdo" redirect="true" /> 
    632633    </action> 
     
    642643 
    643644    <action    path="/subs/subscribe" 
    644                type="org.bedework.webcommon.subs.SubscribeAction" 
     645               type="org.bedework.webcommon.subs.EndSubscribeAction" 
    645646               name="calForm" 
    646647               scope="session" 
     
    650651      <forward name="reffed" path="/subs/showSubs.rdo" redirect="true"/> 
    651652      <forward name="noAccess" path="/subs/showSubs.rdo" redirect="true"/> 
     653      <forward name="added" path="/subs/showSubs.rdo" redirect="true" /> 
     654      <forward name="updated" path="/subs/showSubs.rdo" redirect="true" /> 
    652655      <forward name="success" path="/subs/showSubs.rdo" redirect="true" /> 
    653656    </action> 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r459 r487  
    8080import org.bedework.calsvci.CalSvcIPars; 
    8181 
     82import edu.rpi.sss.util.Util; 
    8283import edu.rpi.sss.util.jsp.UtilAbstractAction; 
    8384import edu.rpi.sss.util.jsp.UtilActionForm; 
     
    354355  } 
    355356 
     357  protected boolean validateSub(BwSubscription sub, 
     358                                BwActionFormBase form) { 
     359    sub.setName(Util.checkNull(sub.getName())); 
     360 
     361    if (sub.getName() == null) { 
     362      form.getErr().emit("org.bedework.validation.error.missingfield", "name"); 
     363      return false; 
     364    } 
     365 
     366    sub.setUri(Util.checkNull(sub.getUri())); 
     367 
     368    if (!sub.getInternalSubscription() && (sub.getUri() == null)) { 
     369      form.getErr().emit("org.bedework.validation.error.missingfield", "uri"); 
     370      return false; 
     371    } 
     372 
     373    return true; 
     374  } 
     375 
     376  /** Called to finish off adding or updating a subscription 
     377   * 
     378   * @param request 
     379   * @param sub 
     380   * @param form 
     381   * @return String "added" for added, "updated" for updated. 
     382   * @throws Throwable 
     383   */ 
     384  protected String finishSubscribe(HttpServletRequest request, 
     385                                   BwSubscription sub, 
     386                                   BwActionFormBase form) throws Throwable { 
     387    CalSvcI svc = form.fetchSvci(); 
     388    String forward; 
     389 
     390    String viewName = getReqPar(request, "view"); 
     391    boolean addToDefaultView = false; 
     392 
     393    if (viewName == null) { 
     394      addToDefaultView = true; 
     395      String str = getReqPar(request, "addtodefaultview"); 
     396      if (str != null) { 
     397        addToDefaultView = str.equals("y"); 
     398      } 
     399    } 
     400 
     401    Boolean bool = getBooleanReqPar(request, "unremoveable"); 
     402    if (bool != null) { 
     403      if (!form.getUserAuth().isSuperUser()) { 
     404        return "noAccess"; // Only super user for that flag 
     405      } 
     406 
     407      sub.setUnremoveable(bool.booleanValue()); 
     408    } 
     409 
     410    if (!validateSub(sub, form)) { 
     411      return "retry"; 
     412    } 
     413 
     414    if (getReqPar(request, "addSubscription") != null) { 
     415      try { 
     416        svc.addSubscription(sub); 
     417        forward = "added"; 
     418      } catch (CalFacadeException cfe) { 
     419        if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 
     420          form.getErr().emit(cfe.getMessage()); 
     421          return "success"; // User will see message and we'll stay on page 
     422        } 
     423 
     424        throw cfe; 
     425      } 
     426    } else if (getReqPar(request, "updateSubscription") != null) { 
     427      svc.updateSubscription(sub); 
     428      forward = "updated"; 
     429    } else { 
     430      forward = "noaction"; 
     431    } 
     432 
     433    if ((viewName == null) && !addToDefaultView) { 
     434      // We're done - not adding to a view 
     435      return forward; 
     436    } 
     437 
     438    if (sub != null) { 
     439      svc.addViewSubscription(viewName, sub); 
     440    } 
     441 
     442    form.setSubscriptions(svc.getSubscriptions()); 
     443 
     444    return forward; 
     445  } 
     446 
    356447  /** Find a user object given a "user" request parameter. 
    357448   * 
     
    359450   * @param form 
    360451   * @return BwUser     null if not found. Messages emitted 
     452   * @throws Throwable 
     453   */ 
     454  /** 
     455   * @param request 
     456   * @param form 
     457   * @return 
    361458   * @throws Throwable 
    362459   */ 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/EndSubscribeAction.java

    r486 r487  
    6363import org.bedework.webcommon.BwSession; 
    6464 
    65 import edu.rpi.sss.util.Util; 
    66  
    6765import java.util.Iterator; 
    6866 
     
    7068import javax.servlet.http.HttpServletResponse; 
    7169 
    72 /** Subscribe a user to a calendar. 
     70/** Complete or update a subscription to a calendar. 
    7371 * 
    7472 * <p>Parameters are:<ul> 
     
    9088 * @author Mike Douglass   douglm@rpi.edu 
    9189 */ 
    92 public class SubscribeAction extends BwAbstractAction { 
     90public class EndSubscribeAction extends BwAbstractAction { 
    9391  /* (non-Javadoc) 
    9492   * @see org.bedework.webcommon.BwAbstractAction#doAction(javax.servlet.http.HttpServletRequest, org.bedework.webcommon.BwSession, org.bedework.webcommon.BwActionFormBase) 
     
    106104    } 
    107105 
    108     BwSubscription sub = form.getSubscription(); 
    109  
    110     CalSvcI svc = form.fetchSvci(); 
    111  
    112     String viewName = getReqPar(request, "view"); 
    113     boolean addToDefaultView = false; 
    114  
    115     if (viewName == null) { 
    116       addToDefaultView = true; 
    117       String str = getReqPar(request, "addtodefaultview"); 
    118       if (str != null) { 
    119         addToDefaultView = str.equals("y"); 
    120       } 
    121     } 
    122  
    123     Boolean bool = getBooleanReqPar(request, "unremoveable"); 
    124     if (bool != null) { 
    125       if (!form.getUserAuth().isSuperUser()) { 
    126         return "noAccess"; // Only super user for that flag 
    127       } 
    128  
    129       sub.setUnremoveable(bool.booleanValue()); 
    130     } 
    131  
    132     if (!validateSub(sub, form)) { 
    133       return "retry"; 
    134     } 
    135  
    136     if (getReqPar(request, "addSubscription") != null) { 
    137       try { 
    138         svc.addSubscription(sub); 
    139       } catch (CalFacadeException cfe) { 
    140         if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 
    141           form.getErr().emit(cfe.getMessage()); 
    142           return "success"; // User will see message and we'll stay on page 
    143         } 
    144  
    145         throw cfe; 
    146       } 
    147     } else if (getReqPar(request, "updateSubscription") != null) { 
    148       svc.updateSubscription(sub); 
    149     } else { 
    150     } 
    151  
    152     if ((viewName == null) && !addToDefaultView) { 
    153       // We're done - not adding to a view 
    154       return "success"; 
    155     } 
    156  
    157     if (sub != null) { 
    158       svc.addViewSubscription(viewName, sub); 
    159     } 
    160  
    161     form.setSubscriptions(svc.getSubscriptions()); 
    162  
    163     return "success"; 
    164   } 
    165  
    166   private boolean validateSub(BwSubscription sub, 
    167                               BwActionFormBase form) { 
    168     sub.setName(Util.checkNull(sub.getName())); 
    169  
    170     if (sub.getName() == null) { 
    171       form.getErr().emit("org.bedework.validation.error.missingfield", "name"); 
    172       return false; 
    173     } 
    174  
    175     sub.setUri(Util.checkNull(sub.getUri())); 
    176  
    177     if (!sub.getInternalSubscription() && (sub.getUri() == null)) { 
    178       form.getErr().emit("org.bedework.validation.error.missingfield", "uri"); 
    179       return false; 
    180     } 
    181  
    182     return true; 
     106    return finishSubscribe(request, form.getSubscription(), form); 
    183107  } 
    184108 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java

    r446 r487  
    6464import javax.servlet.http.HttpServletResponse; 
    6565 
    66 /** Subscribe a user to a calendar. 
     66/** This should be called when we have a displayed list of calendars to which 
     67 * we can subscribe. We pass the path or uri and a subscription object is 
     68 * created and placed in the form. 
     69 * 
     70 * <p>This should then forward to a page which allows the user to set the rest 
     71 * of the subscrioption parameters. 
    6772 * 
    6873 * <p>Parameters are:<ul> 
     74 *      <li>"name"              Optional name of subscription</li> 
     75 *      <li>"display"           Optional setting for display flag</li> 
     76 *      <li>"affctsFreeBusy"    Optional setting for freebusy</li> 
    6977 *      <li>"calPath"           Path to local calendar</li> 
    7078 *      <li>"calUri"            URI of remote calendar</li> 
     
    100108    BwSubscription sub; 
    101109 
    102     // XXX Bogus??? Just use path for both. 
     110    boolean display = true; 
     111    Boolean flag = getBooleanReqPar(request, "display"); 
     112    if (flag != null) { 
     113      display = flag.booleanValue(); 
     114    } 
     115 
     116    boolean affectsFreeBusy = false; 
     117    flag = getBooleanReqPar(request, "affectsFreeBusy"); 
     118    if (flag != null) { 
     119      affectsFreeBusy = flag.booleanValue(); 
     120    } 
     121 
     122    String name = getReqPar(request, "name"); 
     123 
    103124    if (calPath == null) { 
    104       calUri = request.getParameter("calUri"); 
     125      calUri = getReqPar(request, "calUri"); 
    105126      if (calUri == null) { 
    106127        return "error"; 
    107128      } 
    108129 
    109       sub = BwSubscription.makeSubscription(calUri, null, false, false, false); 
     130      sub = BwSubscription.makeSubscription(calUri, name, display, 
     131                                            affectsFreeBusy, false); 
    110132 
    111133      /* Try to access the calendar */ 
     
    124146      } 
    125147 
    126       sub = BwSubscription.makeSubscription(cal, cal.getName(), false, false, false); 
     148      if (name == null) { 
     149        name = cal.getName(); 
     150      } 
     151 
     152      sub = BwSubscription.makeSubscription(cal, name, display, 
     153                                            affectsFreeBusy, false); 
     154    } 
     155 
     156    form.setSubscription(sub); 
     157 
     158    if (getReqPar(request, "addSubscription") != null) { 
     159      return finishSubscribe(request, sub, form); 
    127160    } 
    128161 
    129162    form.assignAddingSubscription(true); 
    130     form.setSubscription(sub); 
    131163 
    132164    return "success";