Changeset 540
- Timestamp:
- 06/06/06 11:18:09
- Files:
-
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java (modified) (3 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (3 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java (modified) (6 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java (modified) (2 diffs)
- trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java (modified) (2 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (3 diffs)
- trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java (modified) (1 diff)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalCallback.java (modified) (1 diff)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java
r278 r540 86 86 private static volatile boolean systemTimezonesInitialised = false; 87 87 88 //private transient Logger log;89 90 88 CalTimezonesImpl(Calintf cal, BwStats stats, boolean publicAdmin, boolean debug) 91 89 throws CalFacadeException { … … 175 173 176 174 return vTimeZone; 175 } 176 177 public void storeTimeZone(final String id, BwUser owner) throws CalFacadeException { 178 TimezoneInfo tzinfo = lookup(id); 179 180 if (tzinfo == null) { 181 throw new CalFacadeException("org.bedework.calcore.unknown.tzid", id); 182 } 183 184 if (!tzinfo.getNewDef() && !tzinfo.getChanged()) { 185 return; 186 } 187 188 if (tzinfo.getPublick()) { 189 warn("Attempt to update public timezone"); 190 return; 191 } 192 193 if (tzinfo.getNewDef()) { 194 saveTimeZone(id, tzinfo.getTz().getVTimeZone()); 195 tzinfo.setNewDef(false); 196 } else { 197 // XXX Ignore change for the moment. 198 tzinfo.setChanged(false); 199 } 177 200 } 178 201 … … 230 253 } 231 254 255 if (!userTimezonesInitialised) { 256 // First call after object creation. 257 synchronized (this) { 258 if (!userTimezonesInitialised) { 259 Collection tzs = cal.getUserTimeZones(); 260 Iterator it = tzs.iterator(); 261 262 while (it.hasNext()) { 263 BwTimeZone btz = (BwTimeZone)it.next(); 264 265 Calendar cal = IcalTranslator.getCalendar(btz.getVtimezone()); 266 267 VTimeZone vtz = (VTimeZone)cal.getComponents().getComponent(Component.VTIMEZONE); 268 if (vtz == null) { 269 throw new CalFacadeException("Incorrectly stored timezone"); 270 } 271 272 tzinfo = new TimezoneInfo(new TimeZone(vtz), true); 273 timezones.put(btz.getTzid(), tzinfo); 274 } 275 276 userTimezonesInitialised = true; 277 } 278 } 279 } 280 232 281 tzinfo = (TimezoneInfo)systemTimezones.get(id); 233 282 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r510 r540 403 403 } 404 404 405 public CalTimezones getTimezones () throws CalFacadeException {405 public CalTimezones getTimezonesHandler() throws CalFacadeException { 406 406 return timezones; 407 407 } … … 742 742 743 743 sess.namedQuery("getMergedTimezones"); 744 sess.setEntity("owner", user); 745 746 return sess.getList(); 747 } 748 749 public Collection getUserTimeZones() throws CalFacadeException { 750 sess.namedQuery("getUserTimezones"); 744 751 sess.setEntity("owner", user); 745 752 … … 1060 1067 gpp.startDt = start; 1061 1068 gpp.dur = granularity; 1062 gpp.tzcache = getTimezones ();1069 gpp.tzcache = getTimezonesHandler(); 1063 1070 1064 1071 BwFreeBusyComponent fbc = null; trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r510 r540 367 367 } 368 368 369 CalTimezones tzs = cal.getTimezones ();369 CalTimezones tzs = cal.getTimezonesHandler(); 370 370 DtStart vstart = vev.getStartDate(); 371 371 … … 779 779 } 780 780 781 CalTimezones tzs = cal.getTimezones ();781 CalTimezones tzs = cal.getTimezonesHandler(); 782 782 DtStart vstart = vev.getStartDate(); 783 783 trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java
r415 r540 89 89 boolean publick; 90 90 91 boolean newDef; // true if this is a new definition 92 93 boolean changed; // true if the def has changed 94 91 95 /** 92 96 * @param tz … … 128 132 return publick; 129 133 } 134 135 /** Set the new flag 136 * 137 * @param val 138 */ 139 public void setNewDef(boolean val) { 140 newDef = val; 141 } 142 143 /** 144 * @return true for new def 145 */ 146 public boolean getNewDef() { 147 return newDef; 148 } 149 150 /** Set the changed flag 151 * 152 * @param val 153 */ 154 public void setChanged(boolean val) { 155 changed = val; 156 } 157 158 /** 159 * @return true for new def 160 */ 161 public boolean getChanged() { 162 return changed; 163 } 130 164 } 131 165 132 166 /* Map of user TimezoneInfo */ 133 167 protected HashMap timezones = new HashMap(); 168 169 /* subclasses can use this to trigger a read of stored timezone info. */ 170 protected boolean userTimezonesInitialised; 134 171 135 172 /* Cache date only UTC values - we do a lot of those but the number of … … 179 216 if (tzinfo == null) { 180 217 tzinfo = new TimezoneInfo(timezone); 218 tzinfo.newDef = true; 181 219 timezones.put(id, tzinfo); 182 220 } else { 183 tzinfo.tz = timezone; 221 if (!tzinfo.tz.equals(timezone)) { 222 // XXX Inadequate - different properties order will trigger this. 223 tzinfo.changed = true; 224 tzinfo.tz = timezone; 225 } 184 226 } 185 227 } … … 234 276 */ 235 277 public abstract VTimeZone findTimeZone(final String id, BwUser owner) throws CalFacadeException; 278 279 /** Store the definition for a timezone object in the database given the id. 280 * This will do nothing if the timezone is already stored. 281 * 282 * @param id 283 * @param owner event owner or null for current user 284 * @throws CalFacadeException 285 */ 286 public abstract void storeTimeZone(final String id, BwUser owner) throws CalFacadeException; 236 287 237 288 /** Clear all public timezone objects. Implementing classes should call this. … … 466 517 } 467 518 468 469 519 /* Get a logger for messages 470 520 */ … … 477 527 } 478 528 529 protected void warn(String msg) { 530 getLogger().warn(msg); 531 } 532 479 533 protected void trace(String msg) { 480 getLogger().debug( "trace: " +msg);534 getLogger().debug(msg); 481 535 } 482 536 } trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java
r507 r540 192 192 * @throws CalFacadeException if not admin 193 193 */ 194 public CalTimezones getTimezones () throws CalFacadeException;194 public CalTimezones getTimezonesHandler() throws CalFacadeException; 195 195 196 196 /** Get information about this interface … … 433 433 */ 434 434 public Collection getTimeZones() throws CalFacadeException; 435 436 /** Get all user vtimezone objects. 437 * 438 * @return Collection 439 * @throws CalFacadeException 440 */ 441 public Collection getUserTimeZones() throws CalFacadeException; 435 442 436 443 /** Get all public vtimezone objects. trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/CalintfCaldavImpl.java
r507 r540 172 172 } 173 173 174 public CalTimezones getTimezones () throws CalFacadeException {174 public CalTimezones getTimezonesHandler() throws CalFacadeException { 175 175 return null; 176 176 } … … 302 302 303 303 public Collection getTimeZones() throws CalFacadeException { 304 throw new CalFacadeUnimplementedException(); 305 } 306 307 public Collection getUserTimeZones() throws CalFacadeException { 304 308 throw new CalFacadeUnimplementedException(); 305 309 } trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r526 r540 302 302 } 303 303 304 timezones = getCal().getTimezones ();304 timezones = getCal().getTimezonesHandler(); 305 305 306 306 /* Nominate our timezone registry */ … … 372 372 373 373 public CalTimezones getTimezones() throws CalFacadeException { 374 return getCal().getTimezones ();374 return getCal().getTimezonesHandler(); 375 375 } 376 376 … … 2557 2557 2558 2558 public CalTimezones getTimezones() throws CalFacadeException { 2559 return getCal().getTimezones ();2560 } 2561 2562 public void saveTimeZone(String tzid, VTimeZone vtz2563 ) throws CalFacadeException {2559 return getCal().getTimezonesHandler(); 2560 } 2561 2562 public void saveTimeZone(String tzid, 2563 VTimeZone vtz) throws CalFacadeException { 2564 2564 timezones.saveTimeZone(tzid, vtz); 2565 } 2566 2567 public void storeTimeZone(final String id) throws CalFacadeException { 2568 timezones.storeTimeZone(id, getUser()); 2565 2569 } 2566 2570 trunk/calendar3/dumprestore/src/org/bedework/dumprestore/restore/TimezonesImpl.java
r463 r540 193 193 } 194 194 195 public void storeTimeZone(final String id, BwUser owner) throws CalFacadeException { 196 } 197 195 198 public void refreshTimezones() throws CalFacadeException { 196 199 synchronized (this) { trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalCallback.java
r310 r540 143 143 * @throws CalFacadeException 144 144 */ 145 public void saveTimeZone(String tzid, VTimeZone vtz 146 ) throws CalFacadeException; 145 public void saveTimeZone(String tzid, 146 VTimeZone vtz) throws CalFacadeException; 147 148 /** Store the definition for a timezone object in the database given the id. 149 * This will do nothing if the timezone is already stored. 150 * 151 * @param id 152 * @throws CalFacadeException 153 */ 154 public void storeTimeZone(final String id) throws CalFacadeException; 147 155 148 156 /** Register a timezone object in the current session. trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java
r469 r540 61 61 import org.bedework.calfacade.CalFacadeException; 62 62 import org.bedework.calfacade.svc.EventInfo; 63 //import org.bedework.calfacade.ifs.CalTimezones. 63 64 64 65 import net.fortuna.ical4j.data.CalendarBuilder; … … 531 532 } 532 533 533 if (cb.findTimeZone(id, null) != null) { 534 if (debug) { 535 debugMsg("Timezone already in db"); 536 } 537 return; // We know this one 538 } 539 540 cb.saveTimeZone(tzid.getValue(), vtz); 534 cb.storeTimeZone(tzid.getValue()); 541 535 } 542 536
