Changeset 466

Show
Ignore:
Timestamp:
05/11/06 14:58:38
Author:
douglm
Message:

Only create the user root and default calendar for a new user.
Special calendars are fetched explicitly through a new CalIntf? method:

getSpecialCalendar

This may have some implications for the user interface

Also added some missing syspars fields to dump/restore

Files:

Legend:

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

    r445 r466  
    5555 
    5656import org.bedework.calfacade.BwCalendar; 
     57import org.bedework.calfacade.BwSystem; 
    5758import org.bedework.calfacade.BwUser; 
    5859import org.bedework.calfacade.ifs.CalendarsI; 
     
    146147    usercal.addChild(cal); 
    147148 
    148     /* Add the trash calendar */ 
    149     cal = new BwCalendar(); 
    150     cal.setName(getSyspars().getDefaultTrashCalendar()); 
    151     cal.setCreator(user); 
    152     cal.setOwner(user); 
    153     cal.setPublick(false); 
    154     cal.setPath(path + "/" + getSyspars().getDefaultTrashCalendar()); 
    155     cal.setCalendar(usercal); 
    156     cal.setCalendarCollection(true); 
    157     cal.setCalType(BwCalendar.calTypeTrash); 
    158     usercal.addChild(cal); 
    159  
    160     /* Add the inbox */ 
    161     cal = new BwCalendar(); 
    162     cal.setName(getSyspars().getUserInbox()); 
    163     cal.setCreator(user); 
    164     cal.setOwner(user); 
    165     cal.setPublick(false); 
    166     cal.setPath(path + "/" + getSyspars().getUserInbox()); 
    167     cal.setCalendar(usercal); 
    168     cal.setCalendarCollection(true); 
    169     cal.setCalType(BwCalendar.calTypeInbox); 
    170     usercal.addChild(cal); 
    171  
    172     /* Add the outbox */ 
    173     cal = new BwCalendar(); 
    174     cal.setName(getSyspars().getUserOutbox()); 
    175     cal.setCreator(user); 
    176     cal.setOwner(user); 
    177     cal.setPublick(false); 
    178     cal.setPath(path + "/" + getSyspars().getUserOutbox()); 
    179     cal.setCalendar(usercal); 
    180     cal.setCalendarCollection(true); 
    181     cal.setCalType(BwCalendar.calTypeOutbox); 
    182     usercal.addChild(cal); 
    183  
    184     /* Add the deleted calendar */ 
    185     cal = new BwCalendar(); 
    186     cal.setName(getSyspars().getDeletedCalendar()); 
    187     cal.setCreator(user); 
    188     cal.setOwner(user); 
    189     cal.setPublick(false); 
    190     cal.setPath(path + "/" + getSyspars().getDeletedCalendar()); 
    191     cal.setCalendar(usercal); 
    192     cal.setCalendarCollection(true); 
    193     cal.setCalType(BwCalendar.calTypeDeleted); 
    194     usercal.addChild(cal); 
    195  
    196     /* Add the busy calendar */ 
    197     cal = new BwCalendar(); 
    198     cal.setName(getSyspars().getBusyCalendar()); 
    199     cal.setCreator(user); 
    200     cal.setOwner(user); 
    201     cal.setPublick(false); 
    202     cal.setPath(path + "/" + getSyspars().getBusyCalendar()); 
    203     cal.setCalendar(usercal); 
    204     cal.setCalendarCollection(true); 
    205     cal.setCalType(BwCalendar.calTypeBusy); 
    206     usercal.addChild(cal); 
    207  
    208149    sess.save(usercal); 
    209150 
     
    343284  } 
    344285 
    345   public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException { 
     286  public BwCalendar getSpecialCalendar(BwUser user, 
     287                                       int calType) throws CalFacadeException { 
    346288    StringBuffer sb = new StringBuffer(); 
    347  
    348     sb.append("/"); 
    349     sb.append(getSyspars().getUserCalendarRoot()); 
     289    String name; 
     290    BwSystem sys = getSyspars(); 
     291 
     292    if (calType == BwCalendar.calTypeBusy) { 
     293      name = sys.getBusyCalendar(); 
     294    } else if (calType == BwCalendar.calTypeDeleted) { 
     295      name = sys.getDeletedCalendar(); 
     296    } else if (calType == BwCalendar.calTypeInbox) { 
     297      name = sys.getUserInbox(); 
     298    } else if (calType == BwCalendar.calTypeOutbox) { 
     299      name = sys.getUserOutbox(); 
     300    } else if (calType == BwCalendar.calTypeTrash) { 
     301      name = sys.getDefaultTrashCalendar(); 
     302    } else { 
     303      // Not supported 
     304      return null; 
     305    } 
     306 
     307    sb.append(userCalendarRootPath); 
    350308    sb.append("/"); 
    351309    sb.append(user.getAccount()); 
     310 
     311    String pathTo = sb.toString(); 
     312 
    352313    sb.append("/"); 
    353     sb.append(getSyspars().getDefaultTrashCalendar()); 
    354  
    355     return getCalendar(sb.toString(), privRead); 
    356   } 
    357  
    358   public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
    359     StringBuffer sb = new StringBuffer(); 
    360  
    361     sb.append("/"); 
    362     sb.append(getSyspars().getUserCalendarRoot()); 
    363     sb.append("/"); 
    364     sb.append(user.getAccount()); 
    365     sb.append("/"); 
    366     sb.append("Deleted"); 
    367     // XXX new syspar sb.append(getSyspars().getDefaultTrashCalendar()); 
    368  
    369     return getCalendar(sb.toString(), privRead); 
    370   } 
    371  
    372   /** Create the special deleted calendar which holds deletion annotations to 
    373    * entities for which the user has no write access. 
    374    * 
    375    * @param user 
    376    * @throws CalFacadeException 
    377    */ 
    378   public void createDeletedCalendar(BwUser user) throws CalFacadeException { 
    379     StringBuffer sb = new StringBuffer(); 
    380  
    381     sb.append("/"); 
    382     sb.append(getSyspars().getUserCalendarRoot()); 
    383     sb.append("/"); 
    384     sb.append(user.getAccount()); 
    385  
    386     String pathTo = sb.toString(); 
     314    sb.append(name); 
     315 
     316    BwCalendar cal = getCalendar(sb.toString(), privRead); 
     317 
     318    if (cal != null) { 
     319      return cal; 
     320    } 
    387321 
    388322    /* 
     
    394328    */ 
    395329 
    396     BwCalendar cal = new BwCalendar(); 
    397     cal.setName(getSyspars().getDeletedCalendar()); 
     330    cal = new BwCalendar(); 
     331    cal.setName(name); 
    398332    cal.setOwner(user); 
    399333    cal.setCreator(user); 
    400334    cal.setCalendarCollection(true); 
    401     cal.setCalType(BwCalendar.calTypeDeleted); 
     335    cal.setCalType(calType); 
    402336    addCalendar(cal, pathTo); 
     337 
     338    return cal; 
    403339  } 
    404340 
     
    408344    /* We need write content access to the parent */ 
    409345    BwCalendar parent = getCalendar(parentPath, privWriteContent, false); 
     346    if (parent == null) { 
     347      throw new CalFacadeException("org.bedework.error.nosuchcalendarpath", 
     348                                   parentPath); 
     349    } 
    410350 
    411351    /** Is the parent a calendar collection? 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r448 r466  
    870870  } 
    871871 
    872   public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException { 
    873     return calendars.getTrashCalendar(user); 
    874   } 
    875  
    876   public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
    877     return calendars.getDeletedCalendar(user); 
     872  public BwCalendar getSpecialCalendar(BwUser user, 
     873                                       int calType) throws CalFacadeException { 
     874    return calendars.getSpecialCalendar(user, calType); 
    878875  } 
    879876 
     
    11261123 
    11271124  public Collection getDeletedProxies() throws CalFacadeException { 
    1128     BwCalendar cal = this.getDeletedCalendar(user); 
     1125    BwCalendar cal = getSpecialCalendar(user, BwCalendar.calTypeDeleted); 
    11291126 
    11301127    if (cal == null) { 
    1131       // Create the deleted calendar for another time 
    1132       calendars.createDeletedCalendar(user); 
     1128      // Not supported 
    11331129      return new ArrayList(); 
    11341130    } 
    11351131 
    1136     return events.getDeletedProxies(this.getDeletedCalendar(user)); 
     1132    return events.getDeletedProxies(cal); 
    11371133  } 
    11381134 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r445 r466  
    472472  } 
    473473 
    474   public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException { 
    475     throw new CalFacadeUnimplementedException(); 
    476   } 
    477  
    478   public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException { 
     474  public BwCalendar getSpecialCalendar(BwUser user, 
     475                                       int calType) throws CalFacadeException { 
    479476    throw new CalFacadeUnimplementedException(); 
    480477  } 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java

    r436 r466  
    155155   * of a calendar. 
    156156   * 
    157    * @param  val     int id of calendar 
    158    * @return CalendarVO null for unknown calendar 
     157   * @param  val        int id of calendar 
     158   * @return BwCalendar null for unknown calendar 
    159159   * @throws CalFacadeException 
    160160   */ 
    161161  public BwCalendar getCalendar(int val) throws CalFacadeException; 
    162162 
    163   /** Get a calendar given the path 
    164    * 
    165    * @param  path     String path of calendar 
     163  /** Get a calendar given the path. If the path is that of a 'special' 
     164   * calendar, for example the deleted calendar, it may not exist if it has 
     165   * not been used. 
     166   * 
     167   * @param  path          String path of calendar 
    166168   * @param  desiredAccess int access we need 
    167169   * @return BwCalendar null for unknown calendar 
     
    181183  public BwCalendar getDefaultCalendar(BwUser user) throws CalFacadeException; 
    182184 
    183   /** Get the trash calendar for the given user. 
     185  /** Get a special calendar (e.g. Trash) for the given user. If it does not 
     186   * exist and is supported by the target system it will be created. 
    184187   * 
    185188   * @param  user 
    186    * @return BwCalendar null for unknown calendar 
    187    * @throws CalFacadeException 
    188    */ 
    189   public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException; 
    190  
    191   /** Get the deleted calendar for the given user. This holds annotations 
    192    * marking other events as deleted 
    193    * 
    194    * @param  user 
    195    * @return BwCalendar null for unknown calendar 
    196    * @throws CalFacadeException 
    197    */ 
    198   public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException; 
     189   * @param  calType   int special calendar type. 
     190   * @return BwCalendar null for unknown calendar 
     191   * @throws CalFacadeException 
     192   */ 
     193  public BwCalendar getSpecialCalendar(BwUser user, 
     194                                       int calType) throws CalFacadeException; 
    199195 
    200196  /** Add a calendar object 
  • trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java

    r445 r466  
    389389  } 
    390390 
    391   public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException { 
    392     throw new CalFacadeUnimplementedException(); 
    393   } 
    394  
    395391  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
    396392    checkOpen(); 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r445 r466  
    17011701      // Have write access - just set the flag and move it into the owners trash 
    17021702      event.setDeleted(true); 
    1703       event.setCalendar(getCal().getTrashCalendar(event.getOwner())); 
     1703      event.setCalendar(getCal().getSpecialCalendar(event.getOwner(), 
     1704                                                    BwCalendar.calTypeTrash)); 
    17041705      updateEvent(event); 
    17051706      return; 
     
    17131714    // Put it in the trash - but don't delete on empty trash 
    17141715 
    1715     BwCalendar cal = getCal().getDeletedCalendar(getUser()); 
     1716    BwCalendar cal = getCal().getSpecialCalendar(getUser(), 
     1717                                                 BwCalendar.calTypeTrash); 
    17161718    proxy.setOwner(getUser()); 
    17171719    proxy.setDeleted(true); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/dump/dumpling/DumpSyspars.java

    r64 r466  
    8383    taggedVal("userInbox", s.getUserInbox()); 
    8484    taggedVal("userOutbox", s.getUserOutbox()); 
     85    taggedVal("deletedCalendar", s.getDeletedCalendar()); 
     86    taggedVal("busyCalendar", s.getBusyCalendar()); 
     87 
    8588    taggedVal("defaultUserViewName", s.getDefaultUserViewName()); 
    8689 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/FiltersRule.java

    r463 r466  
    150150    globals.defaultCalendars.put(new Integer(u.getId()), cal); 
    151151 
    152     /* Add the trash calendar */ 
    153     cal = new BwCalendar(); 
    154     cal.setId(globals.nextCalKey); 
    155     globals.nextCalKey++; 
    156     cal.setName(globals.syspars.getDefaultTrashCalendar()); 
    157     cal.setPath(ucal.getPath() + "/" + cal.getName()); 
    158     cal.setCreator(u); 
    159     cal.setOwner(u); 
    160     cal.setCalendar(ucal); 
    161     cal.setCalendarCollection(true); 
    162     ucal.addChild(cal); 
    163  
    164     globals.trashCalendars.put(new Integer(u.getId()), cal); 
    165  
    166     /* Add the inbox */ 
    167     cal = new BwCalendar(); 
    168     cal.setId(globals.nextCalKey); 
    169     globals.nextCalKey++; 
    170     cal.setName(globals.syspars.getUserInbox()); 
    171     cal.setPath(ucal.getPath() + "/" + cal.getName()); 
    172     cal.setCreator(u); 
    173     cal.setOwner(u); 
    174     cal.setCalendar(ucal); 
    175     cal.setCalendarCollection(true); 
    176     ucal.addChild(cal); 
    177  
    178     /* Add the outbox */ 
    179     cal = new BwCalendar(); 
    180     cal.setId(globals.nextCalKey); 
    181     globals.nextCalKey++; 
    182     cal.setName(globals.syspars.getUserOutbox()); 
    183     cal.setPath(ucal.getPath() + "/" + cal.getName()); 
    184     cal.setCreator(u); 
    185     cal.setOwner(u); 
    186     cal.setCalendar(ucal); 
    187     cal.setCalendarCollection(true); 
    188     ucal.addChild(cal); 
    189  
    190152    if (globals.rintf != null) { 
    191153      globals.rintf.restoreCalendars(ucal); 
     
    195157  } 
    196158} 
    197  
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/SysparsFieldRule.java

    r463 r466  
    9494    } else if (name.equals("userOutbox")) { 
    9595      ent.setUserOutbox(parval(globals.syspars.getUserOutbox(), stringFld())); 
     96    } else if (name.equals("deletedCalendar")) { 
     97      ent.setDeletedCalendar(parval(globals.syspars.getDeletedCalendar(), stringFld())); 
     98    } else if (name.equals("busyCalendar")) { 
     99      ent.setBusyCalendar(parval(globals.syspars.getBusyCalendar(), stringFld())); 
     100 
    96101    } else if (name.equals("defaultUserViewName")) { 
    97102      ent.setDefaultUserViewName(parval(globals.syspars.getDefaultUserViewName(), stringFld()));