Changeset 360

Show
Ignore:
Timestamp:
04/10/06 22:53:39
Author:
douglm
Message:

Don't use Trash to store deleted event annotations. Instead store in special calendar "Deleted"
That way we don't have to take any special actions when emptying trash

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java

    r336 r360  
    8282   * @throws CalFacadeException 
    8383   */ 
    84   public Calendars(Calintf cal, AccessUtil access,  
     84  public Calendars(Calintf cal, AccessUtil access, 
    8585                   int currentMode, boolean debug) 
    8686                  throws CalFacadeException { 
     
    178178    usercal.addChild(cal); 
    179179 
     180    /* Add the deleted calendar */ 
     181    cal = new BwCalendar(); 
     182    // XXX new syspar cal.setName(getSyspars().getUserOutbox()); 
     183    cal.setName("Deleted"); 
     184    cal.setCreator(user); 
     185    cal.setOwner(user); 
     186    cal.setPublick(false); 
     187    // XXX new syspar cal.setPath(path + "/" + getSyspars().getUserOutbox()); 
     188    cal.setPath(path + "/" + "Deleted"); 
     189    cal.setCalendar(usercal); 
     190    cal.setCalendarCollection(true); 
     191    usercal.addChild(cal); 
     192 
    180193    sess.save(usercal); 
    181194 
     
    313326  } 
    314327 
     328  public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
     329    StringBuffer sb = new StringBuffer(); 
     330 
     331    sb.append("/"); 
     332    sb.append(getSyspars().getUserCalendarRoot()); 
     333    sb.append("/"); 
     334    sb.append(user.getAccount()); 
     335    sb.append("/"); 
     336    sb.append("Deleted"); 
     337    // XXX new syspar sb.append(getSyspars().getDefaultTrashCalendar()); 
     338 
     339    return getCalendar(sb.toString()); 
     340  } 
     341 
     342  public void createDeletedCalendar(BwUser user) throws CalFacadeException { 
     343    StringBuffer sb = new StringBuffer(); 
     344 
     345    sb.append("/"); 
     346    sb.append(getSyspars().getUserCalendarRoot()); 
     347    sb.append("/"); 
     348    sb.append(user.getAccount()); 
     349 
     350    String pathTo = sb.toString(); 
     351 
     352    BwCalendar parent = getCalendar(pathTo); 
     353 
     354    if (parent == null) { 
     355      throw new CalFacadeException("org.bedework.calcore.calendars.unabletocreate"); 
     356    } 
     357 
     358    BwCalendar cal = new BwCalendar(); 
     359    cal.setName("Deleted"); 
     360    cal.setOwner(user); 
     361    cal.setCreator(user); 
     362    cal.setPublick(parent.getPublick()); 
     363    cal.setCalendarCollection(true); 
     364    addCalendar(cal, parent); 
     365  } 
     366 
    315367  public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
    316368    HibSession sess = getSess(); 
    317369 
    318     /* We need write access to the parent */ 
    319     access.checkAccess(parent, privWrite, false); 
     370    /* We need write content access to the parent */ 
     371    access.checkAccess(parent, privWriteContent, false); 
    320372 
    321373    /** Is the parent a calendar collection? 
    322374     */ 
    323 /*    sess.namedQuery("countCalendarEventRefs"); 
    324     sess.setEntity("cal", parent); 
    325  
    326     Integer res = (Integer)sess.getUnique(); 
    327  
    328     if (res.intValue() > 0) {*/ 
    329  
    330375    if (parent.getCalendarCollection()) { 
    331376      throw new CalFacadeException(CalFacadeException.illegalCalendarCreation); 
     
    352397 
    353398    val.setPath(path); 
    354     val.setOwner(getUser()); 
     399    if (val.getOwner() == null) { 
     400      val.setOwner(getUser()); 
     401    } 
    355402    val.setCalendar(parent); 
    356403    parent.addChild(val); 
     
    427474    while (it.hasNext()) { 
    428475      BwCalendar cal = (BwCalendar)it.next(); 
    429       CurrentAccess ca = access.checkAccess(cal, desiredAccess,  
     476      CurrentAccess ca = access.checkAccess(cal, desiredAccess, 
    430477                                            noAccessReturnsNull); 
    431478      if (ca != null) { 
     
    450497  private BwCalendar cloneAndCheckOne(BwCalendar subroot, int desiredAccess, 
    451498                           boolean nullForNoAccess) throws CalFacadeException { 
    452     CurrentAccess ca = access.checkAccess(subroot, desiredAccess,  
     499    CurrentAccess ca = access.checkAccess(subroot, desiredAccess, 
    453500                                          nullForNoAccess); 
    454      
     501 
    455502    if (!ca.accessAllowed) { 
    456503      return null; 
     
    460507    // XXX Temp fix - add id to the clone 
    461508    cal.setId(subroot.getId()); 
    462      
     509 
    463510    cal.setCurrentAccess(ca); 
    464511 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r356 r360  
    8686 
    8787import java.sql.Timestamp; 
     88import java.util.ArrayList; 
    8889import java.util.Collection; 
    8990import java.util.TreeSet; 
     
    860861  } 
    861862 
     863  public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
     864    return calendars.getDeletedCalendar(user); 
     865  } 
     866 
    862867  public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
    863868    checkOpen(); 
     
    11061111 
    11071112  public Collection getDeletedProxies() throws CalFacadeException { 
    1108     return events.getDeletedProxies(this.getTrashCalendar(user)); 
     1113    BwCalendar cal = this.getDeletedCalendar(user); 
     1114 
     1115    if (cal == null) { 
     1116      // Create the deleted calendar for another time 
     1117      calendars.createDeletedCalendar(user); 
     1118      return new ArrayList(); 
     1119    } 
     1120 
     1121    return events.getDeletedProxies(this.getDeletedCalendar(user)); 
    11091122  } 
    11101123 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java

    r356 r360  
    295295   * from result sets. 
    296296   * 
    297    * @param cal         Trash calendar object 
     297   * @param cal         Deleted calendar object 
    298298   * @return Collection of CoreEventInfo objects 
    299299   */ 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r356 r360  
    470470  } 
    471471 
     472  public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
     473    throw new CalFacadeUnimplementedException(); 
     474  } 
     475 
    472476  public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
    473477    checkOpen(); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java

    r212 r360  
    106106 
    107107  /** Get the default calendar for the given user. This is determined by the 
    108    * name for the default calendar assigned to the system, not by any user  
     108   * name for the default calendar assigned to the system, not by any user 
    109109   * preferences. This is normally used at initialisation of a new user. 
    110110   * 
    111    * @param  user      
     111   * @param  user 
    112112   * @return BwCalendar null for unknown calendar 
    113113   * @throws CalFacadeException 
     
    117117  /** Get the trash calendar for the given user. 
    118118   * 
    119    * @param  user      
     119   * @param  user 
    120120   * @return BwCalendar null for unknown calendar 
    121121   * @throws CalFacadeException 
    122122   */ 
    123123  public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException; 
     124 
     125  /** Get the deleted calendar for the given user. This holds annotations 
     126   * marking other events as deleted 
     127   * 
     128   * @param  user 
     129   * @return BwCalendar null for unknown calendar 
     130   * @throws CalFacadeException 
     131   */ 
     132  public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException; 
    124133 
    125134  /** Add a calendar object 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r357 r360  
    16831683      // Have write access - just set the flag and move it into the owners trash 
    16841684      event.setDeleted(true); 
    1685       event.setCalendar(getCal().getTrashCalendar(event.getOwner())); 
     1685      event.setCalendar(getCal().getDeletedCalendar(event.getOwner())); 
    16861686      updateEvent(event); 
    16871687      return; 
     
    16951695    // Put it in the trash - but don't delete on empty trash 
    16961696 
    1697     BwCalendar cal = getCal().getTrashCalendar(getUser()); 
     1697    BwCalendar cal = getCal().getDeletedCalendar(getUser()); 
    16981698    proxy.setOwner(getUser()); 
    16991699    proxy.setDeleted(true);