Changeset 882

Show
Ignore:
Timestamp:
07/28/06 00:00:28
Author:
douglm
Message:

Changes to ensure timezones are restored correctly
Add a sectionRule to flag start/end of restore sections
Restore missed preferredViewPeriod

Comment out some unused bits in admin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/dump/dumpling/DumpEvents.java

    r539 r882  
    8181  private void dumpEvent(BwEvent e) throws Throwable { 
    8282    BwEventAnnotation ann = null; 
     83 
     84    if (e instanceof BwEventAnnotation) { 
     85      ann = (BwEventAnnotation)e; 
     86    } 
    8387 
    8488    if (ann == null) { 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/HibRestore.java

    r760 r882  
    6060import org.bedework.calfacade.BwCategory; 
    6161import org.bedework.calfacade.BwEvent; 
     62import org.bedework.calfacade.BwEventObj; 
    6263import org.bedework.calfacade.BwLocation; 
    6364import org.bedework.calfacade.BwOrganizer; 
     
    289290 
    290291    Query q = hibSess.createQuery("from org.bedework.calfacade.svc.BwAdminGroup ag" + 
    291         " where ag.name=:name"); 
    292     q.setString("name", name); 
     292        " where ag.account=:account"); 
     293    q.setString("account", name); 
    293294    return (BwAdminGroup)q.uniqueResult(); 
    294295  } 
     
    324325    hibSave(o); 
    325326    closeHibSess(); 
     327  } 
     328 
     329  public BwEvent getEvent(BwCalendar cal, String guid) throws Throwable { 
     330    openHibSess(); 
     331 
     332    Query q = hibSess.createQuery("from " + BwEventObj.class.getName() + 
     333                                  " ev where ev.calendar=:cal " + 
     334                                  " and ev.guid=:guid "); 
     335    q.setEntity("cal", cal); 
     336    q.setString("guid", guid); 
     337    BwEvent ev = (BwEvent)q.uniqueResult(); 
     338 
     339    return ev; 
    326340  } 
    327341 
     
    561575    openHibSess(); 
    562576 
    563     Query q = hibSess.createQuery("from org.bedework.calfacade.BwCalendar cal where "
    564                         "cal.path=:path"); 
     577    Query q = hibSess.createQuery("from " + BwCalendar.class.getName()
     578                                  " cal where cal.path=:path"); 
    565579    q.setString("path", path); 
    566580    BwCalendar cal = (BwCalendar)q.uniqueResult(); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/RestoreIntf.java

    r534 r882  
    176176  public void restoreEvent(BwEvent o) throws Throwable; 
    177177 
     178  /** Get an event 
     179  * 
     180   * @param cal 
     181   * @param guid 
     182   * @return BwEvent 
     183   * @throws Throwable 
     184   */ 
     185  public BwEvent getEvent(BwCalendar cal, String guid) throws Throwable; 
     186 
    178187  /** Update an event 
    179188   * 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java

    r881 r882  
    8686  } 
    8787 
    88   public void saveTimeZone(String tzid, VTimeZone vtz
     88  public void saveTimeZone(String tzid, VTimeZone vtz, boolean publick
    8989          throws CalFacadeException { 
    90     /* For a user update the map to avoid a refetch. For system timezones we will 
    91        force a refresh when we're done. 
    92     */ 
     90    super.saveTimeZone(tzid, vtz, publick); 
    9391 
    94     super.saveTimeZone(tzid, vtz); 
    95  
    96     saveTZ(tzid, vtz, false, getUser()); 
    97   } 
    98  
    99   /** Saves a public timezone for restores. 
    100    * 
    101    * @param tzid 
    102    * @param vtz 
    103    * @throws CalFacadeException 
    104    */ 
    105   public void savePublicTimeZone(String tzid, VTimeZone vtz) 
    106           throws CalFacadeException { 
    107     /* For a user update the map to avoid a refetch. For system timezones we will 
    108        force a refresh when we're done. 
    109     */ 
    110  
    111     super.savePublicTimeZone(tzid, vtz); 
    112  
    113     saveTZ(tzid, vtz, true, getUser()); 
     92    saveTZ(tzid, vtz, publick, getUser()); 
    11493  } 
    11594 
     
    125104        // Populate from a file 
    126105        TimeZonesParser tzp = new TimeZonesParser( 
    127                                                   new FileInputStream(globals.config.getTimezonesFilename()), 
    128                                                   globals.config.getDebug()); 
     106                    new FileInputStream(globals.config.getTimezonesFilename()), 
     107                    globals.config.getDebug()); 
    129108 
    130109        Collection tzis = tzp.getTimeZones(); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/EventFieldRule.java

    r464 r882  
    112112        // Nothing to do. 
    113113 
     114      /* --------------- Annotation fields ---------------------- */ 
    114115      } else if (name.equals("target-calendar")) { 
    115116        BwEvent target = getAnnotationTarget(e); 
    116117 
    117         // target.setCalendar() 
     118        target.setCalendar(calendarFld()); 
     119      } else if (name.equals("target-guid")) { 
     120        BwEvent target = getAnnotationTarget(e); 
     121 
     122        target.setGuid(stringFld()); 
     123      } else if (name.equals("master-calendar")) { 
     124        BwEvent master = getAnnotationMaster(e); 
     125 
     126        master.setCalendar(calendarFld()); 
     127      } else if (name.equals("master-guid")) { 
     128        BwEvent master = getAnnotationMaster(e); 
     129 
     130        master.setGuid(stringFld()); 
     131 
    118132      } else if (name.equals("name")) { 
    119133        e.setName(stringFld()); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/EventRule.java

    r463 r882  
    104104    fixSharableEntity(entity, "Event"); 
    105105 
    106     /* If it's an alias, save an entry in the alias table then remove the dummy target. 
    107      * We'll update them all at the end 
    108      */ 
    109     if (entity instanceof BwEventAnnotation) { 
    110       globals.aliasTbl.put((BwEventAnnotation)entity); 
    111       ((BwEventAnnotation)entity).setTarget(null); 
    112     } 
    113  
    114106    try { 
     107      /* If it's an alias, save an entry in the alias table then remove the dummy target. 
     108       * We'll update them all at the end 
     109       */ 
     110      if (entity instanceof BwEventAnnotation) { 
     111        BwEventAnnotation ann = (BwEventAnnotation)entity; 
     112 
     113        globals.aliasTbl.put(ann); 
     114 
     115        BwEvent target = ann.getTarget(); 
     116        BwEvent ntarget = globals.rintf.getEvent(target.getCalendar(), target.getGuid()); 
     117 
     118        if (ntarget == null) { 
     119          error("Unknown target " + target); 
     120        } 
     121        ann.setTarget(ntarget); 
     122 
     123        BwEvent master = ann.getMaster(); 
     124        BwEvent nmaster = globals.rintf.getEvent(master.getCalendar(), master.getGuid()); 
     125 
     126        if (nmaster == null) { 
     127          error("Unknown master " + master); 
     128        } 
     129        ann.setMaster(nmaster); 
     130      } 
     131 
    115132      if (globals.config.getFrom2p3px()) { 
    116         if ((entity.getGuid() == null) || (entity.getGuid().length() == 0)) { 
    117           if (globals.syspars.getSystemid() == null) { 
    118             throw new Exception("You must supply a system id"); 
    119           } 
    120  
    121           /* ************** Duplicated code from calintfimpl **************** */ 
    122           String guidPrefix = "CAL-" + (String)uuidGen.generate(null, null); 
    123  
    124           if (entity.getName() == null) { 
    125             entity.setName(guidPrefix + ".ics"); 
    126           } 
    127  
    128           String guid = guidPrefix + globals.syspars.getSystemid(); 
    129  
    130           if (globals.config.getDebug()) { 
    131 //            trace("Set guid for " + entity.getId() + " to " + guid); 
    132           } 
    133  
    134           entity.setGuid(guid); 
    135         } 
    136  
    137         /* Try to fix up dates and times. 
    138            Non-inclusive ends seems to mean: 
    139  
    140            DATE-TIME start, no end        --  zero time at indicated time 
    141            DATE-TIME start, DATE end      --  is that allowed, means remainder of day? 
    142            DATE-TIME start, DATE-TIME end --  from start, up to, not including end 
    143            DATE start                     --  all day event 
    144            DATE start, DATE end           --  end - start + 1 all day(s) 
    145         */ 
    146  
    147         BwDateTime start = entity.getDtstart(); 
    148         BwDateTime end = entity.getDtend(); 
    149  
    150         entity.setEndType(BwEvent.endTypeDate); 
    151  
    152         if (!start.getDateType() && !end.getDateType()) { 
    153           // Both date-time, assume OK 
    154         } else if (start.getDateType() && end.getDateType()) { 
    155           // Both date - could be trouble 
    156           if (start.equals(end)) { 
    157             // Assume OK 
    158           } else { 
    159             Dur dur = new Dur(start.makeDate(), end.makeDate()); 
    160  
    161             warn(dur.getDays() + " day event " + entity.getId() + 
    162                  " start = " + start); 
    163           } 
    164  
    165           /* Increment the end by one day to take account of current practice */ 
    166           end = end.getNextDay(globals.getTzcache()); 
    167           entity.setDtend(end); 
    168         } else if (!end.getDateType()) { 
    169           // date start, date-time end --- illegal 
    170           warn("date start, date-time end for event " + entity.getId() + 
    171                " start = " + start.getDtval() + 
    172                " end = " + end.getDtval()); 
    173         } else { 
    174           /* date-time start, date end --- is this OK? 
    175              We'll fix it by setting end to start. 
    176  
    177           warn("date-time start, date end for event " + entity.getId() + 
    178                " start = " + start.getDtval() + 
    179                " end = " + end.getDtval()); 
    180            */ 
    181           globals.fixedNoEndTime++; 
    182           entity.setDtend(start); 
    183           entity.setEndType(BwEvent.endTypeNone); 
    184           end = start; 
    185         } 
    186  
    187         if (end.before(start)) { 
    188           warn("end before start for " + entity.getId() + " start = " + start + 
    189                " end = " + end); 
    190  
    191           end.init(start.getDateType(), start.getDtval(), null, 
    192                    globals.getTzcache()); 
    193         } 
    194  
    195         if (entity.getSummary() == null) { 
    196           warn("Event " + entity.getId() + " has no summary."); 
    197           entity.setSummary("Missing summary"); 
    198         } 
    199  
    200         if (entity.getCalendar() == null) { 
    201           warn("Event " + entity.getId() + " has no calendar."); 
    202           entity.setCalendar(globals.defaultPublicCal); 
    203         } 
    204  
    205         entity.setDuration(BwDateTime.makeDuration(start, end).toString()); 
     133        fixFor2p3(entity); 
    206134      } 
    207135 
     
    221149    pop(); 
    222150  } 
     151 
     152  private void fixFor2p3(BwEvent entity) throws Throwable { 
     153    if ((entity.getGuid() == null) || (entity.getGuid().length() == 0)) { 
     154      if (globals.syspars.getSystemid() == null) { 
     155        throw new Exception("You must supply a system id"); 
     156      } 
     157 
     158      /* ************** Duplicated code from calintfimpl **************** */ 
     159      String guidPrefix = "CAL-" + (String)uuidGen.generate(null, null); 
     160 
     161      if (entity.getName() == null) { 
     162        entity.setName(guidPrefix + ".ics"); 
     163      } 
     164 
     165      String guid = guidPrefix + globals.syspars.getSystemid(); 
     166 
     167      if (globals.config.getDebug()) { 
     168//        trace("Set guid for " + entity.getId() + " to " + guid); 
     169      } 
     170 
     171      entity.setGuid(guid); 
     172    } 
     173 
     174    /* Try to fix up dates and times. 
     175       Non-inclusive ends seems to mean: 
     176 
     177       DATE-TIME start, no end        --  zero time at indicated time 
     178       DATE-TIME start, DATE end      --  is that allowed, means remainder of day? 
     179       DATE-TIME start, DATE-TIME end --  from start, up to, not including end 
     180       DATE start                     --  all day event 
     181       DATE start, DATE end           --  end - start + 1 all day(s) 
     182    */ 
     183 
     184    BwDateTime start = entity.getDtstart(); 
     185    BwDateTime end = entity.getDtend(); 
     186 
     187    entity.setEndType(BwEvent.endTypeDate); 
     188 
     189    if (!start.getDateType() && !end.getDateType()) { 
     190      // Both date-time, assume OK 
     191    } else if (start.getDateType() && end.getDateType()) { 
     192      // Both date - could be trouble 
     193      if (start.equals(end)) { 
     194        // Assume OK 
     195      } else { 
     196        Dur dur = new Dur(start.makeDate(), end.makeDate()); 
     197 
     198        warn(dur.getDays() + " day event " + entity.getId() + 
     199             " start = " + start); 
     200      } 
     201 
     202      /* Increment the end by one day to take account of current practice */ 
     203      end = end.getNextDay(globals.getTzcache()); 
     204      entity.setDtend(end); 
     205    } else if (!end.getDateType()) { 
     206      // date start, date-time end --- illegal 
     207      warn("date start, date-time end for event " + entity.getId() + 
     208           " start = " + start.getDtval() + 
     209           " end = " + end.getDtval()); 
     210    } else { 
     211      /* date-time start, date end --- is this OK? 
     212         We'll fix it by setting end to start. 
     213 
     214      warn("date-time start, date end for event " + entity.getId() + 
     215           " start = " + start.getDtval() + 
     216           " end = " + end.getDtval()); 
     217       */ 
     218      globals.fixedNoEndTime++; 
     219      entity.setDtend(start); 
     220      entity.setEndType(BwEvent.endTypeNone); 
     221      end = start; 
     222    } 
     223 
     224    if (end.before(start)) { 
     225      warn("end before start for " + entity.getId() + " start = " + start + 
     226           " end = " + end); 
     227 
     228      end.init(start.getDateType(), start.getDtval(), null, 
     229               globals.getTzcache()); 
     230    } 
     231 
     232    if (entity.getSummary() == null) { 
     233      warn("Event " + entity.getId() + " has no summary."); 
     234      entity.setSummary("Missing summary"); 
     235    } 
     236 
     237    if (entity.getCalendar() == null) { 
     238      warn("Event " + entity.getId() + " has no calendar."); 
     239      entity.setCalendar(globals.defaultPublicCal); 
     240    } 
     241 
     242    entity.setDuration(BwDateTime.makeDuration(start, end).toString()); 
     243  } 
    223244} 
    224245 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/RestoreRule.java

    r463 r882  
    9292  } 
    9393 
     94  protected void info(String msg) { 
     95    getLog().info(msg); 
     96  } 
     97 
    9498  protected void error(String msg) { 
    9599    getLog().error(msg); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/RestoreRuleSet.java

    r534 r882  
    8383 
    8484    UserFieldRule ufr = new UserFieldRule(globals); 
     85    d.addRule("caldata/users", new SectionRule(globals, "users")); 
    8586    d.addRule("caldata/users/user", new UserRule(globals)); 
    8687    d.addRule("caldata/users/user/*", ufr); 
    8788 
     89    d.addRule("caldata/timezones", new SectionRule(globals, "timezones")); 
    8890    d.addRule("caldata/timezones/timezone", new TimeZoneRule(globals)); 
    8991    d.addRule("caldata/timezones/timezone/*", new TimeZoneFieldRule(globals)); 
    9092 
     93    d.addRule("caldata/calendars", new SectionRule(globals, "calendars")); 
    9194    d.addRule("caldata/calendars/calendar", new CalendarRule(globals)); 
    9295    d.addRule("caldata/calendars/calendar/*", new CalendarFieldRule(globals)); 
    9396 
     97    d.addRule("caldata/cal-suites", new SectionRule(globals, "cal-suites")); 
    9498    d.addRule("caldata/cal-suites/cal-suite", new CalSuiteRule(globals)); 
    9599    d.addRule("caldata/cal-suites/cal-suite/*", new CalSuiteFieldRule(globals)); 
    96100 
     101    d.addRule("caldata/locations", new SectionRule(globals, "locations")); 
    97102    d.addRule("caldata/locations/location", new LocationRule(globals)); 
    98103    d.addRule("caldata/locations/location/*", new LocationFieldRule(globals)); 
    99104 
     105    d.addRule("caldata/sponsors", new SectionRule(globals, "sponsors")); 
    100106    d.addRule("caldata/sponsors/sponsor", new SponsorRule(globals)); 
    101107    d.addRule("caldata/sponsors/sponsor/*", new SponsorFieldRule(globals)); 
    102108 
     109    d.addRule("caldata/organizers", new SectionRule(globals, "organizers")); 
    103110    d.addRule("caldata/organizers/organizer", new OrganizerRule(globals)); 
    104111    d.addRule("caldata/organizers/organizer/*", new OrganizerFieldRule(globals)); 
    105112 
     113    d.addRule("caldata/attendees", new SectionRule(globals, "attendees")); 
    106114    d.addRule("caldata/attendees/attendee", new AttendeeRule(globals)); 
    107115    d.addRule("caldata/attendees/attendee/*", new AttendeeFieldRule(globals)); 
     
    125133 
    126134    AdminGroupFieldRule agfr = new AdminGroupFieldRule(globals); 
     135    d.addRule("caldata/adminGroups", new SectionRule(globals, "adminGroups")); 
    127136    d.addRule("caldata/adminGroups/adminGroup", new AdminGroupRule(globals)); 
    128137    d.addRule("caldata/adminGroups/adminGroup/*", agfr); 
    129138 
    130139    AuthUserFieldRule aufr = new AuthUserFieldRule(globals); 
     140    d.addRule("caldata/authusers", new SectionRule(globals, "authusers")); 
    131141    d.addRule("caldata/authusers/authuser", new AuthUserRule(globals)); 
    132142    d.addRule("caldata/authusers/authuser/*", aufr); 
     
    137147 
    138148    EventFieldRule efr = new EventFieldRule(globals); 
     149    d.addRule("caldata/events", new SectionRule(globals, "events")); 
    139150    d.addRule("caldata/events/event", new EventRule(globals)); 
    140151    d.addRule("caldata/events/event/*", efr); 
    141152 
     153    d.addRule("caldata/event-annotations", new SectionRule(globals, "event annotations")); 
    142154    d.addRule("caldata/event-annotations/event-annotation", new EventRule(globals)); 
    143155    d.addRule("caldata/event-annotations/event-annotation/*", efr); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/TimeZoneRule.java

    r881 r882  
    6060import org.bedework.calfacade.BwTimeZone; 
    6161import org.bedework.calfacade.CalFacadeException; 
     62import org.bedework.calfacade.timezones.SATimezonesImpl; 
    6263import org.bedework.dumprestore.restore.RestoreGlobals; 
    6364import org.bedework.icalendar.IcalTranslator; 
     
    101102      String tzid = entity.getTzid(); 
    102103 
    103       globals.getTzcache().saveTimeZone(tzid, vtz, entity.getPublick()); 
     104      SATimezonesImpl tzs = globals.getTzcache(); 
     105      tzs.setUser(entity.getOwner()); 
     106      tzs.saveTimeZone(tzid, vtz, entity.getPublick()); 
    104107    } catch (Throwable t) { 
    105108      error("Exception restoring " + entity); 
  • trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/rules/UserPrefsFieldRule.java

    r556 r882  
    8787    } else if (name.equals("preferredView")) { 
    8888      p.setPreferredView(stringFld()); 
     89    } else if (name.equals("preferredViewPeriod")) { 
     90      p.setPreferredViewPeriod(stringFld()); 
    8991    } else if (name.equals("subscriptions")) { 
    9092      // Nothing to do now 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/authuser/PEDeleteAuthAction.java

    r550 r882  
    5555package org.bedework.webadmin.authuser; 
    5656 
    57 import org.bedework.calsvci.CalSvcI; 
     57//import org.bedework.calsvci.CalSvcI; 
    5858import org.bedework.webadmin.PEAbstractAction; 
    5959import org.bedework.webadmin.PEActionForm; 
     
    8585    } 
    8686 
    87     CalSvcI svci = form.fetchSvci(); 
     87    //CalSvcI svci = form.fetchSvci(); 
    8888 
    8989    // XXX This was set up to remove the current auth user, 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEDeleteEventAction.java

    r550 r882  
    5656 
    5757import org.bedework.calfacade.BwEvent; 
    58 import org.bedework.calsvci.CalSvcI; 
     58//import org.bedework.calsvci.CalSvcI; 
    5959import org.bedework.webadmin.PEAbstractAction; 
    6060import org.bedework.webadmin.PEActionForm; 
     
    8181                         BwSession sess, 
    8282                         PEActionForm form) throws Throwable { 
    83     CalSvcI svci = form.fetchSvci(); 
     83    //CalSvcI svci = form.fetchSvci(); 
    8484    boolean alerts = form.getAlertEvent(); 
    8585