Changeset 436

Show
Ignore:
Timestamp:
05/02/06 10:50:41
Author:
douglm
Message:

Changes to use calendar path rather than database id throughout.

Resulted in uncovering of error in back end which required further api change to addCalendar method.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calCore/resources/hbms/Calendar.hbm.xml

    r235 r436  
    6868       ================================================================= --> 
    6969 
    70   <!-- Calendars will be rooted in an entry with special names. 
    71        Public calendars are rooted on "*PUBLIC*" and private calendars on 
    72        ":USER:account,  e.g. :USER:douglm --> 
    7370  <query name="getNamedCalendars"><![CDATA[ 
    7471    from org.bedework.calfacade.BwCalendar as cal 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java

    r418 r436  
    289289  public BwCalendar getCalendar(String path, 
    290290                                int desiredAccess) throws CalFacadeException { 
     291    return getCalendar(path, desiredAccess, true); 
     292  } 
     293 
     294  private BwCalendar getCalendar(String path, 
     295                                 int desiredAccess, 
     296                                 boolean cloneIt) throws CalFacadeException { 
    291297    HibSession sess = getSess(); 
    292298 
     
    299305    if (cal != null) { 
    300306      // Need to clone for this 
    301       //access.checkAccess(cal, desiredAccess, false); 
    302       cal = cloneAndCheckOne(cal, desiredAccess, false); 
     307      if (!cloneIt) { 
     308        access.checkAccess(cal, desiredAccess, false); 
     309      } else { 
     310        cal = cloneAndCheckOne(cal, desiredAccess, false); 
     311      } 
    303312    } 
    304313 
     
    362371    String pathTo = sb.toString(); 
    363372 
     373    /* 
    364374    BwCalendar parent = getCalendar(pathTo, privRead); 
    365375 
     
    367377      throw new CalFacadeException("org.bedework.calcore.calendars.unabletocreate"); 
    368378    } 
     379    */ 
    369380 
    370381    BwCalendar cal = new BwCalendar(); 
     
    372383    cal.setOwner(user); 
    373384    cal.setCreator(user); 
    374     cal.setPublick(parent.getPublick()); 
    375385    cal.setCalendarCollection(true); 
    376     addCalendar(cal, parent); 
    377   } 
    378  
    379   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
     386    addCalendar(cal, pathTo); 
     387  } 
     388 
     389  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
    380390    HibSession sess = getSess(); 
    381391 
    382392    /* We need write content access to the parent */ 
    383     access.checkAccess(parent, privWriteContent, false); 
     393    BwCalendar parent = getCalendar(parentPath, privWriteContent, false); 
    384394 
    385395    /** Is the parent a calendar collection? 
     
    413423    } 
    414424    val.setCalendar(parent); 
     425    val.setPublick(parent.getPublick()); 
    415426    parent.addChild(val); 
    416427 
    417     sess.save(parent); 
     428    sess.update(parent); 
    418429  } 
    419430 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r415 r436  
    874874  } 
    875875 
    876   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
    877     checkOpen(); 
    878  
    879     calendars.addCalendar(val, parent); 
     876  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
     877    checkOpen(); 
     878 
     879    calendars.addCalendar(val, parentPath); 
    880880  } 
    881881 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/HibSession.java

    r331 r436  
    9191  /** Exception from this session. */ 
    9292  Throwable exc; 
    93    
     93 
    9494  private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); 
    9595 
     
    250250 
    251251  /** Return true if we have a transaction started 
    252    *  
     252   * 
    253253   * @return boolean 
    254254   */ 
     
    256256    return tx != null; 
    257257  } 
    258    
     258 
    259259  /** Commit a transaction 
    260260   * 
     
    663663  } 
    664664 
    665  
    666665  /** Update an object which may have been loaded in a previous hibernate 
    667666   * session 
     
    678677    try { 
    679678      sess.update(obj); 
     679    } catch (Throwable t) { 
     680      handleException(t); 
     681    } 
     682  } 
     683 
     684  /** Merge and update an object which may have been loaded in a previous hibernate 
     685   * session 
     686   * 
     687   * @param obj 
     688   * @throws CalFacadeException 
     689   */ 
     690  public void merge(Object obj) throws CalFacadeException { 
     691    if (exc != null) { 
     692      // Didn't hear me last time? 
     693      throw new CalFacadeException(exc); 
     694    } 
     695 
     696    try { 
     697      sess.merge(obj); 
    680698    } catch (Throwable t) { 
    681699      handleException(t); 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java

    r415 r436  
    480480  } 
    481481 
    482   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
     482  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
    483483    checkOpen(); 
    484484 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java

    r406 r436  
    211211   * <p>Name must be unique at this level, i.e. all paths must be unique 
    212212   * 
    213    * @param  val     CalendarVO new object 
    214    * @param  parent  CalendarVO object or null for root level 
    215    * @throws CalFacadeException 
    216    */ 
    217   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException; 
     213   * @param  val     BwCalendar new object 
     214   * @param  parentPath  String path to parent. 
     215   * @throws CalFacadeException 
     216   */ 
     217  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException; 
    218218 
    219219  /** Update a calendar object 
  • trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java

    r418 r436  
    676676      newcal.setCalendarCollection("MKCALENDAR".equalsIgnoreCase(req.getMethod())); 
    677677 
    678       getSvci().addCalendar(newcal, parent); 
     678      getSvci().addCalendar(newcal, parent.getPath()); 
    679679    } catch (CalFacadeAccessException cfae) { 
    680680      throw WebdavIntfException.forbidden(); 
  • trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java

    r415 r436  
    393393  } 
    394394 
    395   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
     395  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
    396396    checkOpen(); 
    397397 
  • trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java

    r423 r436  
    689689  } 
    690690 
    691   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException { 
     691  public void addCalendar(BwCalendar val, String parentPath) throws CalFacadeException { 
    692692    updateOK(val); 
    693693 
    694694    setupSharableEntity(val); 
    695695 
    696     getCal().addCalendar(val, parent); 
     696    getCal().addCalendar(val, parentPath); 
    697697  } 
    698698 
  • trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java

    r415 r436  
    586586   * <p>Name must be unique at this level, i.e. all paths must be unique 
    587587   * 
    588    * @param  val     CalendarVO new object 
    589    * @param  parent  CalendarVO object or null for root level 
    590    * @throws CalFacadeException 
    591    */ 
    592   public abstract void addCalendar(BwCalendar val, BwCalendar parent
     588   * @param  val     BwCalendar new object 
     589   * @param  parentPath  String path to parent. 
     590   * @throws CalFacadeException 
     591   */ 
     592  public abstract void addCalendar(BwCalendar val, String parentPath
    593593      throws CalFacadeException; 
    594594 
  • trunk/calendar3/test/src/org/bedework/tests/calsvc/CalSvcTestWrapper.java

    r301 r436  
    121121    this.user = user; 
    122122    String envPrefix; 
    123      
     123 
    124124    if (publicEvents) { 
    125125      envPrefix = webAdminAppPrefix; 
     
    130130    } 
    131131 
    132     CalSvcIPars pars = new CalSvcIPars(user, user,  
     132    CalSvcIPars pars = new CalSvcIPars(user, user, 
    133133                                       envPrefix, 
    134134                                       publicEvents, 
     
    311311    publicCal.setCalendarCollection(true); 
    312312 
    313     addCalendar(publicCal, root); 
     313    addCalendar(publicCal, root.getPath()); 
    314314 
    315315    return publicCal; 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java

    r432 r436  
    475475   *      <li>"subid"    subscription id for event. < 0 if there is none 
    476476   *                     e.g. displayed directly from calendar.</li> 
    477    *      <li>"calid"    id of calendar to search.</li> 
     477   *      <li>"calPath"  Path of calendar to search.</li> 
    478478   *      <li>"guid"     guid of event.</li> 
    479479   *      <li>"recurrenceId"   recurrence-id of event instance - possibly null.</li> 
     
    503503    } 
    504504 
    505     int calId = getIntReqPar(request, "calid", -1); 
    506505    BwCalendar cal = null; 
    507506 
    508     if (calId < 0) { 
    509       // Try path 
    510       String calPath = request.getParameter("calPath"); 
    511  
    512       if (calPath == null) { 
    513         // bogus request 
    514         form.getErr().emit("org.bedework.client.error.missingcalendarpath"); 
    515         return null; 
    516       } 
    517  
    518       cal = svci.getCalendar(calPath); 
    519     } else { 
    520       cal = svci.getCalendar(calId); 
    521     } 
     507    String calPath = getReqPar(request, "calPath"); 
     508 
     509    if (calPath == null) { 
     510      // bogus request 
     511      form.getErr().emit("org.bedework.client.error.missingcalendarpath"); 
     512      return null; 
     513    } 
     514 
     515    cal = svci.getCalendar(calPath); 
    522516 
    523517    if (cal == null) { 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java

    r336 r436  
    112112  // XXX locale - needs to be changed when locale changes 
    113113  private transient Collator listCollator; 
    114    
     114 
    115115  /* This should be a cloned copy only */ 
    116116  private BwSystem syspars; 
    117117 
    118118  private Collection sysStats; 
    119    
     119 
    120120  private transient MailerIntf mailer; 
    121121 
     
    234234   * .................................................................... */ 
    235235 
    236   private int calId; 
    237  
    238236  private int categoryId; 
    239237 
     
    367365  private BwCalendar calendar; 
    368366 
    369   private int parentCalendarId
     367  private String parentCalendarPath
    370368 
    371369  /** True if we are adding a new calendar 
     
    405403    return syspars; 
    406404  } 
    407    
    408   /** Set system statistics  
     405 
     406  /** Set system statistics 
    409407  * 
    410408  * @param val      Collection of BwStats.StatsEntry objects 
     
    414412  } 
    415413 
    416   /** Get system statistics  
     414  /** Get system statistics 
    417415  * 
    418416  * @return Collection of BwStats.StatsEntry objects 
     
    422420      sysStats = new ArrayList(); 
    423421    } 
    424      
     422 
    425423    return sysStats; 
    426424  } 
    427425 
    428   /** Get system statistics enabled state  
     426  /** Get system statistics enabled state 
    429427  * 
    430428   * @return boolean true if statistics collection enabled 
     
    437435    } 
    438436  } 
    439    
     437 
    440438  /** This will default to the current user. Superusers will be able to 
    441439   * specify a creator. 
     
    13551353   * ==================================================================== */ 
    13561354 
    1357   /** 
    1358    * @param val id 
    1359    */ 
    1360   public void setCalId(int val) { 
    1361     calId = val; 
    1362   } 
    1363  
    1364   /** 
    1365    * @return cal id 
    1366    */ 
    1367   public int getCalId() { 
    1368     return calId; 
    1369   } 
    1370  
    13711355  /** Return the public calendars 
    13721356   * 
     
    14411425    try { 
    14421426      TreeMap tm = new TreeMap(getListCollator()); 
    1443        
     1427 
    14441428      Iterator it = fetchSvci().getAddContentCalendarCollections().iterator(); 
    1445        
     1429 
    14461430      while (it.hasNext()) { 
    14471431        BwCalendar cal = (BwCalendar)it.next(); 
     
    14571441  } 
    14581442 
    1459   /** Save the id of the soon-to-be parent 
    1460    */ 
    1461   /** 
    1462    * @param val 
    1463    */ 
    1464   public void setParentCalendarId(int val) { 
    1465     parentCalendarId = val; 
    1466   } 
    1467  
    1468   /** 
    1469    * @return cal id 
    1470    */ 
    1471   public int getParentCalendarId() { 
    1472     return parentCalendarId; 
     1443  /** Save the Path of the soon-to-be parent 
     1444   * 
     1445   * @param val 
     1446   */ 
     1447  public void setParentCalendarPath(String val) { 
     1448    parentCalendarPath = val; 
     1449  } 
     1450 
     1451  /** 
     1452   * @return cal Path 
     1453   */ 
     1454  public String getParentCalendarPath() { 
     1455    return parentCalendarPath; 
    14731456  } 
    14741457 
     
    21482131    } 
    21492132  } 
    2150    
     2133 
    21512134  // XXX locale - needs to be changed when locale changes 
    21522135  private Collator getListCollator() { 
     
    21542137      listCollator = Collator.getInstance(); 
    21552138    } 
    2156      
     2139 
    21572140    return listCollator; 
    21582141  } 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/access/AccessAction.java

    r432 r436  
    7979 * <p>Request parameters:<ul> 
    8080 *      <li>  calPath alone:         path (or url) of calendar or...</li>. 
    81  *      <li>  calId+guid+recurid:  event</li>. 
    82  *      <li>  how:                   concateated String of desired access rights 
     81 *      <li>  calPath+guid+recurid:  event</li>. 
     82 *      <li>  how:                   concatenated String of desired access rights 
    8383 *                               @see edu.rpi.cct.uwcal.access.PrivilegeDefs </li>. 
    8484 *      <li>  whoType:               user (default), group</li>. 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/FetchCalendarAction.java

    r55 r436  
    6666 * 
    6767 * <p>Parameters are:<ul> 
    68  *      <li>"calId"            Id of calendar</li> 
     68 *      <li>"calPath"            Path of calendar</li> 
    6969 * </ul> 
    7070 * 
     
    8888     * the form so we can display the page 
    8989     */ 
    90     int id = getIntReqPar(request, "calId", -1); 
    9190 
    92     if (id < 0) { 
     91    String calPath = getReqPar(request, "calPath"); 
     92 
     93    if (calPath == null) { 
    9394      // bogus request 
     95      form.getErr().emit("org.bedework.client.error.missingcalendarpath"); 
    9496      return "notFound"; 
    9597    } 
    9698 
    97     BwCalendar calendar = form.fetchSvci().getCalendar(id); 
     99    BwCalendar calendar = form.fetchSvci().getCalendar(calPath); 
    98100 
    99101    if (debug) { 
    100102      if (calendar == null) { 
    101         logIt("No calendar with id " + id); 
     103        logIt("No calendar with path " + calPath); 
    102104      } else { 
    103105        logIt("Retrieved calendar " + calendar.getId()); 
     
    108110    form.setCalendar(calendar); 
    109111    if (calendar == null) { 
    110       form.getErr().emit("org.bedework.client.error.nosuchcalendar", id); 
     112      form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); 
    111113      return "notFound"; 
    112114    } 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/InitAddCalendarAction.java

    r55 r436  
    5555package org.bedework.webcommon.calendars; 
    5656 
    57 import org.bedework.calfacade.BwCalendar; 
    5857import org.bedework.webcommon.BwAbstractAction; 
    5958import org.bedework.webcommon.BwActionFormBase; 
     
    6665 * 
    6766 * <p>Parameters are:<ul> 
    68  *      <li>"calId"            Id of the parent to be</li> 
     67 *      <li>"calPath"       Path of the parent to be</li> 
    6968 * </ul> 
    7069 * 
     
    8988    } 
    9089 
    91     int id = getIntReqPar(request, "calId", -1); 
     90    String calPath = getReqPar(request, "calPath"); 
    9291 
    93     BwCalendar calendar = form.fetchSvci().getCalendar(id); 
    94  
    95     if ((calendar == null) || calendar.getCalendarCollection()) { 
     92    if (calPath == null) { 
     93      // bogus request 
     94      form.getErr().emit("org.bedework.client.error.missingcalendarpath"); 
    9695      return "notAllowed"; 
    9796    } 
    9897 
    99     form.setParentCalendarId(id); 
     98    form.setParentCalendarPath(calPath); 
    10099 
    101100    /** Set the objects to null so we get new ones. 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/UpdateCalendarAction.java

    r415 r436  
    117117 
    118118    if (add) { 
    119       BwCalendar parent = svci.getCalendar(form.getParentCalendarId()); 
    120  
    121       if (parent == null) { 
     119      String parentPath = form.getParentCalendarPath(); 
     120 
     121      if (parentPath == null) { 
    122122        return "error"; 
    123123      } 
    124       svci.addCalendar(cal, parent); 
     124      svci.addCalendar(cal, parentPath); 
    125125    } else { 
    126126      svci.updateCalendar(cal); 
    127127    } 
     128 
     129    form.setParentCalendarPath(null); 
    128130 
    129131    if (getPublicAdmin(form)) { 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/ExportAction.java

    r170 r436  
    8383 *      <li>"guid"           guid of event.</li> 
    8484 *      <li>"recurrenceId"   recurrence id of event (optional)... or</li> 
    85  *      <li>"calid"          Id of calendar to export.</li> 
     85 *      <li>"calPath"        Path of calendar to export.</li> 
    8686 *      <li>"sresult"        Any value - export last search result.</li> 
    8787 *      <li>"expand"         true/false - default is to not expand recurrences.</li> 
     
    9898                         BwActionFormBase form) throws Throwable { 
    9999    String guid = Util.checkNull(request.getParameter("guid")); 
    100     int calid = getIntReqPar(request, "calid", -1); 
     100    String calPath = getReqPar(request, "calPath"); 
    101101    int subid = getIntReqPar(request, "subid", -1); 
    102102    CalSvcI svci = form.fetchSvci(); 
     
    120120    } else { 
    121121      BwSubscription sub = null; 
    122       if (calid >= 0) { 
    123         BwCalendar cal = svci.getCalendar(calid); 
     122      if (calPath != null) { 
     123        BwCalendar cal = svci.getCalendar(calPath); 
    124124        if (cal == null) { 
    125125          return "notFound"; 
     
    162162    } 
    163163 
    164     IcalTranslator ical = new IcalTranslator(svci.getIcalCallback(),  
     164    IcalTranslator ical = new IcalTranslator(svci.getIcalCallback(), 
    165165                                             form.getDebug()); 
    166166 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/UpdateUserInfoAction.java

    r24 r436  
    7171 * 
    7272 * <p>Request parameters<ul> 
    73  *      <li>"guid"           guid of event.</li> 
    74  *      <li>"recurrenceId"   recurrence id of event (optional)... or</li> 
    75  *      <li>"calid"          Id of calendar to export.</li> 
    76  *      <li>"sresult"        Any value - export last search result.</li> 
    77  *      <li>"expand"         true/false - default is to not expand recurrences.</li> 
    7873 * </ul> 
     74 * 
    7975 * <p>Forwards to:<ul> 
    8076 *      <li>"noAccess"     user not authorised.</li> 
    81  *      <li>"notFound"     no event was found.</li> 
    82  *      <li>"success"      exported ok.</li> 
     77 *      <li>"retry"        validation error.</li> 
     78 *      <li>"continue"    ok.</li> 
    8379 * </ul> 
    8480 */ 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/UploadAction.java

    r317 r436  
    7575 
    7676/** 
    77  * Action to upload an icalendar file.. 
    78  * <p>No request parameters (other than updates to email and subject) 
     77 * Action to upload an icalendar file. 
     78 * <p>Parameters are:<ul> 
     79 *      <li>"calPath"            Path of calendar</li> 
     80 * </ul> 
     81 * 
    7982 * <p>Forwards to:<ul> 
    8083 *      <li>"retry"        email options still not valid.</li> 
     
    9598    BwCalendar cal = null; 
    9699 
    97     int calId = getIntReqPar(request, "calId", -1); 
    98     if (calId >= 0) { 
    99       cal = svci.getCalendar(calId); 
     100    String calPath = getReqPar(request, "calPath"); 
     101 
     102    if (calPath != null) { 
     103      cal = svci.getCalendar(calPath); 
    100104    } 
    101105 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/GetSubscriptionsAction.java

    r423 r436  
    5454package org.bedework.webcommon.subs; 
    5555 
    56 import org.bedework.calsvci.CalSvcI; 
    5756import org.bedework.webcommon.BwAbstractAction; 
    5857import org.bedework.webcommon.BwActionFormBase; 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/InitSubscribeAction.java

    r55 r436  
    6767 * 
    6868 * <p>Parameters are:<ul> 
    69  *      <li>"calId"            Id of calendar</li> 
     69 *      <li>"calPath"           Path to local calendar</li> 
    7070 *      <li>"calUri"            URI of remote calendar</li> 
    7171 * </ul> 
     
    9292    } 
    9393 
    94     int calId = getIntReqPar(request, "calId", -1); 
     94    String calPath = getReqPar(request, "calPath"); 
    9595    String calUri = null; 
    9696    BwCalendar cal = null; 
     
    100100    BwSubscription sub; 
    101101 
    102     if (calId < 0) { 
     102    // XXX Bogus??? Just use path for both. 
     103    if (calPath == null) { 
    103104      calUri = request.getParameter("calUri"); 
    104105      if (calUri == null) { 
     
    108109      sub = BwSubscription.makeSubscription(calUri, null, false, false, false); 
    109110    } else { 
    110       cal = svc.getCalendar(calId); 
     111      cal = svc.getCalendar(calPath); 
    111112 
    112113      if (cal == null) { 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java

    r408 r436  
    7373 * 
    7474 * <p>Parameters are:<ul> 
    75  *      <li>"calid"            Id of calendar</li> 
    7675 *      <li>"name"             Name of subscription</li> 
    7776 *      <li>"email"            y/n for email .</li>