Changeset 336

Show
Ignore:
Timestamp:
04/06/06 10:55:20
Author:
douglm
Message:

1. Add debug mode to user auth impl

2. Use shallow clone for calendar cloning. We weren't really cloning the children.

3. Add user mode to preferences. Not yet in db

4. Auto remove deleted subscription for extra simple user mode.

5. Remove unused unsubscribe action

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/access/src/edu/rpi/cct/uwcal/access/Acl.java

    r331 r336  
    138138    /** Was it succesful */ 
    139139    public boolean accessAllowed; 
     140     
     141    public String toString() { 
     142      StringBuffer sb = new StringBuffer("CurrentAccess{"); 
     143      sb.append("acl="); 
     144      sb.append(acl); 
     145       
     146      sb.append("accessAllowed="); 
     147      sb.append(accessAllowed); 
     148      sb.append("}"); 
     149 
     150      return sb.toString(); 
     151    } 
    140152  } 
    141153 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java

    r331 r336  
    457457    } 
    458458 
    459     BwCalendar cal = (BwCalendar)subroot.clone(); 
     459    BwCalendar cal = (BwCalendar)subroot.shallowClone(); 
    460460    // XXX Temp fix - add id to the clone 
    461461    cal.setId(subroot.getId()); 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/UserAuthUWDbImpl.java

    r256 r336  
    128128   */ 
    129129  public void initialise(String userid, CallBack cb, 
    130                          Object val) throws CalFacadeException { 
     130                         Object val, 
     131                         boolean debug) throws CalFacadeException { 
    131132    curUser = userid; 
    132133    this.cb = cb; 
     
    136137    } 
    137138    userAuthRO = null; 
    138     debug = getLogger().isDebugEnabled()
     139    this.debug = debug
    139140  } 
    140141 
     
    150151   */ 
    151152  public void initialise(String userid, CallBack cb, 
    152                          int val) throws CalFacadeException { 
     153                         int val, 
     154                         boolean debug) throws CalFacadeException { 
    153155    curUser = userid; 
    154156    this.cb = cb; 
     
    158160    } 
    159161    userAuthRO = null; 
    160     debug = getLogger().isDebugEnabled()
     162    this.debug = debug
    161163  } 
    162164 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwCalendar.java

    r320 r336  
    382382   * ==================================================================== */ 
    383383 
    384   /** Comapre this calendar and an object 
     384  /** Compare this calendar and an object 
    385385   * 
    386386   * @param  o    object to compare. 
     
    412412 
    413413    toStringSegment(sb); 
    414     sb.append("name="); 
     414    sb.append(", name="); 
    415415    sb.append(String.valueOf(getName())); 
    416416    sb.append(", path="); 
     
    424424    sb.append(", calendarCollection="); 
    425425    sb.append(String.valueOf(getCalendarCollection())); 
     426 
     427    sb.append(", children("); 
     428    Iterator it = iterateChildren(); 
     429    boolean donech = false; 
     430     
     431    while (it.hasNext()) { 
     432      BwCalendar ch = (BwCalendar)it.next(); 
     433       
     434      if (!donech) { 
     435        donech = true; 
     436      } else { 
     437        sb.append(", "); 
     438      } 
     439       
     440      sb.append(ch.getPath()); 
     441    } 
    426442    sb.append(")"); 
     443     
     444    if (getCurrentAccess() != null) { 
     445      sb.append(", currentAccess="); 
     446      sb.append(getCurrentAccess()); 
     447    } 
     448    sb.append("}"); 
    427449 
    428450    return sb.toString(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwShareableContainedDbentity.java

    r128 r336  
    139139  public void copyTo(BwShareableContainedDbentity val) { 
    140140    super.copyTo(val); 
    141     val.setCalendar((BwCalendar)getCalendar().clone()); 
     141    val.setCalendar((BwCalendar)getCalendar().shallowClone()); 
    142142  } 
    143143} 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwAuthUserPrefs.java

    r2 r336  
    509509 
    510510      while (it.hasNext()) { 
    511         nts.add((BwCalendar)((BwCalendar)it.next()).clone()); 
     511        nts.add((BwCalendar)((BwCalendar)it.next()).shallowClone()); 
    512512      } 
    513513    } 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java

    r2 r336  
    7979  private int workdayStart; 
    8080 
    81   /** Time in minutes for workday end, e.g. 17:30 is 1050 
     81  /* Time in minutes for workday end, e.g. 17:30 is 1050 
    8282   */ 
    8383  private int workdayEnd; 
    8484 
    85   /** When adding events do we prefer end date ("date") 
     85  /* When adding events do we prefer end date ("date") 
    8686   *  or duration ("duration"). Note the values this field takes 
    8787   *  are internal values only - not meant for display. 
    8888   */ 
    8989  private String preferredEndType; 
    90  
     90   
     91  /** Value identifying an extra simple user mode - we just do stuff without 
     92   * asking 
     93   */ 
     94  public static final int extraSimpleMode = 0; 
     95   
     96  /** Value identifying a simple user mode - we hide some stuff but make 
     97   * fewer assumptions 
     98   */ 
     99  public static final int simpleMode = 1; 
     100   
     101  /** Value identifying an advanced user mode - reveal it in all its glory 
     102   */ 
     103  public static final int advancedMode = 2; 
     104 
     105  private int userMode; 
     106   
    91107  /** Constructor 
    92108   * 
     
    275291  public String getPreferredEndType() { 
    276292    return preferredEndType; 
     293  } 
     294 
     295  /** 
     296   * @param val 
     297   */ 
     298  public void setUserMode(int val) { 
     299    userMode = val; 
     300  } 
     301 
     302  /** 
     303   * @return int user mode 
     304   */ 
     305  public int getUserMode() { 
     306    return userMode; 
    277307  } 
    278308 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/UserAuth.java

    r2 r336  
    148148   */ 
    149149  public void initialise(String userid, CallBack cb, 
    150                          Object val) throws CalFacadeException; 
     150                         Object val, 
     151                         boolean debug) throws CalFacadeException; 
    151152 
    152153  /** Initialise the implementing object with an access level. 
     
    172173   */ 
    173174  public void initialise(String userid, CallBack cb, 
    174                          int val) throws CalFacadeException; 
     175                         int val, 
     176                         boolean debug) throws CalFacadeException; 
    175177 
    176178  /** =================================================================== 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/UserAuthRO.java

    r2 r336  
    7171   */ 
    7272  public void initialise(String userid, CallBack cb, 
    73                          Object val) throws CalFacadeException { 
     73                         Object val, 
     74                         boolean debug) throws CalFacadeException { 
    7475    throw new CalFacadeException("Method not accessible"); 
    7576  } 
     
    9798   */ 
    9899  public void initialise(String userid, CallBack cb, 
    99                          int val) throws CalFacadeException { 
     100                         int val, 
     101                         boolean debug) throws CalFacadeException { 
    100102    throw new CalFacadeException("Method not accessible"); 
    101103  } 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r331 r336  
    465465  } 
    466466 
    467   public BwPreferences getUserPrefs() throws CalFacadeException { 
    468     return dbi.getPreferences(); 
    469   } 
    470  
    471   public BwPreferences getUserPrefs(BwUser user) throws CalFacadeException { 
    472     return dbi.fetchPreferences(user); 
    473   } 
    474  
    475   public void updateUserPrefs(BwPreferences  val) throws CalFacadeException { 
    476     dbi.updatePreferences(val); 
    477   } 
    478  
    479467  public UserAuth getUserAuth(String user, Object par) throws CalFacadeException { 
    480468    if (userAuth != null) { 
     
    490478    } 
    491479 
    492     userAuth.initialise(user, getUserAuthCallBack(), par); 
     480    userAuth.initialise(user, getUserAuthCallBack(), par, debug); 
    493481 
    494482    return userAuth; 
     
    558546    publicLastmod = lastmod; 
    559547    return true; 
     548  } 
     549 
     550  /* ==================================================================== 
     551   *                   Preferences 
     552   * ==================================================================== */ 
     553 
     554  public BwPreferences getUserPrefs() throws CalFacadeException { 
     555    return dbi.getPreferences(); 
     556  } 
     557 
     558  public BwPreferences getUserPrefs(BwUser user) throws CalFacadeException { 
     559    return dbi.fetchPreferences(user); 
     560  } 
     561 
     562  public void updateUserPrefs(BwPreferences  val) throws CalFacadeException { 
     563    dbi.updatePreferences(val); 
    560564  } 
    561565 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r331 r336  
    313313  public abstract Collection getInstanceOwners() throws CalFacadeException; 
    314314 
    315   /** Returns the current user preferences. 
    316    * 
    317    * @return BwPreferences   prefs for the current user 
    318    * @throws CalFacadeException 
    319    */ 
    320   public abstract BwPreferences getUserPrefs() throws CalFacadeException; 
    321  
    322   /** Returns the given user preferences. 
    323    * 
    324    * @param user 
    325    * @return BwPreferences   prefs for the given user 
    326    * @throws CalFacadeException 
    327    */ 
    328   public abstract BwPreferences getUserPrefs(BwUser user) throws CalFacadeException; 
    329  
    330   /** Update the current user preferences. 
    331    * 
    332    * @param  val     BwPreferences prefs for the current user 
    333    * @throws CalFacadeException 
    334    */ 
    335   public abstract void updateUserPrefs(BwPreferences val) throws CalFacadeException; 
    336  
    337315  /** Get a UserAuth object which allows the application to determine what 
    338316   * special rights the user has. 
     
    396374   */ 
    397375  public abstract boolean refreshNeeded() throws CalFacadeException; 
     376 
     377  /* ==================================================================== 
     378   *                   Preferences 
     379   * ==================================================================== */ 
     380 
     381  /** Returns the current user preferences. 
     382   * 
     383   * @return BwPreferences   prefs for the current user 
     384   * @throws CalFacadeException 
     385   */ 
     386  public abstract BwPreferences getUserPrefs() throws CalFacadeException; 
     387 
     388  /** Returns the given user preferences. 
     389   * 
     390   * @param user 
     391   * @return BwPreferences   prefs for the given user 
     392   * @throws CalFacadeException 
     393   */ 
     394  public abstract BwPreferences getUserPrefs(BwUser user) throws CalFacadeException; 
     395 
     396  /** Update the current user preferences. 
     397   * 
     398   * @param  val     BwPreferences prefs for the current user 
     399   * @throws CalFacadeException 
     400   */ 
     401  public abstract void updateUserPrefs(BwPreferences val) throws CalFacadeException; 
    398402 
    399403  /* ==================================================================== 
  • trunk/calendar3/synchml/src/edu/rpi/cct/uwcal/synchml/common/Synchml.java

    r310 r336  
    271271  public boolean deleteEvent(VEvent val) throws CalFacadeException { 
    272272    // FIXME - We need a subscription to the calendar we are synching - second par 
    273     return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(), null, null, val, debug).getEvent()); 
     273    return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(),  
     274                                           null,  // BwCalendar  
     275                                           null,  // overrides  
     276                                           val, debug).getEvent()); 
    274277  } 
    275278 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r331 r336  
    7272import org.bedework.calfacade.svc.BwAuthUserPrefs; 
    7373import org.bedework.calfacade.svc.BwSubscription; 
    74 import org.bedework.calfacade.svc.BwView; 
    7574import org.bedework.calfacade.svc.EventInfo; 
    7675import org.bedework.calfacade.svc.UserAuth; 
     
    292291    form.refreshIsNeeded(); 
    293292    return true; 
    294   } 
    295    
    296   protected String unsubscribe(HttpServletRequest request, 
    297                                  BwActionFormBase form) throws Throwable { 
    298     if (form.getGuest()) { 
    299       return "noAccess"; // First line of defence 
    300     } 
    301  
    302     CalSvcI svc = form.fetchSvci(); 
    303  
    304     String name = request.getParameter("name"); 
    305  
    306     if (name == null) { 
    307       // Assume no access 
    308       form.getErr().emit("org.bedework.client.error.missingfield", "name"); 
    309       return "error"; 
    310     } 
    311  
    312     BwSubscription sub = svc.findSubscription(name); 
    313  
    314     if (sub == null) { 
    315       form.getErr().emit("org.bedework.client.error.nosuchsubscription", name); 
    316       return "notFound"; 
    317     } 
    318      
    319     if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { 
    320       return "noAccess"; // Only super user can remove the unremovable 
    321     } 
    322      
    323         Iterator it = svc.getViews().iterator(); 
    324         boolean reffed = false; 
    325         while (it.hasNext()) { 
    326                 BwView v = (BwView)it.next(); 
    327                 if (v.getSubscriptions().contains(sub)) { 
    328                         form.getErr().emit("org.bedework.client.error.subscription.reffed",  
    329                                                        v.getName()); 
    330                         reffed = true; 
    331                 } 
    332         } 
    333          
    334         if (reffed) { 
    335                 return "reffed"; 
    336         } 
    337  
    338     svc.removeSubscription(sub); 
    339     form.getMsg().emit("org.bedework.client.message.subscription.removed"); 
    340     return "success"; 
    341293  } 
    342294 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java

    r324 r336  
    21582158  } 
    21592159} 
    2160  
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java

    r253 r336  
    5555 
    5656import org.bedework.calfacade.CalFacadeException; 
     57import org.bedework.calfacade.svc.BwPreferences; 
    5758import org.bedework.calfacade.svc.BwSubscription; 
     59import org.bedework.calfacade.svc.BwView; 
    5860import org.bedework.calsvci.CalSvcI; 
    5961import org.bedework.webcommon.BwAbstractAction; 
     
    6264 
    6365import edu.rpi.sss.util.Util; 
     66 
     67import java.util.Iterator; 
    6468 
    6569import javax.servlet.http.HttpServletRequest; 
     
    179183    return true; 
    180184  } 
     185   
     186  private String unsubscribe(HttpServletRequest request, 
     187                             BwActionFormBase form) throws Throwable { 
     188    CalSvcI svc = form.fetchSvci(); 
     189 
     190    String name = request.getParameter("name"); 
     191 
     192    if (name == null) { 
     193      // Assume no access 
     194      form.getErr().emit("org.bedework.client.error.missingfield", "name"); 
     195      return "error"; 
     196    } 
     197 
     198    BwSubscription sub = svc.findSubscription(name); 
     199 
     200    if (sub == null) { 
     201      form.getErr().emit("org.bedework.client.error.nosuchsubscription", name); 
     202      return "notFound"; 
     203    } 
     204     
     205    if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { 
     206      return "noAccess"; // Only super user can remove the unremovable 
     207    } 
     208     
     209    /* Check for references in views. For user extra simple mode only we will 
     210     * automatically remove the subscription. For others we list the references 
     211     */ 
     212     
     213    Iterator it = svc.getViews().iterator(); 
     214    boolean reffed = false; 
     215    boolean autoRemove = !getPublicAdmin(form) && 
     216      (svc.getUserPrefs().getUserMode() == BwPreferences.extraSimpleMode); 
     217     
     218    while (it.hasNext()) { 
     219      BwView v = (BwView)it.next(); 
     220      if (v.getSubscriptions().contains(sub)) { 
     221        if (autoRemove) { 
     222          if (!svc.removeViewSubscription(v.getName(), sub)) { 
     223            form.getErr().emit("org.bedework.client.error.viewnotfound",  
     224                               v.getName()); 
     225            return "error"; 
     226          } 
     227        } else { 
     228          form.getErr().emit("org.bedework.client.error.subscription.reffed",  
     229                             v.getName()); 
     230          reffed = true; 
     231        } 
     232      } 
     233    } 
     234     
     235    if (reffed) { 
     236      return "reffed"; 
     237    } 
     238 
     239    svc.removeSubscription(sub); 
     240    form.getMsg().emit("org.bedework.client.message.subscription.removed"); 
     241     
     242    /* Refetch to tidy up */ 
     243    form.setSubscriptions(svc.getSubscriptions()); 
     244 
     245    return "success"; 
     246  } 
    181247} 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/BaseTag.java

    r312 r336  
    5858import javax.servlet.jsp.tagext.TagSupport; 
    5959 
    60 import org.apache.struts.util.RequestUtils; 
     60import org.apache.struts.taglib.TagUtils; 
    6161 
    6262/** Base for simple Tags which provides some commonly used methods 
     
    7979      throws JspTagException { 
    8080    try { 
    81       Object o = RequestUtils.lookup(pageContext, name, property, scope); 
     81      Object o = TagUtils.getInstance().lookup(pageContext, name, property, scope); 
    8282      if (o == null) { 
    8383        if (required) { 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/views/UpdateViewAction.java

    r255 r336  
    128128      } 
    129129 
    130  
    131130      if (!svc.removeViewSubscription(name, sub)) { 
    132131        form.getErr().emit("org.bedework.client.error.viewnotfound", name);