Changeset 99

Show
Ignore:
Timestamp:
02/07/06 10:16:06
Author:
douglm
Message:

Created CalendarsI interface in calfacade/ifs - it's the Calendars section of Calintf

Created separate Calendars component in calcore which is called by CalintImpl? to do the work. It implements CalendarsI.

Added new code to Calendars to check access of calendar (sub)tree we are trying to fetch and truncate it at inaccessible entries.

ALso partially fix up calendar deletions. Still an error trying to delet parent but seems to be a stylesheet problem.

Files:

Legend:

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

    r86 r99  
    144144  private AccessUtil access; 
    145145 
    146   /* From core environment properties * / 
    147   private String systemId; 
    148  
    149   private String publicCalendarRoot; 
    150   private String userCalendarRoot; 
    151   private String userDefaultCalendar; 
    152   private String defaultTrashCalendar; 
    153   */ 
    154   private String publicCalendarRootPath; 
    155   private String userCalendarRootPath; 
    156  
    157146  /** Ensure we don't open while open 
    158147   */ 
     
    171160 
    172161  private Events events; 
     162 
     163  private Calendars calendars; 
    173164 
    174165  private EventProperties categories; 
     
    263254        throw new CalFacadeException("synch only valid for non admin"); 
    264255      } 
    265  
    266       /** Define the roots of the calendars. 
    267        * / 
    268       publicCalendarRoot = CalEnv.getGlobalProperty("public.calroot"); 
    269       userCalendarRoot = CalEnv.getGlobalProperty("user.calroot"); 
    270       userDefaultCalendar = CalEnv.getGlobalProperty("default.user.calendar"); 
    271       defaultTrashCalendar = CalEnv.getGlobalProperty("default.trash.calendar"); 
    272  
    273       systemId = CalEnv.getGlobalProperty("systemid"); 
    274       */ 
    275256    } catch (Throwable t) { 
    276257      throw new CalFacadeException(t); 
    277258    } 
    278  
    279     publicCalendarRootPath = "/" + getSyspars().getPublicCalendarRoot(); 
    280     userCalendarRootPath = "/" + getSyspars().getUserCalendarRoot(); 
    281     //systemId = getSyspars().getSystemid(); 
    282259 
    283260    if (user == null) { 
     
    302279         */ 
    303280        getLogger().info("Add new user " + authenticatedUser); 
    304         addUser(new BwUser(authenticatedUser)); 
     281        addNewUser(new BwUser(authenticatedUser)); 
    305282        authUser = getUser(authenticatedUser); 
    306283        userCreated = true; 
     
    332309    access.setAuthUser(authUser); 
    333310 
    334     events = new Events(this, access, sess, this.user, debug); 
    335  
    336     categories = new EventProperties(this, 
     311    events = new Events(this, access, this.user, debug); 
     312 
     313    calendars = new Calendars(this, access, this.user, debug); 
     314 
     315    categories = new EventProperties(this, access, this.user, 
    337316                                     "word", BwCategory.class.getName(), 
    338317                                     "getCategoryRefs", 
    339318                                     -1, debug); 
    340     locations = new EventProperties(this, 
     319    locations = new EventProperties(this, access, this.user, 
    341320                                    "address", BwLocation.class.getName(), 
    342321                                     "getLocationRefs", 
    343322                                     CalFacadeDefs.maxReservedLocationId, debug); 
    344     sponsors = new EventProperties(this, 
     323    sponsors = new EventProperties(this, access, this.user, 
    345324                                   "name", BwSponsor.class.getName(), 
    346325                                   "getSponsorRefs", 
     
    350329    timezones.setDefaultTimeZoneId(getSyspars().getTzid()); 
    351330 
     331    if (userCreated) { 
     332      calendars.addNewCalendars(); 
     333    } 
    352334    return userCreated; 
    353335  } 
     
    451433      } 
    452434      sess = new HibSession(sessFactory, log); 
    453       if (events != null) { 
    454         events.setHibSession(sess); 
    455       } 
    456435    } else { 
    457436      if (debug) { 
     
    616595 
    617596  public void addUser(BwUser user) throws CalFacadeException { 
     597    addNewUser(user); 
     598    calendars.addNewCalendars(); 
     599  } 
     600 
     601  private void addNewUser(BwUser user) throws CalFacadeException { 
    618602    checkOpen(); 
    619603 
     
    625609 
    626610    sess.save(user); 
    627  
    628     /* Add a user collection to the userCalendarRoot and then a default 
    629        calendar collection. */ 
    630  
    631     sess.namedQuery("getCalendarByPath"); 
    632  
    633     String path =  "/" + getSyspars().getUserCalendarRoot(); 
    634     sess.setString("path", path); 
    635  
    636     BwCalendar userrootcal = (BwCalendar)sess.getUnique(); 
    637  
    638     if (userrootcal == null) { 
    639       throw new CalFacadeException("No user root at " + path); 
    640     } 
    641  
    642     path += "/" + user.getAccount(); 
    643     sess.namedQuery("getCalendarByPath"); 
    644     sess.setString("path", path); 
    645  
    646     BwCalendar usercal = (BwCalendar)sess.getUnique(); 
    647     if (usercal != null) { 
    648       throw new CalFacadeException("User calendar already exists at " + path); 
    649     } 
    650  
    651     /* Create a folder for the user */ 
    652     usercal = new BwCalendar(); 
    653     usercal.setName(user.getAccount()); 
    654     usercal.setCreator(user); 
    655     usercal.setOwner(user); 
    656     usercal.setPublick(false); 
    657     usercal.setPath(path); 
    658     usercal.setCalendar(userrootcal); 
    659     userrootcal.addChild(usercal); 
    660  
    661     sess.save(userrootcal); 
    662  
    663     /* Create a default calendar */ 
    664     BwCalendar cal = new BwCalendar(); 
    665     cal.setName(getSyspars().getUserDefaultCalendar()); 
    666     cal.setCreator(user); 
    667     cal.setOwner(user); 
    668     cal.setPublick(false); 
    669     cal.setPath(path + "/" + getSyspars().getUserDefaultCalendar()); 
    670     cal.setCalendar(usercal); 
    671     cal.setCalendarCollection(true); 
    672     usercal.addChild(cal); 
    673  
    674     /* Add the trash calendar */ 
    675     cal = new BwCalendar(); 
    676     cal.setName(getSyspars().getDefaultTrashCalendar()); 
    677     cal.setCreator(user); 
    678     cal.setOwner(user); 
    679     cal.setPublick(false); 
    680     cal.setPath(path + "/" + getSyspars().getDefaultTrashCalendar()); 
    681     cal.setCalendar(usercal); 
    682     cal.setCalendarCollection(true); 
    683     usercal.addChild(cal); 
    684  
    685     /* Add the inbox */ 
    686     cal = new BwCalendar(); 
    687     cal.setName(getSyspars().getUserInbox()); 
    688     cal.setCreator(user); 
    689     cal.setOwner(user); 
    690     cal.setPublick(false); 
    691     cal.setPath(path + "/" + getSyspars().getUserInbox()); 
    692     cal.setCalendar(usercal); 
    693     cal.setCalendarCollection(true); 
    694     usercal.addChild(cal); 
    695  
    696     /* Add the outbox */ 
    697     cal = new BwCalendar(); 
    698     cal.setName(getSyspars().getUserOutbox()); 
    699     cal.setCreator(user); 
    700     cal.setOwner(user); 
    701     cal.setPublick(false); 
    702     cal.setPath(path + "/" + getSyspars().getUserOutbox()); 
    703     cal.setCalendar(usercal); 
    704     cal.setCalendarCollection(true); 
    705     usercal.addChild(cal); 
    706  
    707     sess.save(usercal); 
    708  
    709     sess.update(user); 
    710611  } 
    711612 
     
    855756 
    856757  /* ==================================================================== 
    857    *                   Calendars and search 
     758   *                       Calendars 
    858759   * ==================================================================== */ 
    859760 
     
    861762    checkOpen(); 
    862763 
    863     sess.namedQuery("getCalendarByPath"); 
    864     sess.setString("path", publicCalendarRootPath); 
    865     sess.cacheableQuery(); 
    866  
    867     /* XXX access checks */ 
    868     return (BwCalendar)sess.getUnique(); 
     764    return calendars.getPublicCalendars(); 
    869765  } 
    870766 
     
    872768    checkOpen(); 
    873769 
    874     sess.namedQuery("getPublicCalendarCollections"); 
    875     sess.cacheableQuery(); 
    876  
    877     return access.checkAccess(sess.getList(), privWrite, true); 
     770    return calendars.getPublicCalendarCollections(); 
    878771  } 
    879772 
     
    885778    checkOpen(); 
    886779 
    887     sess.namedQuery("getCalendarByPath"); 
    888     sess.setString("path", userCalendarRootPath + "/" + user.getAccount()); 
    889     sess.cacheableQuery(); 
    890  
    891     return (BwCalendar)sess.getUnique(); 
     780    return calendars.getCalendars(); 
    892781  } 
    893782 
     
    895784    checkOpen(); 
    896785 
    897     sess.namedQuery("getUserCalendarCollections"); 
    898     sess.setEntity("owner", user); 
    899     sess.cacheableQuery(); 
    900  
    901     return access.checkAccess(sess.getList(), privWrite, true); 
     786    return calendars.getCalendarCollections(); 
    902787  } 
    903788 
     
    906791    checkOpen(); 
    907792 
    908     sess.namedQuery("getPublicCalendarCollections"); 
    909     sess.cacheableQuery(); 
    910  
    911     return access.checkAccess(sess.getList(), privWriteContent, true); 
     793    return calendars.getAddContentPublicCalendarCollections(); 
    912794  } 
    913795 
     
    920802    checkOpen(); 
    921803 
    922     sess.namedQuery("getUserCalendarCollections"); 
    923     sess.setEntity("owner", user); 
    924     sess.cacheableQuery(); 
    925  
    926     return access.checkAccess(sess.getList(), privWriteContent, true); 
     804    return calendars.getAddContentCalendarCollections(); 
    927805  } 
    928806 
     
    930808    checkOpen(); 
    931809 
    932     sess.namedQuery("getCalendarById"); 
    933     sess.setInt("id", val); 
    934     sess.cacheableQuery(); 
    935  
    936     return (BwCalendar)sess.getUnique(); 
     810    return calendars.getCalendar(val); 
    937811  } 
    938812 
     
    940814    checkOpen(); 
    941815 
    942     sess.namedQuery("getCalendarByPath"); 
    943     sess.setString("path", path); 
    944     sess.cacheableQuery(); 
    945  
    946     BwCalendar cal = (BwCalendar)sess.getUnique(); 
    947  
    948     if (cal != null) { 
    949       access.accessible(cal, privRead, false); 
    950     } 
    951  
    952     return cal; 
     816    return calendars.getCalendar(path); 
    953817  } 
    954818 
    955819  public BwCalendar getDefaultCalendar() throws CalFacadeException { 
    956     StringBuffer sb = new StringBuffer(); 
    957  
    958     sb.append("/"); 
    959     sb.append(getSyspars().getUserCalendarRoot()); 
    960     sb.append("/"); 
    961     sb.append(user.getAccount()); 
    962     sb.append("/"); 
    963     sb.append(getSyspars().getUserDefaultCalendar()); 
    964  
    965     return getCalendar(sb.toString()); 
     820    return calendars.getDefaultCalendar(); 
    966821  } 
    967822 
    968823  public BwCalendar getTrashCalendar() throws CalFacadeException { 
    969     StringBuffer sb = new StringBuffer(); 
    970  
    971     sb.append("/"); 
    972     sb.append(getSyspars().getUserCalendarRoot()); 
    973     sb.append("/"); 
    974     sb.append(user.getAccount()); 
    975     sb.append("/"); 
    976     sb.append(getSyspars().getDefaultTrashCalendar()); 
    977  
    978     return getCalendar(sb.toString()); 
     824    return calendars.getTrashCalendar(); 
    979825  } 
    980826 
     
    982828    checkOpen(); 
    983829 
    984     /* We need write access to the parent */ 
    985     access.accessible(parent, privWrite, false); 
    986  
    987     /** Is the parent a calendar collection? 
    988      */ 
    989 /*    sess.namedQuery("countCalendarEventRefs"); 
    990     sess.setEntity("cal", parent); 
    991  
    992     Integer res = (Integer)sess.getUnique(); 
    993  
    994     if (res.intValue() > 0) {*/ 
    995  
    996     if (parent.getCalendarCollection()) { 
    997       throw new CalFacadeException(CalFacadeException.illegalCalendarCreation); 
    998     } 
    999  
    1000     /* Ensure the path is unique */ 
    1001     String path = parent.getPath(); 
    1002     if (path == null) { 
    1003       if (parent.getPublick()) { 
    1004         path = ""; 
    1005       } else { 
    1006         path = "/users/" + parent.getOwner().getAccount(); 
    1007       } 
    1008     } 
    1009  
    1010     path += "/" + val.getName(); 
    1011  
    1012     sess.namedQuery("getCalendarByPath"); 
    1013     sess.setString("path", path); 
    1014  
    1015     if (sess.getUnique() != null) { 
    1016       throw new CalFacadeException(CalFacadeException.duplicateCalendar); 
    1017     } 
    1018  
    1019     val.setPath(path); 
    1020     val.setOwner(user); 
    1021     val.setCalendar(parent); 
    1022     parent.addChild(val); 
    1023  
    1024     sess.save(parent); 
     830    calendars.addCalendar(val, parent); 
    1025831  } 
    1026832 
    1027833  public void updateCalendar(BwCalendar val) throws CalFacadeException { 
    1028834    checkOpen(); 
    1029     sess.update(val); 
     835    calendars.updateCalendar(val); 
    1030836  } 
    1031837 
     
    1033839    checkOpen(); 
    1034840 
    1035     BwCalendar parent = val.getCalendar(); 
    1036     if (parent == null) { 
    1037       throw new CalFacadeException(CalFacadeException.cannotDeleteCalendarRoot); 
    1038     } 
    1039  
    1040     //sess.delete(val); 
    1041     parent.removeChild(val); 
    1042     sess.update(parent); 
    1043  
    1044     return true; 
     841    return calendars.deleteCalendar(val); 
    1045842  } 
    1046843 
     
    1048845    checkOpen(); 
    1049846 
    1050     sess.namedQuery("countCalendarEventRefs"); 
    1051     sess.setEntity("cal", val); 
    1052  
    1053     Integer res = (Integer)sess.getUnique(); 
    1054  
    1055     if (debug) { 
    1056       trace(" ----------- count = " + res); 
    1057     } 
    1058  
    1059     if (res == null) { 
    1060       return false; 
    1061     } 
    1062  
    1063     return res.intValue() > 0; 
     847    return calendars.checkCalendarRefs(val); 
    1064848  } 
    1065849 
     
    1077861    return null; 
    1078862  } 
    1079  
    1080   /* 
    1081   public BwFilter getFilter(String name) throws CalFacadeException { 
    1082     checkOpen(); 
    1083     if (currentMode != CalintfUtil.guestMode) { 
    1084       return null; 
    1085     } 
    1086  
    1087     sess.createQuery("from " + BwFilter.class.getName() + " as cal " + 
    1088                      "where cal.name = :name"); 
    1089     sess.setString("name", name); 
    1090  
    1091     return (BwFilter)sess.getUnique(); 
    1092   } 
    1093  
    1094   public BwFilter getFilter(int id) throws CalFacadeException { 
    1095     checkOpen(); 
    1096  
    1097 /*    Object o = sess.get(FilterVO.class, id); 
    1098     if (o != null) { 
    1099       return (FilterVO)o; 
    1100     } 
    1101 * / 
    1102     sess.createQuery("from " + BwFilter.class.getName() + " as cal " + 
    1103                      "where cal.id = :id"); 
    1104     sess.setInt("id", id); 
    1105  
    1106     return (BwFilter)sess.getUnique(); 
    1107   } */ 
    1108863 
    1109864  public void addFilter(BwFilter val) throws CalFacadeException { 
     
    15211276 
    15221277  /* ==================================================================== 
    1523    *                   Arbitrary query 
    1524    * ==================================================================== */ 
    1525  
    1526   /* 
    1527   public Collection arbQuery(String q) throws CalFacadeException { 
    1528     checkOpen(); 
    1529     sess.createQuery(q); 
    1530  
    1531     return sess.getList(); 
    1532   }*/ 
    1533  
    1534   /* ==================================================================== 
    15351278   *                   Private methods 
    15361279   * ==================================================================== */ 
     
    15401283      throw new CalFacadeException("Calintf call when closed"); 
    15411284    } 
    1542   } 
    1543  
    1544   /* 
    1545   private void updated(BwUser user) { 
    1546     personalModified.add(user); 
    15471285  } 
    15481286 
     
    15571295  } 
    15581296 
    1559   /* 
    1560   private void error(String msg) { 
    1561     getLogger().error(msg); 
    1562   }*/ 
    1563  
    15641297  private void trace(String msg) { 
    15651298    getLogger().debug(msg); 
     
    15751308    throw new CalFacadeAccessException(); 
    15761309  } 
    1577  
    1578   /* Ensure the current user is not a guest. 
    1579    * / 
    1580   private void requireNotGuest() throws CalFacadeException { 
    1581     if (!user.isGuest())  { 
    1582       return; 
    1583     } 
    1584  
    1585     throw new CalFacadeAccessException(); 
    1586   }*/ 
    15871310} 
    15881311 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/EventProperties.java

    r2 r99  
    5757import org.bedework.calfacade.BwUser; 
    5858import org.bedework.calfacade.CalFacadeException; 
    59 import org.bedework.calfacade.CalintfDefs; 
    60  
    61 import java.io.Serializable; 
     59import org.bedework.calfacade.ifs.Calintf; 
     60 
    6261import java.util.Collection; 
    63  
    64 import org.apache.log4j.Logger; 
    6562 
    6663/** Class which handles manipulation of BwEventProperty subclasses which are 
     
    7673 * 
    7774 */ 
    78 public class EventProperties implements CalintfDefs, Serializable { 
    79   private boolean debug; 
    80  
    81   private CalintfImpl cal; 
    82  
     75public class EventProperties extends CalintfHelper { 
    8376  private String keyFieldName; 
    8477 
     
    9184  private int minId; 
    9285 
    93   private transient Logger log; 
    94  
    9586  /** Constructor 
    9687   * 
    97    * @param cal           CalintImpl object 
     88   * @param cal           Calintf object 
     89   * @param access 
     90   * @param user 
    9891   * @param keyFieldName  Name of entity keyfield 
    9992   * @param className     Class of entity 
     
    10295   * @param debug 
    10396   */ 
    104   public EventProperties(CalintfImpl cal
     97  public EventProperties(Calintf cal, AccessUtil access, BwUser user
    10598                         String keyFieldName, 
    10699                         String className, 
     
    108101                         int minId, 
    109102                         boolean debug) { 
    110     this.cal = cal; 
     103    super(cal, access, user, debug); 
     104 
    111105    this.keyFieldName = keyFieldName; 
    112106    this.className = className; 
    113107    this.refQuery = refQuery; 
    114108    this.minId = minId; 
    115     this.debug = debug; 
    116109  } 
    117110 
     
    308301    return refs; 
    309302  } 
    310  
    311   private HibSession getSess() throws CalFacadeException { 
    312     return (HibSession)cal.getDbSession(); 
    313   } 
    314  
    315   /** Get a logger for messages 
    316    */ 
    317   private Logger getLogger() { 
    318     if (log == null) { 
    319       log = Logger.getLogger(this.getClass()); 
    320     } 
    321  
    322     return log; 
    323   } 
    324  
    325   private void trace(String msg) { 
    326     getLogger().debug(msg); 
    327   } 
    328303} 
    329304 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java

    r31 r99  
    6565import org.bedework.calfacade.CalFacadeDefs; 
    6666import org.bedework.calfacade.CalFacadeUtil; 
    67 import org.bedework.calfacade.CalintfDefs; 
    6867import org.bedework.calfacade.filter.BwFilter; 
    6968import org.bedework.calfacade.ifs.CalTimezones; 
     
    7372import org.bedework.icalendar.VEventUtil; 
    7473 
    75 import edu.rpi.cct.uwcal.access.PrivilegeDefs; 
    76  
    7774import net.fortuna.ical4j.model.component.VEvent; 
    7875import net.fortuna.ical4j.model.Date; 
     
    8279import net.fortuna.ical4j.model.property.DtStart; 
    8380 
    84 import org.apache.log4j.Logger; 
    85  
    8681import org.hibernate.Criteria; 
    8782import org.hibernate.criterion.Expression; 
     
    9085import org.hibernate.id.UUIDHexGenerator; 
    9186 
    92 import java.io.Serializable; 
    9387import java.util.Collection; 
    9488import java.util.HashMap; 
     
    10195 * @author Mike Douglass   douglm@rpi.edu 
    10296 */ 
    103 public class Events implements CalintfDefs, PrivilegeDefs, Serializable { 
    104   private boolean debug; 
    105  
    106   private Calintf cal; 
    107  
    108   private AccessUtil access; 
    109  
    110   private HibSession sess; 
    111  
    112   private BwUser user; 
    113  
    114   private transient Logger log; 
    115  
     97public class Events extends CalintfHelper { 
    11698  private UUIDHexGenerator uuidGen; 
    11799 
     
    120102   * @param cal 
    121103   * @param access 
    122    * @param sess 
    123104   * @param user 
    124105   * @param debug 
    125106   */ 
    126   public Events(Calintf cal, AccessUtil access, HibSession sess, 
    127                 BwUser user, boolean debug) { 
    128     this.cal = cal; 
    129     this.access = access; 
    130     this.sess = sess; 
    131     this.user = user; 
    132     this.debug = debug; 
     107  public Events(Calintf cal, AccessUtil access, BwUser user, boolean debug) { 
     108    super(cal, access, user, debug); 
    133109 
    134110    Properties uidprops = new Properties(); 
     
    136112    uuidGen = new UUIDHexGenerator(); 
    137113    ((Configurable)uuidGen).configure(Hibernate.STRING, uidprops, null); 
    138   } 
    139  
    140   /** (Re)set the HibSession 
    141    * 
    142    * @param val 
    143    */ 
    144   public void setHibSession(HibSession val) { 
    145     sess = val; 
    146114  } 
    147115 
     
    179147    BwEvent master = null; 
    180148    TreeSet ts = new TreeSet(); 
     149    HibSession sess = getSess(); 
    181150 
    182151    if (rid == null) { 
     
    357326   */ 
    358327  public BwEvent getEvent(int id) throws CalFacadeException { 
     328    HibSession sess = getSess(); 
    359329    Criteria cr = sess.createCriteria(BwEventObj.class); 
    360330 
     
    378348  public void addEvent(BwEvent val, Collection overrides) throws CalFacadeException { 
    379349    RecuridTable recurids = null; 
     350    HibSession sess = getSess(); 
    380351 
    381352    if ((overrides != null) && (overrides.size() != 0)) { 
     
    502473    override.setOwner(user); 
    503474 
    504     sess.saveOrUpdate(override); 
     475    getSess().saveOrUpdate(override); 
    505476    inst.setOverride(override); 
    506477  } 
     
    512483   */ 
    513484  public void updateEvent(BwEvent val) throws CalFacadeException { 
     485    HibSession sess = getSess(); 
    514486    if (!(val instanceof BwEventProxy)) { 
    515487      sess.saveOrUpdate(val); 
     
    598570   */ 
    599571  private void updateRecurrences(BwEvent val) throws CalFacadeException { 
     572    HibSession sess = getSess(); 
    600573    VEvent vev = VEventUtil.toIcalEvent(val, null); 
    601574 
     
    688661   */ 
    689662  public DelEventResult deleteEvent(BwEvent val) throws CalFacadeException { 
     663    HibSession sess = getSess(); 
    690664    DelEventResult der = new DelEventResult(false, 0); 
    691665 
     
    828802                              int currentMode, boolean ignoreCreator) 
    829803          throws CalFacadeException { 
     804    HibSession sess = getSess(); 
    830805    StringBuffer sb = new StringBuffer(); 
    831806 
     
    921896  public Collection getEventsByName(BwCalendar cal, String val) 
    922897          throws CalFacadeException { 
     898    HibSession sess = getSess(); 
    923899    sess.namedQuery("eventsByName"); 
    924900    sess.setString("name", val); 
     
    936912  private void eventQuery(Class cl, String guid, String rid, Integer seqnum, 
    937913                          boolean masterOnly) throws CalFacadeException { 
     914    HibSession sess = getSess(); 
    938915    StringBuffer sb = new StringBuffer(); 
    939916 
     
    992969                                           int recurRetrieval) 
    993970          throws CalFacadeException { 
     971    HibSession sess = getSess(); 
    994972    StringBuffer sb = new StringBuffer(); 
    995973 
     
    11461124  private void doCalendarEntities(boolean setUser, BwCalendar calendar) 
    11471125          throws CalFacadeException { 
     1126    HibSession sess = getSess(); 
    11481127    if (setUser) { 
    11491128      sess.setEntity("user", user); 
     
    11651144    if (calendar.getCalendarCollection()) { 
    11661145      // leaf calendar 
    1167       sess.setEntity("calendar" + calTerm.i, calendar); 
     1146      getSess().setEntity("calendar" + calTerm.i, calendar); 
    11681147      calTerm.i++; 
    11691148    } else { 
     
    13971376 
    13981377  private int deleteAlarms(BwEvent ev) throws CalFacadeException { 
     1378    HibSession sess = getSess(); 
    13991379    sess.namedQuery("deleteEventAlarms"); 
    14001380    sess.setEntity("ev", ev); 
     
    14131393      BwEvent ev = (BwEvent)it.next(); 
    14141394 
    1415       if (access.accessible(ev, desiredAccess,  noAccessReturnsNull)) { 
     1395      if (access.accessible(ev, desiredAccess,  nullForNoAccess)) { 
    14161396        outevs.add(ev); 
    14171397      } 
     
    14291409    } 
    14301410 
    1431     if (!access.accessible(ev, desiredAccess, noAccessReturnsNull)) { 
     1411    if (!access.accessible(ev, desiredAccess, nullForNoAccess)) { 
    14321412      return null; 
    14331413    } 
     
    14611441    } 
    14621442  } 
    1463  
    1464   private Logger getLog() { 
    1465     if (log == null) { 
    1466       log = Logger.getLogger(getClass()); 
    1467     } 
    1468  
    1469     return log; 
    1470   } 
    1471  
    1472   private void debugMsg(String msg) { 
    1473     getLog().debug(msg); 
    1474   } 
    14751443} 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/BwCalendar.java

    r36 r99  
    325325  } 
    326326 
     327  /** Create a copy of this object but do not clone the children 
     328   * 
     329   * @return BwCalendar object 
     330   */ 
     331  public BwCalendar shallowClone() { 
     332    return new BwCalendar((BwUser)getOwner().clone(), 
     333                          getPublick(), 
     334                          (BwUser)getCreator().clone(), 
     335                          getAccess(), 
     336                          getName(), 
     337                          getPath(), 
     338                          getSummary(), 
     339                          getDescription(), 
     340                          getMailListId(), 
     341                          getCalendarCollection(), 
     342                          getCalendar(), 
     343                          null); 
     344  } 
     345 
    327346  /* ==================================================================== 
    328347   *                   Object methods 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeException.java

    r36 r99  
    6464   */ 
    6565 
     66  /** Couldn't find calendar */ 
     67  public static final String calendarNotFound = 
     68      "org.bedework.exception.calendarnotfound"; 
     69 
    6670  /** Somebody tried to create a duplicate calendar */ 
    6771  public static final String duplicateCalendar = 
    6872      "org.bedework.exception.duplicatecalendar"; 
     73 
     74  /** Somebody tried to create a calendar with children */ 
     75  public static final String calendarNotEmpty = 
     76      "org.bedework.exception.calendarnotempty"; 
    6977 
    7078  /** */ 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java

    r55 r99  
    7070import org.bedework.calfacade.ifs.Groups; 
    7171 
    72 import java.io.Serializable; 
    7372import java.util.Collection; 
    7473 
    7574import net.fortuna.ical4j.model.component.VTimeZone; 
    7675 
    77 /** This class acts as a low level interface to the calendar database. 
     76/** This is the low level interface to the calendar database. 
    7877 * 
    7978 * <p>This interface provides a view of the data as seen by the supplied user 
     
    9291 * @author Mike Douglass   douglm@rpi.edu 
    9392 */ 
    94 public interface Calintf extends Serializable
     93public interface Calintf extends CalendarsI
    9594  /** Must be called to initialise the new object. 
    9695   * 
     
    412411   */ 
    413412  public void clearPublicTimezones() throws CalFacadeException; 
    414  
    415   /* ==================================================================== 
    416    *                   Calendars 
    417    * ==================================================================== */ 
    418  
    419   /** Returns the tree of public calendars 
    420    * 
    421    * @return BwCalendar   root with all children attached 
    422    * @throws CalFacadeException 
    423    */ 
    424   public BwCalendar getPublicCalendars() throws CalFacadeException; 
    425  
    426   /** Return a list of public calendars in which calendar objects can be 
    427    * placed by the current user. 
    428    * 
    429    * <p>Caldav currently does not allow collections inside collections so that 
    430    * calendar collections are the leaf nodes only. 
    431    * 
    432    * @return Collection   of CalendarVO 
    433    * @throws CalFacadeException 
    434    */ 
    435   public Collection getPublicCalendarCollections() throws CalFacadeException; 
    436  
    437   /** Returns calendars owned by the current user. 
    438    * 
    439    * <p>For anonymous (public events) access, this method returns the same 
    440    * as getPublicCalendars(). 
    441    * 
    442    * <p>For authenticated, personal access this always returns the user 
    443    * entry in the /user calendar tree, e.g. for user smithj it would return 
    444    * an entry smithj 
    445    * 
    446    * @return BwCalendar   root with all children attached 
    447    * @throws CalFacadeException 
    448    */ 
    449   public BwCalendar getCalendars() throws CalFacadeException; 
    450  
    451   /** Return a list of user calendars in which calendar objects can be 
    452    * placed by the current user. 
    453    * 
    454    * <p>Caldav currently does not allow collections inside collections so that 
    455    * calendar collections are the leaf nodes only. 
    456    * 
    457    * @return Collection   of CalendarVO 
    458    * @throws CalFacadeException 
    459    */ 
    460   public Collection getCalendarCollections() throws CalFacadeException; 
    461  
    462   /** Return a list of calendars in which calendar objects can be 
    463    * placed by the current user. 
    464    * 
    465    * <p>Caldav currently does not allow collections inside collections so that 
    466    * calendar collections are the leaf nodes only. 
    467    * 
    468    * @return Collection   of BwCalendar 
    469    * @throws CalFacadeException 
    470    */ 
    471   public Collection getAddContentPublicCalendarCollections() 
    472           throws CalFacadeException; 
    473  
    474   /** Return a list of calendars in which calendar objects can be 
    475    * placed by the current user. 
    476    * 
    477    * <p>Caldav currently does not allow collections inside collections so that 
    478    * calendar collections are the leaf nodes only. 
    479    * 
    480    * @return Collection   of BwCalendar 
    481    * @throws CalFacadeException 
    482    */ 
    483   public Collection getAddContentCalendarCollections() 
    484           throws CalFacadeException; 
    485  
    486   /** Get a calendar we are interested in. This is represented by the id 
    487    * of a calendar. 
    488    * 
    489    * @param  val     int id of calendar 
    490    * @return CalendarVO null for unknown calendar 
    491    * @throws CalFacadeException 
    492    */ 
    493   public BwCalendar getCalendar(int val) throws CalFacadeException; 
    494  
    495   /** Get a calendar given the path 
    496    * 
    497    * @param  path     String path of calendar 
    498    * @return BwCalendar null for unknown calendar 
    499    * @throws CalFacadeException 
    500    */ 
    501   public BwCalendar getCalendar(String path) throws CalFacadeException; 
    502  
    503   /** Get the default calendar for the current user. 
    504    * 
    505    * @return BwCalendar null for unknown calendar 
    506    * @throws CalFacadeException 
    507    */ 
    508   public BwCalendar getDefaultCalendar() throws CalFacadeException; 
    509  
    510   /** Get the trash calendar for the current user. 
    511    * 
    512    * @return BwCalendar null for unknown calendar 
    513    * @throws CalFacadeException 
    514    */ 
    515   public BwCalendar getTrashCalendar() throws CalFacadeException; 
    516  
    517   /** Add a calendar object 
    518    * 
    519    * <p>The new calendar object will be added to the db. If the indicated parent 
    520    * is null it will be added as a root level calendar. 
    521    * 
    522    * <p>Certain restrictions apply, mostly because of interoperability issues. 
    523    * A calendar cannot be added to another calendar which already contains 
    524    * entities, e.g. events etc. 
    525    * 
    526    * <p>Names cannot contain certain characters - (complete this) 
    527    * 
    528    * <p>Name must be unique at this level, i.e. all paths must be unique 
    529    * 
    530    * @param  val     CalendarVO new object 
    531    * @param  parent  CalendarVO object or null for root level 
    532    * @throws CalFacadeException 
    533    */ 
    534   public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException; 
    535  
    536   /** Update a calendar object 
    537    * 
    538    * @param  val     CalendarVO object 
    539    * @throws CalFacadeException 
    540    */ 
    541   public void updateCalendar(BwCalendar val) throws CalFacadeException; 
    542  
    543   /** Delete the given calendar 
    544    * 
    545    * @param val      CalendarVO object to be deleted 
    546    * @return boolean false if it didn't exist, true if it was deleted. 
    547    * @throws CalFacadeException 
    548    */ 
    549   public boolean deleteCalendar(BwCalendar val) throws CalFacadeException; 
    550  
    551   /** Check to see if a calendar is referenced. 
    552    * 
    553    * @param val      CalendarVO object to check 
    554    * @return boolean true if the calendar is referenced somewhere 
    555    * @throws CalFacadeException 
    556    */ 
    557   public boolean checkCalendarRefs(BwCalendar val) throws CalFacadeException; 
    558413 
    559414  /* ==================================================================== 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java

    r96 r99  
    282282      throw new RuntimeException("Unable to initialise UTC timezone"); 
    283283    } 
     284    cal.setTimeZone(utctz); 
    284285  } 
    285286 
     
    337338        } 
    338339 
    339         cal.setTimeZone(utctz); 
    340340        cal.setTime(formatTd.parse(time)); 
    341341 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/DeleteCalendarAction.java

    r55 r99  
    8383 
    8484    BwCalendar cal = form.getCalendar(); 
     85    if (cal.getChildren().size() > 0) { 
     86      form.getErr().emit("org.bedework.client.error.calendar.referenced"); 
     87      return "inUse"; 
     88    } 
     89 
    8590    int delResult = form.fetchSvci().deleteCalendar(cal); 
    8691