Changeset 356
- Timestamp:
- 04/10/06 00:26:24
- Files:
-
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (9 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (14 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java (modified) (4 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEventProxy.java (modified) (5 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeDefs.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/CoreEventInfo.java (modified) (7 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (5 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java (modified) (8 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/EventsI.java (modified) (4 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/EventInfo.java (modified) (4 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (24 diffs)
- trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java (modified) (10 diffs)
- trunk/calendar3/synchml/src/edu/rpi/cct/uwcal/synchml/common/Synchml.java (modified) (4 diffs)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwDelEventAction.java (modified) (2 diffs)
- trunk/calendar3/webclient/war/WEB-INF/struts-config.xml (modified) (1 diff)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r331 r356 55 55 56 56 import edu.rpi.cct.uwcal.access.PrivilegeDefs; 57 import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 57 58 58 59 import org.bedework.calenv.CalEnv; … … 300 301 calendars = new Calendars(this, access, currentMode, debug); 301 302 302 categories = new EventProperties(this, access, currentMode, 303 categories = new EventProperties(this, access, currentMode, 303 304 "word", BwCategory.class.getName(), 304 305 "getCategoryRefs", 305 306 -1, debug); 306 locations = new EventProperties(this, access, currentMode, 307 locations = new EventProperties(this, access, currentMode, 307 308 "address", BwLocation.class.getName(), 308 309 "getLocationRefs", 309 310 CalFacadeDefs.maxReservedLocationId, debug); 310 sponsors = new EventProperties(this, access, currentMode, 311 sponsors = new EventProperties(this, access, currentMode, 311 312 "name", BwSponsor.class.getName(), 312 313 "getSponsorRefs", … … 325 326 access.setSuperUser(val); 326 327 } 327 328 328 329 public boolean getSuperUser() { 329 330 return access.getSuperUser(); … … 334 335 return null; 335 336 } 336 337 337 338 BwRWStats rwstats = (BwRWStats)stats; 338 339 339 340 if (timezones != null) { 340 341 rwstats.setDateCacheHits(timezones.getDateCacheHits()); … … 342 343 rwstats.setDatesCached(timezones.getDatesCached()); 343 344 } 344 345 345 346 return stats; 346 347 } … … 350 351 return; 351 352 } 352 353 353 354 if (dbStats == null) { 354 355 dbStats = sessFactory.getStatistics(); 355 356 } 356 357 357 358 dbStats.setStatisticsEnabled(enable); 358 359 } … … 362 363 return false; 363 364 } 364 365 365 366 return dbStats.isStatisticsEnabled(); 366 367 } 367 368 368 369 public void dumpDbStats() throws CalFacadeException { 369 370 DbStatistics.dumpStats(dbStats); 370 371 } 371 372 372 373 public Collection getDbStats() throws CalFacadeException { 373 374 return DbStatistics.getStats(dbStats); … … 689 690 * ==================================================================== */ 690 691 691 public void changeAccess(BwShareableDbentity ent, 692 public void changeAccess(BwShareableDbentity ent, 692 693 Collection aces) throws CalFacadeException { 693 694 checkOpen(); 694 695 access.changeAccess(ent, aces); 695 696 sess.saveOrUpdate(ent); 697 } 698 699 public CurrentAccess checkAccess(BwShareableDbentity ent, int desiredAccess, 700 boolean returnResult) throws CalFacadeException { 701 return access.checkAccess(ent, desiredAccess, returnResult); 696 702 } 697 703 … … 1099 1105 } 1100 1106 1107 public Collection getDeletedProxies() throws CalFacadeException { 1108 return events.getDeletedProxies(this.getTrashCalendar(user)); 1109 } 1110 1101 1111 /* ==================================================================== 1102 1112 * Synchronization trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r321 r356 107 107 * @param debug 108 108 */ 109 public Events(Calintf cal, AccessUtil access, 109 public Events(Calintf cal, AccessUtil access, 110 110 int currentMode, boolean debug) { 111 111 super(cal, access, currentMode, debug); … … 118 118 TreeSet ts = new TreeSet(); 119 119 HibSession sess = getSess(); 120 120 121 121 /* This (seems) to work as follows: 122 * 122 * 123 123 * First try to retrieve the event from the events table. 124 * 124 * 125 125 * If not there try the annotations table. If it's there, it's a reference 126 126 * to an event owned by somebody else. Otherwise we drew a blank. 127 * 127 * 128 128 * If we want the recurrences and the event is recurring we go on to try to 129 129 * retrieve the rest. … … 138 138 cei = postGetEvent((BwEvent)sess.getUnique(), privRead, noAccessReturnsNull); 139 139 140 // XXX Don't want annotations in the trash 140 141 if (cei == null) { 141 142 /* Look for an annotation to that event by the current user. … … 149 150 } 150 151 } 151 152 152 153 if (cei == null) { 153 154 return ts; 154 155 } 155 156 156 157 master = cei.getEvent(); 157 158 … … 279 280 } 280 281 282 /** XXX temp I think 283 * Retrieve event proxies in the trash - they will be used to remove events 284 * from result sets. 285 * 286 * @return Collection of CoreEventInfo objects 287 */ 288 public Collection getDeletedProxies() throws CalFacadeException { 289 // Calintf supplies the calendar 290 return null; 291 } 292 293 /** XXX temp I think 294 * Retrieve event proxies in the trash - they will be used to remove events 295 * from result sets. 296 * 297 * @param cal Trash calendar object 298 * @return Collection of CoreEventInfo objects 299 */ 300 public Collection getDeletedProxies(BwCalendar cal) throws CalFacadeException { 301 HibSession sess = getSess(); 302 StringBuffer sb = new StringBuffer(); 303 304 sb.append("from "); 305 sb.append(BwEventAnnotation.class.getName()); 306 sb.append(" ev"); 307 sb.append(" where ev.calendar=:calendar"); 308 sb.append(" and ev.deleted=true"); 309 310 sess.createQuery(sb.toString()); 311 sess.setEntity("calendar", cal); 312 313 Collection evs = sess.getList(); 314 315 return postGetEvents(evs, privRead, noAccessReturnsNull); 316 } 317 281 318 public CoreEventInfo getEvent(int id) throws CalFacadeException { 282 319 HibSession sess = getSess(); … … 290 327 } 291 328 292 public void addEvent(BwEvent val, 329 public void addEvent(BwEvent val, 293 330 Collection overrides) throws CalFacadeException { 294 331 RecuridTable recurids = null; … … 321 358 throw new CalFacadeException(CalFacadeException.duplicateGuid); 322 359 } 323 360 324 361 if (val.getOrganizer() != null) { 325 362 sess.saveOrUpdate(val.getOrganizer()); … … 568 605 569 606 Filters flt = new Filters(filter, sb, qevName, debug); 607 608 // XXX we should do the following for both events and annotations 570 609 571 610 /* SEG: from Events ev where */ … … 808 847 } 809 848 810 private void eventQuery(Class cl, BwCalendar calendar, String guid, String rid, 849 private void eventQuery(Class cl, BwCalendar calendar, String guid, String rid, 811 850 boolean masterOnly) throws CalFacadeException { 812 851 HibSession sess = getSess(); … … 1091 1130 checked.setChecked(mstr, ca); 1092 1131 } 1093 1132 1094 1133 if (!ca.accessAllowed) { 1095 1134 return null; … … 1210 1249 * (DTSTART >= start AND DTSTART < end) OR 1211 1250 * (DTEND > start AND DTEND <= end) 1212 * 1251 * 1213 1252 * XXX This is wrong??? Last should be 1214 1253 * XXX (DTEND > start AND DTEND < end) … … 1282 1321 1283 1322 while (it.hasNext()) { 1284 CoreEventInfo cei = postGetEvent((BwEvent)it.next(), 1323 CoreEventInfo cei = postGetEvent((BwEvent)it.next(), 1285 1324 desiredAccess, nullForNoAccess); 1286 1325 1287 1326 if (cei != null) { 1288 1327 outevs.add(cei); … … 1302 1341 1303 1342 CurrentAccess ca = access.checkAccess(ev, desiredAccess, nullForNoAccess); 1304 1343 1305 1344 if (!ca.accessAllowed) { 1306 1345 return null; … … 1313 1352 */ 1314 1353 1354 if (ev instanceof BwEventAnnotation) { 1355 ev = new BwEventProxy((BwEventAnnotation)ev); 1356 } 1315 1357 CoreEventInfo cei = new CoreEventInfo(ev, ca); 1316 1358 1317 1359 return cei; 1318 1360 } trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java
r181 r356 1129 1129 /* If the guids are the same it's the same event for non recurring. 1130 1130 For recurring events the recurrence id must also be equal. 1131 * /1131 * / 1132 1132 int res = e1.getGuid().compareTo(e2.getGuid()); 1133 1133 if (res == 0) { … … 1136 1136 } 1137 1137 1138 /* Recurring - only the same if the recurrence id is equal * /1138 /* Recurring - only the same if the recurrence id is equal * / 1139 1139 return CalFacadeUtil.cmpObjval(e1.getRecurrence().getRecurrenceId(), 1140 1140 e2.getRecurrence().getRecurrenceId()); … … 1151 1151 } 1152 1152 1153 /* Dates are the same - try summary. * /1153 /* Dates are the same - try summary. * / 1154 1154 1155 1155 res = e1.getSummary().compareTo(e2.getSummary()); … … 1160 1160 // Just use guid 1161 1161 return e1.getGuid().compareTo(e2.getGuid()); 1162 */ 1163 /* If the guids are the same it's the same event for non recurring. 1164 For recurring events the recurrence id must also be equal. 1165 */ 1166 int res = e1.getGuid().compareTo(e2.getGuid()); 1167 if ((res == 0) && (!e1.getRecurring())) { 1168 return 0; 1169 } 1170 1171 if (!e2.getRecurring()) { 1172 return 1; 1173 } 1174 1175 /* Both recurring - only the same if the recurrence id is equal */ 1176 return CalFacadeUtil.cmpObjval(e1.getRecurrence().getRecurrenceId(), 1177 e2.getRecurrence().getRecurrenceId()); 1162 1178 } 1163 1179 trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEventProxy.java
r212 r356 243 243 } 244 244 245 /** Set the event's calendar 246 * 247 * @param val BwCalendar event's calendar 248 */ 249 public void setCalendar(BwCalendar val) { 250 ref.setCalendar(val); 251 } 252 253 /** Get the event's calendar 254 * 255 * @return CalendarVO the event's calendar 256 */ 257 public BwCalendar getCalendar() { 258 BwCalendar val = ref.getCalendar(); 259 if (val != null) { 260 return val; 261 } 262 263 return getTarget().getCalendar(); 264 } 265 245 266 /* (non-Javadoc) 246 267 * @see org.bedework.calfacade.BwEvent#setName(java.lang.String) … … 401 422 } 402 423 424 /** Set the event deleted flag 425 * 426 * @param val boolean true if the event is deleted 427 */ 428 public void setDeleted(boolean val) { 429 ref.setDeleted(val); 430 } 431 432 /** Get the event deleted flag 433 * 434 * @return boolean true if the event is deleted 435 */ 436 public boolean getDeleted() { 437 if (getTarget().getDeleted()) { 438 return true; 439 } 440 return ref.getDeleted(); 441 } 442 403 443 /* (non-Javadoc) 404 444 * @see org.bedework.calfacade.BwEvent#setStatus(char) … … 471 511 } 472 512 473 /** Set the event's calendar474 *475 * @param val CalendarVO event's calendar476 */477 public void setCalendar(BwCalendar val) {478 ref.setCalendar(val);479 }480 481 /** Get the event's calendar482 *483 * @return CalendarVO the event's calendar484 */485 public BwCalendar getCalendar() {486 BwCalendar val = ref.getCalendar();487 if (val != null) {488 return val;489 }490 491 return getTarget().getCalendar();492 }493 494 513 public void setDtstamp(String val) { 495 514 ref.setDtstamp(val); … … 786 805 } 787 806 return getTarget().getAttendeeEmailList(); 807 } 808 809 /* (non-Javadoc) 810 * @see org.bedework.calfacade.ifs.AttendeesI#copyAttendees() 811 */ 812 public Collection copyAttendees() { 813 if (ref.getAttendeesChanged()) { 814 return ref.copyAttendees(); 815 } 816 817 return getTarget().copyAttendees(); 788 818 } 789 819 … … 861 891 override.setEndType(ev.getEndType()); 862 892 override.setCreator(ev.getCreator()); 893 override.setGuid(ev.getGuid()); 863 894 864 895 if (owner != null) { trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeDefs.java
r2 r356 79 79 public static final int unsavedItemKey = -1; 80 80 81 /** Values which define how to retrieve recurring events. We have the 81 /** ENUM 82 * Values which define how to retrieve recurring events. We have the 82 83 * following choices (derived from caldav) 83 84 * trunk/calendar3/calFacade/src/org/bedework/calfacade/CoreEventInfo.java
r321 r356 68 68 public class CoreEventInfo implements Comparable, Comparator, Serializable { 69 69 protected BwEvent event; 70 70 71 71 /* This object contains information giving the current users access rights to 72 72 * the entity. … … 75 75 76 76 /** Constructor 77 * 77 * 78 78 */ 79 79 public CoreEventInfo() { … … 81 81 82 82 /** Constructor 83 * 83 * 84 84 */ 85 85 public CoreEventInfo(BwEvent event, CurrentAccess currentAccess) { … … 87 87 this.currentAccess = currentAccess; 88 88 } 89 89 90 90 /** 91 91 * @param val … … 101 101 return event; 102 102 } 103 103 104 104 /* Set the current users access rights. 105 * 105 * 106 106 * @param val CurrentAccess 107 107 */ … … 109 109 currentAccess = val; 110 110 } 111 111 112 112 /* Get the current users access rights. 113 * 113 * 114 114 * @return CurrentAccess 115 115 */ … … 131 131 } 132 132 133 if ( 01 == 02) {133 if (o1 == o2) { 134 134 return 0; 135 135 } trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r331 r356 78 78 import org.bedework.calfacade.ifs.Groups; 79 79 80 import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 81 80 82 import java.sql.Timestamp; 81 83 import java.util.Collection; … … 153 155 public void setSuperUser(boolean val) { 154 156 } 155 157 156 158 public boolean getSuperUser() { 157 159 return false; … … 176 178 public void dumpDbStats() throws CalFacadeException { 177 179 } 178 180 179 181 public Collection getDbStats() throws CalFacadeException { 180 182 return null; … … 370 372 * ==================================================================== */ 371 373 372 public void changeAccess(BwShareableDbentity ent, 374 public void changeAccess(BwShareableDbentity ent, 373 375 Collection aces) throws CalFacadeException { 374 376 checkOpen(); 377 throw new CalFacadeUnimplementedException(); 378 } 379 380 public CurrentAccess checkAccess(BwShareableDbentity ent, int desiredAccess, 381 boolean returnResult) throws CalFacadeException { 375 382 throw new CalFacadeUnimplementedException(); 376 383 } … … 731 738 } 732 739 740 public Collection getDeletedProxies() throws CalFacadeException { 741 throw new CalFacadeUnimplementedException(); 742 } 743 733 744 /* ==================================================================== 734 745 * Caldav support trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java
r331 r356 68 68 import org.bedework.calfacade.filter.BwFilter; 69 69 import org.bedework.calfacade.ifs.Groups; 70 71 import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 70 72 71 73 import java.util.Collection; … … 111 113 boolean debug) throws CalFacadeException; 112 114 113 /** Called after init to flag this user as a super user. 115 /** Called after init to flag this user as a super user. 114 116 * 115 117 * @param val true for a super user … … 117 119 public void setSuperUser(boolean val); 118 120 119 /** Called after init to flag this user as a super user. 121 /** Called after init to flag this user as a super user. 120 122 * 121 123 * @return boolean true if super user … … 130 132 public BwStats getStats() throws CalFacadeException; 131 133 132 /** Enable/disable db statistics 134 /** Enable/disable db statistics 133 135 * 134 136 * @param enable boolean true to turn on db statistics collection … … 137 139 public void setDbStatsEnabled(boolean enable) throws CalFacadeException; 138 140 139 /** 141 /** 140 142 * 141 143 * @return boolean true if statistics collection enabled … … 144 146 public boolean getDbStatsEnabled() throws CalFacadeException; 145 147 146 /** Dump db statistics 148 /** Dump db statistics 147 149 * 148 150 * @throws CalFacadeException if not admin … … 150 152 public void dumpDbStats() throws CalFacadeException; 151 153 152 /** Get db statistics 154 /** Get db statistics 153 155 * 154 156 * @return Collection of BwStats.StatsEntry objects … … 356 358 /** Change the access to the given calendar entity. 357 359 * 358 * @param ent BwShareableDbentity 360 * @param ent BwShareableDbentity 359 361 * @param aces Collection of ace 360 362 * @throws CalFacadeException 361 363 */ 362 public void changeAccess(BwShareableDbentity ent, 364 public void changeAccess(BwShareableDbentity ent, 363 365 Collection aces) throws CalFacadeException; 366 367 /** Check the access for the given entity. Returns the current access 368 * or null or optionally throws a no access exception. 369 * 370 * @param ent 371 * @param desiredAccess 372 * @param returnResult 373 * @return CurrentAccess 374 * @throws CalFacadeAccessException if returnResult false and no access 375 * @throws CalFacadeException 376 */ 377 public CurrentAccess checkAccess(BwShareableDbentity ent, int desiredAccess, 378 boolean returnResult) throws CalFacadeException; 364 379 365 380 /* ==================================================================== trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/EventsI.java
r331 r356 22 22 * ==================================================================== */ 23 23 24 /** Return one or more events using the calendar, guid and optionally a 24 /** Return one or more events using the calendar, guid and optionally a 25 25 * recurrence-id as a key. 26 26 * … … 53 53 * @return CoreEventInfo object representing event. 54 54 * @throws CalFacadeException 55 * 55 * 56 56 * @deprecated - other calendar systems won't support this. Doesn't make sense 57 57 * for recurring events. … … 125 125 * @param calendar BwCalendar object restricting search or null. 126 126 * @param filter BwFilter object restricting search or null. 127 * @param startDate DateTimeVOstart - may be null128 * @param endDate DateTimeVOend - may be null.127 * @param startDate BwDateTime start - may be null 128 * @param endDate BwDateTime end - may be null. 129 129 * @param recurRetrieval Takes value defined in CalFacadeDefs 130 130 * @return Collection of CoreEventInfo objects … … 135 135 int recurRetrieval) 136 136 throws CalFacadeException; 137 138 /** XXX temp I think 139 * Retrieve event proxies in the trash - they will be used to remove events 140 * from result sets. 141 * 142 * @return Collection of CoreEventInfo objects 143 */ 144 public Collection getDeletedProxies() throws CalFacadeException; 137 145 138 146 /* * Return true if this event is editable by the current user trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/EventInfo.java
r321 r356 129 129 */ 130 130 private String recurrenceId; 131 131 132 132 /* This object contains information giving the current users access rights to 133 133 * the entity. … … 311 311 return recurrenceId; 312 312 } 313 313 314 314 /* Set the current users access rights. 315 * 315 * 316 316 * @param val CurrentAccess 317 317 */ … … 319 319 currentAccess = val; 320 320 } 321 321 322 322 /* Get the current users access rights. 323 * 323 * 324 324 * @return CurrentAccess 325 325 */ … … 341 341 } 342 342 343 if ( 01 == 02) {343 if (o1 == o2) { 344 344 return 0; 345 345 } trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r336 r356 98 98 //import org.bedework.mail.MailerIntf; 99 99 100 import edu.rpi.cct.uwcal.access.PrivilegeDefs; 101 import edu.rpi.cct.uwcal.access.Acl.CurrentAccess; 100 102 import edu.rpi.cct.uwcal.resources.Resources; 101 103 … … 127 129 128 130 private boolean open; 129 131 130 132 private boolean superUser; 131 133 … … 310 312 superUser = val; 311 313 } 312 314 313 315 public boolean getSuperUser() { 314 316 return superUser; … … 334 336 return getCal().getDbStatsEnabled(); 335 337 } 336 338 337 339 public void dumpDbStats() throws CalFacadeException { 338 340 //if (!pars.getPublicAdmin()) { 339 341 // throw new CalFacadeAccessException(); 340 342 //} 341 343 342 344 trace(getStats().toString()); 343 345 getCal().dumpDbStats(); 344 346 } 345 347 346 348 public Collection getDbStats() throws CalFacadeException { 347 349 //if (!pars.getPublicAdmin()) { 348 350 // throw new CalFacadeAccessException(); 349 351 //} 350 352 351 353 return getCal().getDbStats(); 352 354 } … … 568 570 * ==================================================================== */ 569 571 570 public void changeAccess(BwShareableDbentity ent, 572 public void changeAccess(BwShareableDbentity ent, 571 573 Collection aces) throws CalFacadeException { 572 574 getCal().changeAccess(ent, aces); … … 583 585 throw new CalFacadeAccessException(); 584 586 } 585 587 586 588 timezones.saveTimeZone(tzid, vtz); 587 589 } … … 604 606 throw new CalFacadeAccessException(); 605 607 } 606 608 607 609 timezones.clearPublicTimezones(); 608 610 } … … 698 700 } 699 701 } 700 702 701 703 getCal().updateCalendar(val); 702 704 } … … 1459 1461 } 1460 1462 1461 public Collection getEvent(BwSubscription sub, BwCalendar cal, 1463 public Collection getEvent(BwSubscription sub, BwCalendar cal, 1462 1464 String guid, String recurrenceId, 1463 1465 int recurRetrieval) throws CalFacadeException { … … 1524 1526 } 1525 1527 } 1526 1528 1527 1529 /* Iterate over the subscriptions and merge the results. 1528 * 1530 * 1529 1531 * First we iterate over the subscriptions looking for internal calendars. 1530 1532 * These we accumulate as children of a single calendar allowing a single 1531 1533 * query for all calendars. 1532 * 1534 * 1533 1535 * We will then iterate again to handle external calendars. (Not implemented) 1534 1536 */ … … 1536 1538 BwCalendar internal = new BwCalendar(); 1537 1539 setupSharableEntity(internal); 1538 1540 1539 1541 // For locating subscriptions from calendar 1540 1542 HashMap sublookup = new HashMap(); … … 1544 1546 1545 1547 BwCalendar calendar = getSubCalendar(sub); 1546 1548 1547 1549 if (calendar != null) { 1548 1550 internal.addChild(calendar); … … 1550 1552 } 1551 1553 } 1552 1554 1553 1555 if (internal.getChildren().size() == 0) { 1554 1556 if (debug) { 1555 1557 trace("No children for internal calendar"); 1556 1558 } 1557 1559 1558 1560 return ts; 1559 1561 } 1560 1562 1561 1563 ts.addAll(postProcess(getCal().getEvents(internal, filter, 1562 1564 startDate, endDate, … … 1565 1567 1566 1568 return ts; 1567 }1568 1569 private BwCalendar getSubCalendar(BwSubscription sub) throws CalFacadeException {1570 if (!sub.getInternalSubscription() || sub.getCalendarDeleted()) {1571 return null;1572 }1573 1574 BwCalendar calendar = sub.getCalendar();1575 1576 if (calendar != null) {1577 return calendar;1578 }1579 1580 String path;1581 String uri = sub.getUri();1582 1583 if (uri.startsWith(CalFacadeDefs.bwUriPrefix)) {1584 path = uri.substring(CalFacadeDefs.bwUriPrefix.length());1585 } else {1586 // Shouldn't happen?1587 path = uri;1588 }1589 1590 if (debug) {1591 trace("Search for calendar \"" + path + "\"");1592 }1593 1594 calendar = getCal().getCalendar(path);1595 if (calendar == null) {1596 // Assume deleted1597 sub.setCalendarDeleted(true);1598 updateSubscription(sub);1599 } else {1600 sub.setCalendar(calendar);1601 }1602 1603 return calendar;1604 }1605 1606 private void putSublookup(HashMap sublookup, BwSubscription sub, BwCalendar cal) {1607 if (cal.getCalendarCollection()) {1608 // Leaf node1609 sublookup.put(new Integer(cal.getId()), sub);1610 return;1611 }1612 1613 Iterator it = cal.iterateChildren();1614 while (it.hasNext()) {1615 putSublookup(sublookup, sub, (BwCalendar)it.next());1616 }1617 1569 } 1618 1570 … … 1686 1638 throw new CalFacadeAccessException(); 1687 1639 } 1688 1640 1689 1641 event.setCalendar(cal); 1690 1642 … … 1718 1670 } 1719 1671 1720 public boolean deleteSubscribedEvent(BwEvent event) throws CalFacadeException { 1721 /* 1722 if (!getCal().fromSubscription(event)) { 1723 throw new CalFacadeException( 1724 "Attempt to hide a non-subscribed event: " + event); 1725 } 1726 */ 1727 throw new CalFacadeException("Unimplemented: "); 1672 /** For an event to which we have write access we simply mark it deleted. 1673 * 1674 * <p>Otherwise we add an annotation maarking the event as deleted. 1675 * 1676 * @param event 1677 * @throws CalFacadeException 1678 */ 1679 public void markDeleted(BwEvent event) throws CalFacadeException { 1680 CurrentAccess ca = getCal().checkAccess(event, PrivilegeDefs.privWrite, true); 1681 1682 if (ca.accessAllowed) { 1683 // Have write access - just set the flag and move it into the owners trash 1684 event.setDeleted(true); 1685 event.setCalendar(getCal().getTrashCalendar(event.getOwner())); 1686 updateEvent(event); 1687 return; 1688 } 1689 1690 // Need to annotate it as deleted 1691 1692 BwEventProxy proxy = BwEventProxy.makeAnnotation(event, event.getOwner()); 1693 1694 // Where does the ref go? Not in the same calendar - we have no access 1695 // Put it in the trash - but don't delete on empty trash 1696 1697 BwCalendar cal = getCal().getTrashCalendar(getUser()); 1698 proxy.setOwner(getUser()); 1699 proxy.setDeleted(true); 1700 proxy.setCalendar(cal); 1701 addEvent(cal, proxy, null); 1728 1702 } 1729 1703 … … 1929 1903 }*/ 1930 1904 1931 private EventInfo postProcess(CoreEventInfo cei, BwSubscription sub, 1905 private BwCalendar getSubCalendar(BwSubscription sub) throws CalFacadeException { 1906 if (!sub.getInternalSubscription() || sub.getCalendarDeleted()) { 1907 return null; 1908 } 1909 1910 BwCalendar calendar = sub.getCalendar(); 1911 1912 if (calendar != null) { 1913 return calendar; 1914 } 1915 1916 String path; 1917 String uri = sub.getUri(); 1918 1919 if (uri.startsWith(CalFacadeDefs.bwUriPrefix)) { 1920 path = uri.substring(CalFacadeDefs.bwUriPrefix.length()); 1921 } else { 1922 // Shouldn't happen? 1923 path = uri; 1924 } 1925 1926 if (debug) { 1927 trace("Search for calendar \"" + path + "\""); 1928 } 1929 1930 calendar = getCal().getCalendar(path); 1931 if (calendar == null) { 1932 // Assume deleted 1933 sub.setCalendarDeleted(true); 1934 updateSubscription(sub); 1935 } else { 1936 sub.setCalendar(calendar); 1937 } 1938 1939 return calendar; 1940 } 1941 1942 private void putSublookup(HashMap sublookup, BwSubscription sub, BwCalendar cal) { 1943 if (cal.getCalendarCollection()) { 1944 // Leaf node 1945 sublookup.put(new Integer(cal.getId()), sub); 1946 return; 1947 } 1948 1949 Iterator it = cal.iterateChildren(); 1950 while (it.hasNext()) { 1951 putSublookup(sublookup, sub, (BwCalendar)it.next()); 1952 } 1953 } 1954 1955 private EventInfo postProcess(CoreEventInfo cei, BwSubscription sub, 1932 1956 HashMap sublookup) 1933 1957 throws CalFacadeException { … … 1942 1966 */ 1943 1967 BwEvent ev = cei.getEvent(); 1944 1968 1945 1969 if (ev instanceof BwEventAnnotation) { 1946 1970 ev = new BwEventProxy((BwEventAnnotation)ev); … … 1948 1972 1949 1973 EventInfo ei = new EventInfo(ev); 1950 1974 1951 1975 if (sub != null) { 1952 1976 ei.setSubscription(sub); … … 1965 1989 ArrayList al = new ArrayList(); 1966 1990 1991 /* XXX possibly not a great idea. We should probably retrieve the 1992 * deleted events at the same time as we retrieve the desired set. 1993 * 1994 * This way we get too many. 1995 */ 1996 Collection deleted = getCal().getDeletedProxies(); 1997 1967 1998 Iterator it = ceis.iterator(); 1968 1999 1969 2000 while (it.hasNext()) { 1970 EventInfo ei = postProcess((CoreEventInfo)it.next(), sub, null); 1971 al.add(ei); 2001 CoreEventInfo cei = (CoreEventInfo)it.next(); 2002 2003 if (!deleted.contains(cei)) { 2004 EventInfo ei = postProcess(cei, sub, null); 2005 al.add(ei); 2006 } 1972 2007 } 1973 2008 … … 1979 2014 ArrayList al = new ArrayList(); 1980 2015 2016 /* XXX possibly not a great idea. We should probably retrieve the 2017 * deleted events at the same time as we retrieve the desired set. 2018 * 2019 * This way we get too many. 2020 */ 2021 Collection deleted = getCal().getDeletedProxies(); 2022 2023 //traceDeleted(deleted); 2024 1981 2025 Iterator it = ceis.iterator(); 1982 2026 1983 2027 while (it.hasNext()) { 1984 EventInfo ei = postProcess((CoreEventInfo)it.next(), null, sublookup); 1985 al.add(ei); 2028 CoreEventInfo cei = (CoreEventInfo)it.next(); 2029 2030 // if (!deleted.contains(cei)) { 2031 if (!isDeleted(deleted, cei)) { 2032 EventInfo ei = postProcess(cei, null, sublookup); 2033 al.add(ei); 2034 } 1986 2035 } 1987 2036 1988 2037 return al; 2038 } 2039 2040 /* XXX This is here because contains doesn't appear to be working with 2041 * CoreEventInfo objects (or their events) 2042 * 2043 * This is either the TreeSet impleemntation (unlikely) or something to 2044 * do with comparisons but under debug the compare method doesn't even get 2045 * called for some of he objects in deleted 2046 */ 2047 private boolean isDeleted(Collection deleted, CoreEventInfo tryCei) { 2048 if ((deleted == null) || (deleted.size() == 0)) { 2049 return false; 2050 } 2051 boolean try1 = false; 2052 2053 Iterator it = deleted.iterator(); 2054 while (it.hasNext()) { 2055 CoreEventInfo cei = (CoreEventInfo)it.next(); 2056 BwEventProxy pr = (BwEventProxy)cei.getEvent(); 2057 if (debug) { 2058 trace("Deleted: " + pr.getTarget().getId()); 2059 } 2060 2061 if (cei.equals(tryCei)) { 2062 if (!debug) { 2063 return true; 2064 } 2065 2066 trace("Matched: " + tryCei.getEvent().getId()); 2067 try1 = true; 2068 break; 2069 } 2070 } 2071 2072 // only here for debug mode 2073 boolean try2 = deleted.contains(tryCei); 2074 trace(" try2 for : " + tryCei.getEvent().getId() + " gives " + try2); 2075 2076 return try1 || try2; 2077 } 2078 2079 private void traceDeleted(Collection c) { 2080 Iterator it = c.iterator(); 2081 while (it.hasNext()) { 2082 CoreEventInfo cei = (CoreEventInfo)it.next(); 2083 BwEventProxy pr = (BwEventProxy)cei.getEvent(); 2084 trace("Deleted: " + pr.getTarget().getId()); 2085 } 1989 2086 } 1990 2087 … … 2038 2135 2039 2136 if (userCreated) { 2040 initUser(auth, cali);2137 initUser(auth, cali); 2041 2138 } 2042 2139 … … 2062 2159 } 2063 2160 } 2064 2161 2065 2162 private void initUser(BwUser user, Calintf cali) throws CalFacadeException { 2066 2163 // Add preferences … … 2194 2291 public Collection getEvent(BwCalendar cal, String guid, String rid, 2195 2292 int recurRetrieval) throws CalFacadeException { 2196 return CalSvc.this.getEvent(BwSubscription.makeSubscription(cal), cal, guid, 2293 return CalSvc.this.getEvent(BwSubscription.makeSubscription(cal), cal, guid, 2197 2294 rid, recurRetrieval); 2198 2295 } trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java
r336 r356 108 108 public abstract void init(CalSvcIPars pars) throws CalFacadeException; 109 109 110 /** Called after init to flag this user as a super user. 110 /** Called after init to flag this user as a super user. 111 111 * 112 112 * @param val true for a super user … … 114 114 public abstract void setSuperUser(boolean val); 115 115 116 /** Called after init to flag this user as a super user. 116 /** Called after init to flag this user as a super user. 117 117 * 118 118 * @return boolean true if super user … … 127 127 public abstract BwStats getStats() throws CalFacadeException; 128 128 129 /** Enable/disable db statistics 129 /** Enable/disable db statistics 130 130 * 131 131 * @param enable boolean true to turn on db statistics collection … … 134 134 public abstract void setDbStatsEnabled(boolean enable) throws CalFacadeException; 135 135 136 /** 136 /** 137 137 * 138 138 * @return boolean true if statistics collection enabled … … 141 141 public abstract boolean getDbStatsEnabled() throws CalFacadeException; 142 142 143 /** Dump db statistics 143 /** Dump db statistics 144 144 * 145 145 * @throws CalFacadeException if not admin … … 147 147 public abstract void dumpDbStats() throws CalFacadeException; 148 148 149 /** Get db statistics 149 /** Get db statistics 150 150 * 151 151 * @return Collection of BwStats.StatsEntry objects … … 407 407 /** Change the access to the given calendar entity. 408 408 * 409 * @param ent BwShareableDbentity 409 * @param ent BwShareableDbentity 410 410 * @param aces Collection of ace 411 411 * @throws CalFacadeException 412 412 */ 413 public abstract void changeAccess(BwShareableDbentity ent, 413 public abstract void changeAccess(BwShareableDbentity ent, 414 414 Collection aces) throws CalFacadeException; 415 415 … … 1083 1083 * @return EventInfo value object representing event. 1084 1084 * @throws CalFacadeException 1085 * 1085 * 1086 1086 * @deprecated - other calendar systems won't support this. Doesn't make sense 1087 1087 * for recurring events. … … 1104 1104 * @throws CalFacadeException 1105 1105 */ 1106 public abstract Collection getEvent(BwSubscription sub, BwCalendar cal, 1107 String guid, 1106 public abstract Collection getEvent(BwSubscription sub, BwCalendar cal, 1107 String guid, 1108 1108 String recurrenceId, 1109 1109 int recurRetrieval) … … 1231 1231 public abstract void updateEvent(BwEvent event) throws CalFacadeException; 1232 1232 1233 /** Delete a subscribed event for the current user. 1234 * 1235 * <p>This is a partially implemented feature which currently only changes 1236 * the synch state. What we need is in effect a reverse event ref - I guess 1237 * a new purpose, which indicates the event is hidden for this user. 1238 * 1239 * @param event BwEvent object 1240 * @return boolean false for no such item. 1241 * @throws CalFacadeException 1242 */ 1243 public abstract boolean deleteSubscribedEvent(BwEvent event) 1244 throws CalFacadeException; 1233 /** For an event to which we have write access we simply mark it deleted. 1234 * 1235 * <p>Otherwise we add an annotation maarking the event as deleted. 1236 * 1237 * @param event 1238 * @throws CalFacadeException 1239 */ 1240 public abstract void markDeleted(BwEvent event) throws CalFacadeException; 1245 1241 1246 1242 /* ==================================================================== trunk/calendar3/synchml/src/edu/rpi/cct/uwcal/synchml/common/Synchml.java
r336 r356 57 57 import org.bedework.calfacade.BwEvent; 58 58 import org.bedework.calfacade.BwEventObj; 59 import org.bedework.calfacade.BwRecurrence; 59 60 import org.bedework.calfacade.BwSynchData; 60 61 import org.bedework.calfacade.BwSynchInfo; … … 122 123 this.deviceId = deviceId; 123 124 this.debug = debug; 124 CalSvcIPars pars = new CalSvcIPars(account, 125 CalSvcIPars pars = new CalSvcIPars(account, 125 126 account, 126 127 null, // XXX Requires an env prefix … … 271 272 public boolean deleteEvent(VEvent val) throws CalFacadeException { 272 273 // FIXME - We need a subscription to the calendar we are synching - second par 273 return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(), 274 null, // BwCalendar 275 null, // overrides 274 return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(), 275 null, // BwCalendar 276 null, // overrides 276 277 val, debug).getEvent()); 277 278 } … … 458 459 */ 459 460 public boolean deleteEvent(BwEvent val) throws CalFacadeException { 460 EventInfo ei = svci.getEvent(val.getId()); 461 462 if (ei == null) { 461 String recurId = null; 462 463 BwRecurrence recur = val.getRecurrence(); 464 465 if (recur != null) { 466 recurId = recur.getRecurrenceId(); 467 } 468 469 int recurRetrieval = CalFacadeDefs.retrieveRecurMaster; 470 if (recurId != null) { 471 // Get the instance 472 recurRetrieval = CalFacadeDefs.retrieveRecurExpanded; 473 } 474 Collection evs = svci.getEvent(null, val.getCalendar(), val.getGuid(), 475 recurId, recurRetrieval); 476 477 if ((evs == null) || (evs.size() == 0)) { 463 478 return false; 464 479 } 465 480 466 if (ei.getKind() == EventInfo.kindEntry) {467 CalSvcI.DelEventResult der = svci.deleteEvent(ei.getEvent(), true);468 return der.eventDeleted; 469 }470 471 if (ei.getKind() == EventInfo.kindAdded) {472 svci.deleteEvent(ei.getEvent(), true); 473 } else if (ei.getKind() == EventInfo.kindUndeletable) {474 svci.deleteSubscribedEvent(ei.getEvent()); 475 }481 /* We should have one only 482 */ 483 484 if (evs.size() != 1) { 485 throw new CalFacadeException("org.dedwork.synchml.unexpected.result"); 486 } 487 488 EventInfo ei = (EventInfo)evs.iterator().next(); 489 490 svci.markDeleted(ei.getEvent()); 476 491 477 492 return true; trunk/calendar3/webclient/src/org/bedework/webclient/BwDelEventAction.java
r55 r356 87 87 } 88 88 89 int id = form.getEventId();89 CalSvcI svci = form.fetchSvci(); 90 90 91 if (id < 0) { 91 EventInfo ei = findEvent(request, form); 92 93 if (ei == null) { 92 94 // Do nothing 93 form.getErr().emit("org.bedework.client.error.nosuchevent" , id);95 form.getErr().emit("org.bedework.client.error.nosuchevent"); 94 96 return "doNothing"; 95 97 } 96 98 97 CalSvcI svci = form.fetchSvci(); 98 99 EventInfo ei = svci.getEvent(id); 100 101 if (ei == null) { 102 // Do nothing 103 form.getErr().emit("org.bedework.client.error.nosuchevent", id); 104 return "doNothing"; 105 } 106 99 // XXX temp - just mark as deleted 100 /* 107 101 CalSvcI.DelEventResult delResult = form.fetchSvci().deleteEvent(ei.getEvent(), true); 108 102 … … 115 109 form.getMsg().emit("org.bedework.client.message.deleted.locations", 1); 116 110 } 111 */ 112 svci.markDeleted(ei.getEvent()); 117 113 118 114 form.getMsg().emit("org.bedework.client.message.deleted.events", 1); trunk/calendar3/webclient/war/WEB-INF/struts-config.xml
r355 r356 414 414 </action> 415 415 416 <!-- ..................... subscriptions s.......................... -->416 <!-- ..................... subscriptions .......................... --> 417 417 418 418 <action path="/subs/showSubs" trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
r338 r356 103 103 /** Name of the init parameter holding our name */ 104 104 private static final String appNameInitParameter = "rpiappname"; 105 105 106 106 public String getId() { 107 107 return getClass().getName(); … … 130 130 } 131 131 } 132 132 133 133 if (getPublicAdmin(form)) { 134 134 /** We may want to masquerade as a different user … … 170 170 // Embed in request for pages that cannot access the form (loggedOut) 171 171 request.setAttribute("org.bedework.action.appbase", appBase); 172 } 173 174 if (!form.getNewSession()) { 175 // First time through here for this session 176 177 // Set to default view 178 setView(null, form); 172 179 } 173 180 … … 293 300 } 294 301 295 /** Method to retrieve an event. An event is identified by the calendar + 302 /** Method to retrieve an event. An event is identified by the calendar + 296 303 * guid + recurrence id. We also take the subscription id as a parameter so 297 304 * we can pass it along in the result for display purposes. 298 * 305 * 299 306 * <p>We cannot just take the calendar from the subscription, because the 300 * calendar has to be the actual collection containing the event. A 307 * calendar has to be the actual collection containing the event. A 301 308 * subscription may be to higher up the tree (i.e. a folder). 302 * 309 * 303 310 * <p>We need to also allow the calendar path instead of the id. External 304 * calendars don't have an id. This means changing the api (again) and 311 * calendars don't have an id. This means changing the api (again) and 305 312 * changing the urls (again). 306 * 313 * 307 314 * <p>It may be more appropriate to simply encode a url to the event. 308 * 315 * 309 316 * <p>Request parameters<ul> 310 317 * <li>"subid" subscription id for event. < 0 if there is none … … 337 344 } 338 345 } 339 346 340 347 int calId = getIntReqPar(request, "calid", -1); 341 348 BwCalendar cal = null; … … 345 352 return null; 346 353 } 347 354 348 355 cal = svci.getCalendar(calId); 349 356 350 357 if (cal == null) { 351 358 // Assume no access … … 600 607 HttpSession session = request.getSession(); 601 608 ServletContext sc = session.getServletContext(); 602 609 603 610 String appName = sc.getInitParameter("bwappname"); 604 611 605 612 if ((appName == null) || (appName.length() == 0)) { 606 613 appName = "unknown-app-name"; 607 614 } 608 615 609 616 String envPrefix = "org.bedework.app." + appName + "."; 610 617 611 618 env = new CalEnv(envPrefix, debug); 612 619 frm.assignEnv(env); 613 620 614 621 return env; 615 622 } … … 670 677 HttpSession sess = request.getSession(false); 671 678 String appName = getAppName(sess); 672 679 673 680 if (s != null) { 674 681 if (debug) { … … 777 784 return s; 778 785 } 779 786 780 787 private String getAppName(HttpSession sess) { 781 788 ServletContext sc = sess.getServletContext(); … … 785 792 appname = "?"; 786 793 } 787 794 788 795 return appname; 789 796 } … … 797 804 HttpSession hsess = request.getSession(); 798 805 BwCallback cb = (BwCallback)hsess.getAttribute(BwCallback.cbAttrName); 799 806 800 807 if (cb == null) { 801 808 if (form.getDebug()) { … … 809 816 cb.out(); 810 817 } catch (Throwable t) {} 811 818 812 819 try { 813 820 cb.close(); 814 821 } catch (Throwable t) {} 815 822 } 816 823 817 824 return true; 818 825 } … … 876 883 svci.getUser()); 877 884 } 878 885 879 886 // XXX access - disable use of roles 880 887 access = svci.getUserAuth().getUsertype(); … … 897 904 runAsUser = form.getEnv().getAppProperty("run.as.user"); 898 905 } 899 900 CalSvcIPars pars = new CalSvcIPars(user, //access, 901 runAsUser, 906 907 CalSvcIPars pars = new CalSvcIPars(user, //access, 908 runAsUser, 902 909 form.getEnv().getAppPrefix(), 903 910 publicAdmin, … … 917 924 par.svlt = servlet; 918 925 par.req = request; 919 926 920 927 if (publicAdmin) { 921 928 try { 922 929 ua = svci.getUserAuth(user, par); 923 930 924 931 form.assignAuthorisedUser(ua.getUsertype() != UserAuth.noPrivileges); 925 932 svci.setSuperUser((ua.getUsertype() & UserAuth.superUser) != 0); 926 933 927 934 // XXX access - disable use of roles 928 935 access = ua.getUsertype(); 929 936 930 937 if (debug) { 931 938 debugMsg("UserAuth says that current user has the type: " + … … 944 951 } 945 952 } 946 953 947 954 form.assignUserVO((BwUser)svci.getUser().clone()); 948 955
