Changeset 207
- Timestamp:
- 02/25/06 17:51:32
- Files:
-
- trunk/calendar3/calCore/resources/hbms/Event.hbm.xml (modified) (1 diff)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java (modified) (1 diff)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfHelper.java (modified) (2 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (7 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/EventProperties.java (modified) (2 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (18 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java (modified) (3 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/EventsI.java (added)
- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java (modified) (12 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (6 diffs)
- trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java (modified) (5 diffs)
- trunk/calendar3/deployment/webpublic/webapp/resources/demoskins/default/default/default.xsl (modified) (9 diffs)
- trunk/calendar3/docs/todo.txt (modified) (1 diff)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/BwEventUtil.java (modified) (4 diffs)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalCallback.java (modified) (2 diffs)
- trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java (modified) (5 diffs)
- trunk/calendar3/synchml/src/edu/rpi/cct/uwcal/synchml/common/Synchml.java (modified) (6 diffs)
- trunk/calendar3/test/src/org/bedework/tests/calsvc/CalSvcTestUtil.java (modified) (1 diff)
- trunk/calendar3/test/src/org/bedework/tests/calsvc/CalSvcTestWrapper.java (modified) (1 diff)
- trunk/calendar3/test/src/org/bedework/tests/ical/IcalTranslatorTest.java (modified) (5 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java (modified) (1 diff)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventAction.java (modified) (1 diff)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventRefAction.java (modified) (3 diffs)
- trunk/calendar3/webclient/src/org/bedework/webclient/BwSubscribeAction.java (deleted)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java (modified) (3 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/UploadAction.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/calCore/resources/hbms/Event.hbm.xml
r200 r207 210 210 ]]></query> 211 211 212 <!-- Use this to see if a guid exists. The count should be zero or one-->212 <!-- Use this to see if a guid exists. --> 213 213 <query name="getGuidCount"><![CDATA[ 214 214 select count(*) from org.bedework.calfacade.BwEventObj as ev 215 215 where ev.guid = :guid 216 216 ]]></query> 217 218 <!-- Use this to see if a guid exists in a calendar. The count should be zero or one --> 219 <query name="getGuidCountCalendar"><![CDATA[ 220 select count(*) from org.bedework.calfacade.BwEventObj as ev 221 where ev.calendar=:cal and ev.guid = :guid 222 ]]></query> 217 223 </hibernate-mapping> 218 224 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java
r164 r207 79 79 * @throws CalFacadeException 80 80 */ 81 public Calendars(Calintf cal, AccessUtil access, BwUser user, boolean debug) 81 public Calendars(Calintf cal, AccessUtil access, BwUser user, 82 int currentMode, boolean ignoreCreator, boolean debug) 82 83 throws CalFacadeException { 83 super(cal, access, user, debug);84 super(cal, access, user, currentMode, ignoreCreator, debug); 84 85 85 86 publicCalendarRootPath = "/" + getSyspars().getPublicCalendarRoot(); trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfHelper.java
r99 r207 79 79 protected BwUser user; 80 80 81 protected int currentMode = CalintfUtil.guestMode; 82 83 protected boolean ignoreCreator; 84 81 85 private transient Logger log; 82 86 … … 89 93 */ 90 94 public CalintfHelper(Calintf cal, AccessUtil access, 91 BwUser user, boolean debug) { 95 BwUser user, int currentMode, boolean ignoreCreator, 96 boolean debug) { 92 97 this.cal = cal; 93 98 this.access = access; 94 99 this.user = user; 100 this.currentMode = currentMode; 101 this.ignoreCreator = ignoreCreator; 95 102 this.debug = debug; 96 103 } trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r191 r207 311 311 access.setAuthUser(authUser); 312 312 313 events = new Events(this, access, this.user, debug); 314 315 calendars = new Calendars(this, access, this.user, debug); 316 317 categories = new EventProperties(this, access, this.user, 313 events = new Events(this, access, this.user, currentMode, 314 ignoreCreator, debug); 315 316 calendars = new Calendars(this, access, this.user, currentMode, 317 ignoreCreator, debug); 318 319 categories = new EventProperties(this, access, this.user, currentMode, 320 ignoreCreator, 318 321 "word", BwCategory.class.getName(), 319 322 "getCategoryRefs", 320 323 -1, debug); 321 locations = new EventProperties(this, access, this.user, 324 locations = new EventProperties(this, access, this.user, currentMode, 325 ignoreCreator, 322 326 "address", BwLocation.class.getName(), 323 "getLocationRefs",327 "getLocationRefs", 324 328 CalFacadeDefs.maxReservedLocationId, debug); 325 sponsors = new EventProperties(this, access, this.user, 329 sponsors = new EventProperties(this, access, this.user, currentMode, 330 ignoreCreator, 326 331 "name", BwSponsor.class.getName(), 327 332 "getSponsorRefs", … … 928 933 checkOpen(); 929 934 930 return (BwCategory)categories.get(id , currentMode, ignoreCreator);935 return (BwCategory)categories.get(id); 931 936 } 932 937 … … 977 982 checkOpen(); 978 983 979 return (BwLocation)locations.get(id , currentMode, ignoreCreator);984 return (BwLocation)locations.get(id); 980 985 } 981 986 … … 1026 1031 checkOpen(); 1027 1032 1028 return (BwSponsor)sponsors.get(id , currentMode, ignoreCreator);1033 return (BwSponsor)sponsors.get(id); 1029 1034 } 1030 1035 … … 1070 1075 throws CalFacadeException { 1071 1076 return events.getEvents(calendar, filter, 1072 startDate, endDate, recurRetrieval, 1073 currentMode, ignoreCreator); 1077 startDate, endDate, recurRetrieval); 1074 1078 } 1075 1079 … … 1079 1083 } 1080 1084 1081 public Collection getEvent(String guid, String rid, 1082 Integer seqnum, 1085 public Collection getEvent(BwCalendar calendar, String guid, String rid, 1083 1086 int recurRetrieval) throws CalFacadeException { 1084 1087 checkOpen(); 1085 return events.getEvent( guid, rid, seqnum, recurRetrieval);1088 return events.getEvent(calendar, guid, rid, recurRetrieval); 1086 1089 } 1087 1090 … … 1105 1108 checkOpen(); 1106 1109 1107 if (currentMode == CalintfUtil.guestMode) { 1108 return false; 1109 } 1110 1111 if (val.getPublick() != (currentMode == CalintfUtil.publicAdminMode)) { 1112 return false; 1113 } 1114 1115 return user.equals(val.getCreator()); 1116 } 1117 1118 /* ==================================================================== 1119 * Caldav support 1120 * Caldav as it stands at the moment requires that we save the arbitary 1121 * names clients might assign to events. 1122 * ==================================================================== */ 1110 return events.editable(val); 1111 } 1123 1112 1124 1113 public Collection getEventsByName(BwCalendar cal, String val) trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/EventProperties.java
r99 r207 96 96 */ 97 97 public EventProperties(Calintf cal, AccessUtil access, BwUser user, 98 int currentMode, boolean ignoreCreator, 98 99 String keyFieldName, 99 100 String className, 100 101 String refQuery, 101 int minId, 102 int minId, 102 103 boolean debug) { 103 super(cal, access, user, debug);104 super(cal, access, user, currentMode, ignoreCreator, debug); 104 105 105 106 this.keyFieldName = keyFieldName; … … 177 178 * 178 179 * @param id int id of the entity 179 * @param currentMode mode we are in (guest etc)180 * @param ignoreCreator true if we ignore creator181 180 * @return BwEventProperty object representing the entity in question 182 181 * null if it doesn't exist. 183 182 * @throws CalFacadeException 184 183 */ 185 public BwEventProperty get(int id, 186 int currentMode, 187 boolean ignoreCreator) throws CalFacadeException { 184 public BwEventProperty get(int id) throws CalFacadeException { 188 185 HibSession sess = getSess(); 189 186 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r200 r207 68 68 import org.bedework.calfacade.ifs.CalTimezones; 69 69 import org.bedework.calfacade.ifs.Calintf; 70 import org.bedework.calfacade.ifs. Calintf.DelEventResult;70 import org.bedework.calfacade.ifs.EventsI; 71 71 import org.bedework.calfacade.CalFacadeException; 72 72 import org.bedework.icalendar.VEventUtil; … … 95 95 * @author Mike Douglass douglm@rpi.edu 96 96 */ 97 public class Events extends CalintfHelper {97 public class Events extends CalintfHelper implements EventsI { 98 98 private transient UUIDHexGenerator uuidGen; 99 99 … … 105 105 * @param debug 106 106 */ 107 public Events(Calintf cal, AccessUtil access, BwUser user, boolean debug) { 108 super(cal, access, user, debug); 109 } 110 111 /** Return one or more events using the guid and optionally a sequence number 112 * and recurrence-id as a key. 113 * 114 * <p>For non-recurring events, one and only one event should be returned 115 * for any given guid. 116 * 117 * <p>For recurring events, the guid defines the 'master' event defining 118 * the rules together with any exceptions. 119 * 120 * <p>The sequence number and the recurrence id define a particular instance 121 * of a recurrence. 122 * 123 * <p>To specify the master entry provide a null recurrenceId or use the 124 * recurRetrieval parameter. 125 * 126 * <p>If a recurrence id is given and recurRetrieval=retrieveRecurMaster the 127 * associated master event will be returned rather than the instance or any 128 * override. 129 * 130 * @param guid String guid for the event 131 * @param rid String recurrence id, null for non-recurring, null valued for 132 * master or non-null-valued for particular occurrence. 133 * @param seqnum Integer sequence nbr 134 * @param recurRetrieval Takes value defined in CalFacadeDefs. 135 * @return Collection objects representing event - possibly with overrides. 136 * @throws CalFacadeException 137 */ 138 public Collection getEvent(String guid, String rid, 139 Integer seqnum, 107 public Events(Calintf cal, AccessUtil access, BwUser user, 108 int currentMode, boolean ignoreCreator, boolean debug) { 109 super(cal, access, user, currentMode, ignoreCreator, debug); 110 } 111 112 public Collection getEvent(BwCalendar calendar, String guid, String rid, 140 113 int recurRetrieval) throws CalFacadeException { 141 114 BwEvent ev = null; … … 146 119 if (rid == null) { 147 120 // First look in the events table for the master. 148 eventQuery(BwEventObj.class, guid, rid, seqnum, true);121 eventQuery(BwEventObj.class, calendar, guid, rid, true); 149 122 150 123 /* There should be one only */ … … 160 133 if (!user.equals(ev.getOwner())) { 161 134 // XXX that check prevents annotation by owner - is that OK? 162 eventQuery(BwEventAnnotation.class, guid, rid, seqnum, true);135 eventQuery(BwEventAnnotation.class, calendar, guid, rid, true); 163 136 BwEventAnnotation ann = (BwEventAnnotation)postGetEvent((BwEvent)sess.getUnique(), 164 137 privRead, noAccessReturnsNull); … … 208 181 */ 209 182 if (recurRetrieval == CalFacadeDefs.retrieveRecurOverrides) { 210 eventQuery(BwEventAnnotation.class, guid, rid, seqnum, false);183 eventQuery(BwEventAnnotation.class, calendar, guid, rid, false); 211 184 212 185 Collection ovs = sess.getList(); … … 239 212 sb.append(" where rec.master=:master "); 240 213 241 if (seqnum != null) {242 sb.append(" and rec.master.sequence=:seq ");243 }244 245 214 sess.createQuery(sb.toString()); 246 215 247 216 sess.setEntity("master", master); 248 249 if (seqnum != null) {250 sess.setInt("seq", seqnum.intValue());251 }252 217 253 218 Collection instances = sess.getList(); … … 266 231 /* Rid is non-null - look first for an override then for the instance. 267 232 */ 268 eventQuery(BwEventAnnotation.class, guid, rid, seqnum, false);233 eventQuery(BwEventAnnotation.class, calendar, guid, rid, false); 269 234 BwEventAnnotation override = (BwEventAnnotation)sess.getUnique(); 270 235 … … 282 247 sb.append(" where rec.master.guid=:guid "); 283 248 284 if (seqnum != null) {285 sb.append(" and rec.master.sequence=:seq ");286 }287 288 249 sb.append(" and rec.recurrenceId=:rid "); 289 250 … … 291 252 292 253 sess.setString("guid", guid); 293 294 if (seqnum != null) {295 sess.setInt("seq", seqnum.intValue());296 }297 254 298 255 sess.setString("rid", rid); … … 314 271 } 315 272 316 /** Return a single event317 *318 * @param id int id of the event319 * @return EventVO value object representing event.320 * @throws CalFacadeException321 */322 273 public BwEvent getEvent(int id) throws CalFacadeException { 323 274 HibSession sess = getSess(); … … 335 286 } 336 287 337 /** Add an event to the database. 338 * 339 * @param val BwEvent object to be added 340 * @param overrides 341 * @throws CalFacadeException 342 */ 343 public void addEvent(BwEvent val, Collection overrides) throws CalFacadeException { 288 public void addEvent(BwEvent val, 289 Collection overrides) throws CalFacadeException { 344 290 RecuridTable recurids = null; 345 291 HibSession sess = getSess(); … … 361 307 * It also ensures our guid allocation is working OK 362 308 */ 363 sess.namedQuery("getGuidCount"); 309 sess.namedQuery("getGuidCountCalendar"); 310 sess.setEntity("cal", val.getCalendar()); 364 311 sess.setString("guid", val.getGuid()); 365 312 … … 461 408 } 462 409 463 /* Called when adding an event with overrides464 */465 private void addOverride(BwEventProxy proxy,466 BwRecurrenceInstance inst) throws CalFacadeException {467 BwEventAnnotation override = proxy.getRef();468 override.setOwner(user);469 470 getSess().saveOrUpdate(override);471 inst.setOverride(override);472 }473 474 /** Replace an event with the same id in the database.475 *476 * @param val EventVO object to be replaced477 * @throws CalFacadeException478 */479 410 public void updateEvent(BwEvent val) throws CalFacadeException { 480 411 HibSession sess = getSess(); … … 555 486 556 487 proxy.setRefChanged(false); 488 } 489 490 public DelEventResult deleteEvent(BwEvent val) throws CalFacadeException { 491 HibSession sess = getSess(); 492 DelEventResult der = new DelEventResult(false, 0); 493 494 der.alarmsDeleted = deleteAlarms(val); 495 496 StringBuffer sb = new StringBuffer(); 497 498 /* SEG: delete from recurrences recur where */ 499 sb.append("delete from "); 500 sb.append(BwRecurrenceInstance.class.getName()); 501 sb.append(" where master=:master"); 502 503 sess.createQuery(sb.toString()); 504 sess.setEntity("master", val); 505 sess.executeUpdate(); 506 507 /* XXX Cascades don't seem to do the job here - we have to explicitly delete the 508 annotations. 509 510 In any case, this won't work if we have a shared event and there are 511 annotations to the annotation. We need a field which identifies all 512 annotations related to the master i.e. not just a target field but a 513 master field. 514 */ 515 sb = new StringBuffer(); 516 517 sb.append("from "); 518 sb.append(BwEventAnnotation.class.getName()); 519 sb.append(" where target=:target"); 520 521 sess.createQuery(sb.toString()); 522 sess.setEntity("target", val); 523 524 Collection anns = sess.getList(); 525 Iterator it = anns.iterator(); 526 527 while (it.hasNext()) { 528 BwEventAnnotation ann = (BwEventAnnotation)it.next(); 529 530 ann.getAttendees().clear(); 531 532 sess.delete(ann); 533 } 534 535 sess.delete(val); 536 537 /* This event was really deleted so we need to set any synch states to 538 * indicate this is the case. 539 */ 540 cal.setSynchState(val, BwSynchState.DELETED); 541 542 der.eventDeleted = true; 543 544 return der; 545 } 546 547 public Collection getEvents(BwCalendar calendar, BwFilter filter, 548 BwDateTime startDate, BwDateTime endDate, 549 int recurRetrieval) 550 throws CalFacadeException { 551 HibSession sess = getSess(); 552 StringBuffer sb = new StringBuffer(); 553 554 if (debug) { 555 trace("getEvents for start=" + startDate + " end=" + endDate); 556 } 557 558 /* Name of the event in the query */ 559 final String qevName = "ev"; 560 561 Filters flt = new Filters(filter, sb, qevName, debug); 562 563 /* SEG: from Events ev where */ 564 sb.append("from "); 565 sb.append(BwEvent.class.getName()); 566 sb.append(" "); 567 sb.append(qevName); 568 sb.append(" where "); 569 570 /* SEG: (<date-ranges>) and */ 571 if (appendDateTerms(sb, qevName + ".dtstart.date", 572 qevName + ".dtend.date", 573 startDate, endDate)) { 574 sb.append(" and "); 575 } 576 577 /* Don't retrieve any master records - I guess we might have a choice 578 to retrieve any with the dates in the given range 579 */ 580 sb.append(qevName); 581 sb.append(".recurring = false and "); 582 583 /* SEG ( */ 584 sb.append(" ("); 585 586 boolean setUser = doCalendarClause(sb, qevName, calendar, 587 currentMode, ignoreCreator); 588 589 sb.append(") "); 590 591 flt.addWhereFilters(); 592 593 sb.append(" order by "); 594 sb.append(qevName); 595 sb.append(".dtstart.dtval"); 596 597 //if (debug) { 598 // trace(sb.toString()); 599 //} 600 601 sess.createQuery(sb.toString()); 602 603 /* XXX Limit result set size - pagination allows something like: 604 query.setFirstResult(0); 605 query.setMaxResults(10); 606 */ 607 608 if (startDate != null) { 609 sess.setString("fromDate", startDate.getDate()); 610 } 611 612 if (endDate != null) { 613 sess.setString("toDate", endDate.getDate()); 614 } 615 616 doCalendarEntities(setUser, calendar); 617 618 flt.parPass(sess); 619 620 if (debug) { 621 trace(sess.getQueryString()); 622 } 623 624 Collection es = sess.getList(); 625 626 if (debug) { 627 trace("Found " + es.size() + " events"); 628 } 629 630 es = postGetEvents(es, privRead, noAccessReturnsNull); 631 632 /** Run the events we got through the filters 633 */ 634 es = flt.postExec(es); 635 636 Collection rs = getLimitedRecurrences(calendar, filter, startDate, endDate, 637 currentMode, ignoreCreator, 638 recurRetrieval); 639 if (rs != null) { 640 es.addAll(rs); 641 } 642 643 return es; 644 } 645 646 public boolean editable(BwEvent val) throws CalFacadeException { 647 if (currentMode == CalintfUtil.guestMode) { 648 return false; 649 } 650 651 if (val.getPublick() != (currentMode == CalintfUtil.publicAdminMode)) { 652 return false; 653 } 654 655 return user.equals(val.getCreator()); 656 } 657 658 public Collection getEventsByName(BwCalendar cal, String val) 659 throws CalFacadeException { 660 HibSession sess = getSess(); 661 sess.namedQuery("eventsByName"); 662 sess.setString("name", val); 663 sess.setEntity("cal", cal); 664 665 Collection evs = sess.getList(); 666 667 return postGetEvents(evs, privRead, noAccessReturnsNull); 668 } 669 670 /* ==================================================================== 671 * Private methods 672 * ==================================================================== */ 673 674 /** Assign a guid to an event. A noop if this event already has a guid. 675 * 676 * @param val BwEvent object 677 * @throws CalFacadeException 678 */ 679 private void assignGuid(BwEvent val) throws CalFacadeException { 680 if (val == null) { 681 return; 682 } 683 684 String guidPrefix = "CAL-" + (String)getUuidGen().generate(null, null); 685 686 if (val.getName() == null) { 687 val.setName(guidPrefix + ".ics"); 688 } 689 690 if (val.getGuid() != null) { 691 return; 692 } 693 694 String guid = guidPrefix + cal.getSysid(); 695 696 val.setGuid(guid); 697 } 698 699 /* Called when adding an event with overrides 700 */ 701 private void addOverride(BwEventProxy proxy, 702 BwRecurrenceInstance inst) throws CalFacadeException { 703 BwEventAnnotation override = proxy.getRef(); 704 override.setOwner(user); 705 706 getSess().saveOrUpdate(override); 707 inst.setOverride(override); 557 708 } 558 709 … … 649 800 } 650 801 651 /** Delete an event 652 * 653 * @param val BwEvent object to be deleted 654 * @return DelEventResult result. 655 * @exception CalFacadeException If there's a database access problem 656 */ 657 public DelEventResult deleteEvent(BwEvent val) throws CalFacadeException { 658 HibSession sess = getSess(); 659 DelEventResult der = new DelEventResult(false, 0); 660 661 der.alarmsDeleted = deleteAlarms(val); 662 663 StringBuffer sb = new StringBuffer(); 664 665 /* SEG: delete from recurrences recur where */ 666 sb.append("delete from "); 667 sb.append(BwRecurrenceInstance.class.getName()); 668 sb.append(" where master=:master"); 669 670 sess.createQuery(sb.toString()); 671 sess.setEntity("master", val); 672 sess.executeUpdate(); 673 674 /* XXX Cascades don't seem to do the job here - we have to explicitly delete the 675 annotations. 676 677 In any case, this won't work if we have a shared event and there are 678 annotations to the annotation. We need a field which identifies all 679 annotations related to the master i.e. not just a target field but a 680 master field. 681 */ 682 sb = new StringBuffer(); 683 684 sb.append("from "); 685 sb.append(BwEventAnnotation.class.getName()); 686 sb.append(" where target=:target"); 687 688 sess.createQuery(sb.toString()); 689 sess.setEntity("target", val); 690 691 Collection anns = sess.getList(); 692 Iterator it = anns.iterator(); 693 694 while (it.hasNext()) { 695 BwEventAnnotation ann = (BwEventAnnotation)it.next(); 696 697 ann.getAttendees().clear(); 698 699 sess.delete(ann); 700 } 701 702 sess.delete(val); 703 704 /* This event was really deleted so we need to set any synch states to 705 * indicate this is the case. 706 */ 707 cal.setSynchState(val, BwSynchState.DELETED); 708 709 der.eventDeleted = true; 710 711 return der; 712 } 713 714 /** Assign a guid to an event. A noop if this event already has a guid. 715 * 716 * @param val EventVO object 717 * @throws CalFacadeException 718 */ 719 public void assignGuid(BwEvent val) throws CalFacadeException { 720 if (val == null) { 721 return; 722 } 723 724 String guidPrefix = "CAL-" + (String)getUuidGen().generate(null, null); 725 726 if (val.getName() == null) { 727 val.setName(guidPrefix + ".ics"); 728 } 729 730 if (val.getGuid() != null) { 731 return; 732 } 733 734 String guid = guidPrefix + cal.getSysid(); 735 736 val.setGuid(guid); 737 } 738 739 /** Return the events within the given date range. If this is not a public 740 * admin view we apply any filters. 741 * 742 * <p>This should really be a UNION query but hibernate doesn't currently 743 * support these. However, most queries are for a single days events, 744 * repeated to obtain a week or month, and returns a small number of objects. 745 * 746 * <p>Appropriately enabled caching should reduce db interactions to an 747 * acceptable level. 748 * 749 * <p>We try to build something like the following: 750 * 751 * from EventVO where 752 * [ ( <in-date-range> ) and ] if date(s) given 753 * 754 * one of: 755 * A: for personal 756 * ( ( public = false and creator = user) or 757 * [ and <not-in-blocked-events> ] 758 * 759 * B: for guest 760 * ( public = true ) 761 * 762 * C: for public admin 763 * ( public = true and creator = user) 764 * 765 * followed by 766 * [ and <filter-expr> ] 767 * 768 * <filter-expr> 769 * 1. Not null but inexpressable - post process 770 * 771 * 2. Not null but (partially) expressible 772 * Add sql but possibly post-process 773 * e.g. A and B and C 774 * if any of A, B, C are expressible add to query 775 * 776 * 3. null - add nothing 777 * 778 * <p>All parameters may be null implying all events for this object. 779 * Start or end or both may be null.<ul> 780 * <li>startDate=null,endDate=null means all</li> 781 * <li>startDate=null means all less than endDate</li> 782 * <li>endDate=null means all including and after startDate</li> 783 * 784 * @param calendar BwCalendar object restricting search or null. 785 * @param filter BwFilter object restricting search or null. 786 * @param startDate DateTimeVO start - may be null 787 * @param endDate DateTimeVO end - may be null. 788 * @param recurRetrieval Takes value defined in.CalFacadeDefs 789 * @param currentMode 790 * @param ignoreCreator 791 * @return Collection populated event value objects 792 * @throws CalFacadeException 793 */ 794 public Collection getEvents(BwCalendar calendar, BwFilter filter, 795 BwDateTime startDate, BwDateTime endDate, 796 int recurRetrieval, 797 int currentMode, boolean ignoreCreator) 798 throws CalFacadeException { 799 HibSession sess = getSess(); 800 StringBuffer sb = new StringBuffer(); 801 802 if (debug) { 803 trace("getEvents for start=" + startDate + " end=" + endDate); 804 } 805 806 /* Name of the event in the query */ 807 final String qevName = "ev"; 808 809 Filters flt = new Filters(filter, sb, qevName, debug); 810 811 /* SEG: from Events ev where */ 812 sb.append("from "); 813 sb.append(BwEvent.class.getName()); 814 sb.append(" "); 815 sb.append(qevName); 816 sb.append(" where "); 817 818 /* SEG: (<date-ranges>) and */ 819 if (appendDateTerms(sb, qevName + ".dtstart.date", 820 qevName + ".dtend.date", 821 startDate, endDate)) { 822 sb.append(" and "); 823 } 824 825 /* Don't retrieve any master records - I guess we might have a choice 826 to retrieve any with the dates in the given range 827 */ 828 sb.append(qevName); 829 sb.append(".recurring = false and "); 830 831 /* SEG ( */ 832 sb.append(" ("); 833 834 boolean setUser = doCalendarClause(sb, qevName, calendar, 835 currentMode, ignoreCreator); 836 837 sb.append(") "); 838 839 flt.addWhereFilters(); 840 841 sb.append(" order by "); 842 sb.append(qevName); 843 sb.append(".dtstart.dtval"); 844 845 //if (debug) { 846 // trace(sb.toString()); 847 //} 848 849 sess.createQuery(sb.toString()); 850 851 /* XXX Limit result set size - pagination allows something like: 852 query.setFirstResult(0); 853 query.setMaxResults(10); 854 */ 855 856 if (startDate != null) { 857 sess.setString("fromDate", startDate.getDate()); 858 } 859 860 if (endDate != null) { 861 sess.setString("toDate", endDate.getDate()); 862 } 863 864 doCalendarEntities(setUser, calendar); 865 866 flt.parPass(sess); 867 868 if (debug) { 869 trace(sess.getQueryString()); 870 } 871 872 Collection es = sess.getList(); 873 874 if (debug) { 875 trace("Found " + es.size() + " events"); 876 } 877 878 es = postGetEvents(es, privRead, noAccessReturnsNull); 879 880 /** Run the events we got through the filters 881 */ 882 es = flt.postExec(es); 883 884 Collection rs = getLimitedRecurrences(calendar, filter, startDate, endDate, 885 currentMode, ignoreCreator, 886 recurRetrieval); 887 if (rs != null) { 888 es.addAll(rs); 889 } 890 891 return es; 892 } 893 894 /** Get events given the calendar and String name. Return null for not 895 * found. For non-recurring there should be only one event. Otherwise we 896 * return the master event and overrides. 897 * 898 * @param cal BwCalendar object 899 * @param val String possible name 900 * @return Collection of BwEvent or null 901 * @throws CalFacadeException 902 */ 903 public Collection getEventsByName(BwCalendar cal, String val) 904 throws CalFacadeException { 905 HibSession sess = getSess(); 906 sess.namedQuery("eventsByName"); 907 sess.setString("name", val); 908 sess.setEntity("cal", cal); 909 910 Collection evs = sess.getList(); 911 912 return postGetEvents(evs, privRead, noAccessReturnsNull); 913 } 914 915 /* ==================================================================== 916 * Private methods 917 * ==================================================================== */ 918 919 private void eventQuery(Class cl, String guid, String rid, Integer seqnum, 802 private void eventQuery(Class cl, BwCalendar calendar, String guid, String rid, 920 803 boolean masterOnly) throws CalFacadeException { 921 804 HibSession sess = getSess(); … … 926 809 sb.append(cl.getName()); 927 810 sb.append(" ev "); 928 sb.append(" where ev.guid=:guid "); 929 930 if (seqnum != null) { 931 sb.append(" and ev.sequence=:seq "); 932 } 811 sb.append(" where ev.calendar=:cal "); 812 sb.append(" and ev.guid=:guid "); 933 813 934 814 if (masterOnly) { … … 940 820 sess.createQuery(sb.toString()); 941 821 822 sess.setEntity("cal", calendar); 942 823 sess.setString("guid", guid); 943 944 if (seqnum != null) {945 sess.setInt("seq", seqnum.intValue());946 }947 824 948 825 if (! masterOnly && (rid != null)) { trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
r191 r207 694 694 } 695 695 696 public Collection getEvent(String guid, String rid, 697 Integer seqnum, 696 public Collection getEvent(BwCalendar calendar, String guid, String rid, 698 697 int recurRetrieval) throws CalFacadeException { 699 698 checkOpen(); trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Calintf.java
r191 r207 55 55 56 56 import org.bedework.calfacade.BwAlarm; 57 import org.bedework.calfacade.BwCalendar;58 57 import org.bedework.calfacade.BwCategory; 59 import org.bedework.calfacade.BwDateTime;60 58 import org.bedework.calfacade.BwEvent; 61 59 import org.bedework.calfacade.BwLocation; … … 91 89 * @author Mike Douglass douglm@rpi.edu 92 90 */ 93 public interface Calintf extends CalendarsI {91 public interface Calintf extends CalendarsI, EventsI { 94 92 /** Must be called to initialise the new object. 95 93 * … … 677 675 */ 678 676 public Collection getSponsorRefs(BwSponsor val) throws CalFacadeException; 679 680 /* ====================================================================681 * Events682 * ==================================================================== */683 684 /** Return a single event for the current user685 *686 * @param eventId int id of the event687 * @return EventVO value object representing event.688 * @throws CalFacadeException689 */690 public BwEvent getEvent(int eventId) throws CalFacadeException;691 692 /** Return one or more events using the guid and optionally a sequence number693 * and recurrence-id as a key.694 *695 * <p>For non-recurring events, one and only one event should be returned696 * for any given guid.697 *698 * <p>For recurring events, the guid defines the 'master' event defining699 * the rules together with any exceptions.700 *701 * <p>The sequence number and the recurrence id define a particular instance702 * of a recurrence.703 *704 * <p>To specify the master entry provide a null recurrenceId or use the705 * recurRetrieval parameter.706 *707 * @param guid String guid for the event708 * @param rid String recurrence id, null for non-recurring, null valued for709 * master or non-null-valued for particular occurrence.710 * @param seqnum Integer sequence nbr711 * @param recurRetrieval Takes value defined in CalFacadeDefs.712 * @return Collection of EventInfo objects representing event(s).713 * @throws CalFacadeException714 */715 public Collection getEvent(String guid, String rid,716 Integer seqnum,717 int recurRetrieval) throws CalFacadeException;718 719 /** Return the events for the current user within the given date/time720 * range.721 *722 * @param calendar BwCalendar object restricting search or null.723 * @param filter BwFilter object restricting search or null.724 * @param startDate DateTimeVO start - may be null725 * @param endDate DateTimeVO end - may be null.726 * @param recurRetrieval Takes value defined in CalFacadeDefs727 * @return Collection populated event value objects728 * @throws CalFacadeException729 */730 public Collection getEvents(BwCalendar calendar, BwFilter filter,731 BwDateTime startDate, BwDateTime endDate,732 int recurRetrieval)733 throws CalFacadeException;734 735 /** Add an event to the database. The id and uid will be set in the parameter736 * object.737 *738 * @param val EventVO object to be added739 * @param overrides Collection of BwEventProxy objects which override instances740 * of the new event741 * @throws CalFacadeException742 */743 public void addEvent(BwEvent val,744 Collection overrides) throws CalFacadeException;745 746 /** Update an event in the database.747 *748 * <p>This method will set any synchronization state entries to modified749 * unless we are synchronizing in which case that belonging to the current750 * user is set to mark the event as synchronized751 *752 * @param val EventVO object to be replaced753 * @exception CalFacadeException If there's a db problem or problem with754 * the event755 * @throws CalFacadeException756 */757 public void updateEvent(BwEvent val) throws CalFacadeException;758 759 /** This class allows the implementations to pass back some information760 * about what happened. If possible it should fill in the supplied fields.761 *762 * A result of zero for counts does not necessarily indicate nothing763 * happened, for example, the implementation may store elarms as part of764 * the event object and they just go as part of event deletion.765 */766 public static class DelEventResult {767 /** false if it didn't exist768 */769 public boolean eventDeleted;770 771 /** Number of alarms deleted772 */773 public int alarmsDeleted;774 775 /** Constructor776 *777 * @param eventDeleted778 * @param alarmsDeleted779 */780 public DelEventResult(boolean eventDeleted,781 int alarmsDeleted) {782 this.eventDeleted = eventDeleted;783 this.alarmsDeleted = alarmsDeleted;784 }785 }786 787 /** Delete an event and any associated alarms788 * Set any referring synch states to deleted.789 *790 * @param val EventVO object to be deleted791 * @return DelEventResult result.792 * @exception CalFacadeException If there's a database access problem793 */794 public DelEventResult deleteEvent(BwEvent val) throws CalFacadeException;795 796 /* * Assign a guid to an event which must exist in the db. A noop if this797 * event already has a guid.798 *799 * @param val EventVO object800 * /801 public void assignGuid(BwEvent val) throws CalFacadeException;*/802 803 /** Return true if this event is editable by the current user804 *805 * @param val EventVO object to be tested806 * @return boolean807 * @throws CalFacadeException808 */809 public boolean editable(BwEvent val) throws CalFacadeException;810 811 /* ====================================================================812 * Caldav support813 * Caldav as it stands at the moment requires that we save the arbitary814 * names clients might assign to events.815 * ==================================================================== */816 817 /** Get events given the calendar and String name. Return null for not818 * found. For non-recurring there should be only one event. Otherwise we819 * return the currently expanded set of recurring events.820 *821 * @param cal CalendarVO object822 * @param val String possible name823 * @return Collection of EventVO or null824 * @throws CalFacadeException825 */826 public Collection getEventsByName(BwCalendar cal, String val)827 throws CalFacadeException;828 677 829 678 /* ==================================================================== trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java
r47 r207 268 268 public void delete(WebdavNsNode node) throws WebdavIntfException { 269 269 try { 270 CaldavBwNode uwnode = get Uwnode(node);270 CaldavBwNode uwnode = getBwnode(node); 271 271 272 272 if (!(uwnode instanceof CaldavComponentNode)) { … … 298 298 throws WebdavIntfException { 299 299 try { 300 CaldavBwNode uwnode = get Uwnode(node);300 CaldavBwNode uwnode = getBwnode(node); 301 301 302 302 Vector v = new Vector(); … … 379 379 throws WebdavIntfException { 380 380 try { 381 CaldavBwNode uwnode = get Uwnode(node);381 CaldavBwNode uwnode = getBwnode(node); 382 382 383 383 return WebdavProperty.getEnumeration(uwnode.getProperties(namespace)); … … 403 403 } 404 404 405 CaldavBwNode uwnode = get Uwnode(node);405 CaldavBwNode uwnode = getBwnode(node); 406 406 407 407 return uwnode.getContent(); … … 501 501 pcr.created = create; 502 502 503 CaldavBwNode uwnode = getUwnode(node);504 CaldavURI cdUri = uwnode.getCDURI();503 CaldavBwNode bwnode = getBwnode(node); 504 CaldavURI cdUri = bwnode.getCDURI(); 505 505 String entityName = cdUri.getEntityName(); 506 507 Collection c = trans.fromIcal(new MyReader(contentRdr)); 506 BwCalendar cal = cdUri.getCal(); 507 508 Collection c = trans.fromIcal(cal, new MyReader(contentRdr)); 508 509 509 510 /** if more than one event these must all be instances of the same recurrence, i.e the … … 546 547 pcr.created = true; 547 548 ev.setName(entityName); 548 ev.setCalendar(cdUri.getCal()); 549 svci.addEvent(ev, evinfo.getOverrides()); 549 svci.addEvent(cal, ev, evinfo.getOverrides()); 550 550 551 551 StringBuffer sb = new StringBuffer(cdUri.getPath()); … … 634 634 public void makeCollection(HttpServletRequest req, WebdavNsNode node) throws WebdavIntfException { 635 635 try { 636 CaldavBwNode uwnode = get Uwnode(node);636 CaldavBwNode uwnode = getBwnode(node); 637 637 CaldavURI cdUri = uwnode.getCDURI(); 638 638 … … 822 822 823 823 public void emitAcl(WebdavNsNode node) throws WebdavIntfException { 824 CaldavBwNode uwnode = get Uwnode(node);824 CaldavBwNode uwnode = getBwnode(node); 825 825 CaldavURI cdUri = uwnode.getCDURI(); 826 826 Collection aces = null; … … 987 987 public void generatePropResourcetype(WebdavNsNode node) 988 988 throws WebdavIntfException { 989 CaldavBwNode uwnode = get Uwnode(node);989 CaldavBwNode uwnode = getBwnode(node); 990 990 991 991 if (debug) { … … 1031 1031 public Collection query(WebdavNsNode wdnode, int retrieveRecur, 1032 1032 Filter fltr) throws WebdavIntfException { 1033 CaldavBwNode node = get Uwnode(wdnode);1033 CaldavBwNode node = getBwnode(wdnode); 1034 1034 CalSvcI svci = getSvci(); 1035 1035 Collection events; … … 1104 1104 FreeBusyQuery freeBusy) throws WebdavIntfException { 1105 1105 try { 1106 CaldavBwNode uwnode = get Uwnode(wdnode);1106 CaldavBwNode uwnode = getBwnode(wdnode); 1107 1107 if (!(uwnode instanceof CaldavCalNode)) { 1108 1108 throw WebdavIntfException.badRequest(); … … 1437 1437 } 1438 1438 1439 private CaldavBwNode get Uwnode(WebdavNsNode node)1439 private CaldavBwNode getBwnode(WebdavNsNode node) 1440 1440 throws WebdavIntfException { 1441 1441 if (!(node instanceof CaldavBwNode)) { trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r200 r207 1439 1439 } 1440 1440 1441 public Collection getEvent(String guid, String recurrenceId, 1441 public Collection getEvent(BwSubscription sub, BwCalendar cal, 1442 String guid, String recurrenceId, 1442 1443 int recurRetrieval) throws CalFacadeException { 1443 return postProcess(getCal().getEvent( guid, recurrenceId, null, recurRetrieval),1444 (BwSubscription)null);1444 return postProcess(getCal().getEvent(cal, guid, recurrenceId, recurRetrieval), 1445 sub); 1445 1446 } 1446 1447 … … 1522 1523 sub = (BwSubscription)it.next(); 1523 1524 1524 if (sub.getInternalSubscription() && !sub.getCalendarDeleted()) { 1525 BwCalendar calendar = sub.getCalendar(); 1526 1527 if (calendar == null) { 1528 String path; 1529 String uri = sub.getUri(); 1530 1531 if (uri.startsWith(CalFacadeDefs.bwUriPrefix)) { 1532 path = uri.substring(CalFacadeDefs.bwUriPrefix.length()); 1533 } else { 1534 // Shouldn't happen? 1535 path = uri; 1536 } 1537 1538 if (debug) { 1539 trace("Search for calendar \"" + path + "\""); 1540 } 1541 1542 calendar = getCal().getCalendar(path); 1543 if (calendar == null) { 1544 // Assume deleted 1545 sub.setCalendarDeleted(true); 1546 updateSubscription(sub); 1547 } else { 1548 sub.setCalendar(calendar); 1549 } 1550 } 1551 1552 if (calendar != null) { 1553 internal.addChild(calendar); 1554 putSublookup(sublookup, sub, calendar); 1555 } 1525 BwCalendar calendar = getSubCalendar(sub); 1526 1527 if (calendar != null) { 1528 internal.addChild(calendar); 1529 putSublookup(sublookup, sub, calendar); 1556 1530 } 1557 1531 } … … 1563 1537 1564 1538 return ts; 1539 } 1540 1541 private BwCalendar getSubCalendar(BwSubscription sub) throws CalFacadeException { 1542 if (!sub.getInternalSubscription() || sub.getCalendarDeleted()) { 1543 return null; 1544 } 1545 1546 BwCalendar calendar = sub.getCalendar(); 1547 1548 if (calendar != null) { 1549 return calendar; 1550 } 1551 1552 String path; 1553 String uri = sub.getUri(); 1554 1555 if (uri.startsWith(CalFacadeDefs.bwUriPrefix)) { 1556 path = uri.substring(CalFacadeDefs.bwUriPrefix.length()); 1557 } else { 1558 // Shouldn't happen? 1559 path = uri; 1560 } 1561 1562 if (debug) { 1563 trace("Search for calendar \"" + path + "\""); 1564 } 1565 1566 calendar = getCal().getCalendar(path); 1567 if (calendar == null) { 1568 // Assume deleted 1569 sub.setCalendarDeleted(true); 1570 updateSubscription(sub); 1571 } else { 1572 sub.setCalendar(calendar); 1573 } 1574 1575 return calendar; 1565 1576 } 1566 1577 … … 1608 1619 } 1609 1620 1610 public EventUpdateResult addEvent(BwEvent event, 1621 public EventUpdateResult addEvent(BwCalendar cal, 1622 BwEvent event, 1611 1623 Collection overrides) throws CalFacadeException { 1612 1624 EventUpdateResult updResult = new EventUpdateResult(); … … 1631 1643 } 1632 1644 1633 /* If no calendar has been assigned tothis event set it to the default1645 /* If no calendar has been assigned for this event set it to the default 1634 1646 * calendar for non-public events or reject it for public events. 1635 1647 */ 1636 1648 1637 if ( event.getCalendar()== null) {1649 if (cal == null) { 1638 1650 if (event.getPublick()) { 1639 1651 throw new CalFacadeException("No calendar assigned"); 1640 1652 } 1641 1653 1642 event.setCalendar(getPreferences().getDefaultCalendar());1643 } 1644 1645 if (! event.getCalendar().getCalendarCollection()) {1654 cal = getPreferences().getDefaultCalendar(); 1655 } 1656 1657 if (!cal.getCalendarCollection()) { 1646 1658 throw new CalFacadeAccessException(); 1647 1659 } 1660 1661 event.setCalendar(cal); 1648 1662 1649 1663 event.setDtstamp(new DtStamp(new DateTime(true)).getValue()); … … 2144 2158 } 2145 2159 2146 public Collection getEvent(String guid, String rid, 2147 Integer seq, 2160 public Collection getEvent(BwCalendar cal, String guid, String rid, 2148 2161 int recurRetrieval) throws CalFacadeException { 2149 return CalSvc.this.getEvent(guid, rid, recurRetrieval); 2162 return CalSvc.this.getEvent(BwSubscription.makeSubscription(cal), cal, guid, 2163 rid, recurRetrieval); 2150 2164 } 2151 2165 trunk/calendar3/calsvci/src/org/bedework/calsvci/CalSvcI.java
r191 r207 1071 1071 public abstract EventInfo getEvent(int eventId) throws CalFacadeException; 1072 1072 1073 /** Return one or more events for the current user using the guid as a key. 1073 /** Return one or more events for the current user using the calendar, guid 1074 * and the recurrence id as a key. 1074 1075 * 1075 1076 * <p>For non-recurring events, one and only one event should be reurned. … … 1077 1078 * with any exceptions should be returned. 1078 1079 * 1080 * @param sub BwSubscription object 1081 * @param cal BwCalendar object 1079 1082 * @param guid String guid for the event 1080 1083 * @param recurrenceId String recurrence id or null … … 1083 1086 * @throws CalFacadeException 1084 1087 */ 1085 public abstract Collection getEvent(String guid, String recurrenceId, 1088 public abstract Collection getEvent(BwSubscription sub, BwCalendar cal, 1089 String guid, 1090 String recurrenceId, 1086 1091 int recurRetrieval) 1087 1092 throws CalFacadeException; … … 1190 1195 * will come from the target. 1191 1196 * 1197 * @param cal BwCalendar defining recipient calendar 1192 1198 * @param event BwEvent object to be added 1193 1199 * @param overrides Collection of BwEventProxy objects which override instances … … 1196 1202 * @throws CalFacadeException 1197 1203 */ 1198 public abstract EventUpdateResult addEvent(BwEvent event, 1204 public abstract EventUpdateResult addEvent(BwCalendar cal, 1205 BwEvent event, 1199 1206 Collection overrides) throws CalFacadeException; 1200 1207 trunk/calendar3/deployment/webpublic/webapp/resources/demoskins/default/default/default.xsl
r204 r207 534 534 <xsl:variable name="id" select="id"/> 535 535 <xsl:variable name="subscriptionId" select="subscription/id"/> 536 <xsl:variable name="calendarId" select="calendar/id"/> 536 537 <xsl:variable name="guid" select="guid"/> 537 538 <xsl:variable name="recurrenceId" select="recurrenceId"/> 538 <a href="{$privateCal}/addEventRef.do? eventId={$id}" title="Add event to MyCalendar" target="myCalendar">539 <a href="{$privateCal}/addEventRef.do?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}" title="Add event to MyCalendar" target="myCalendar"> 539 540 <img class="addref" src="{$resourcesRoot}/images/add2mycal-icon.gif" width="20" height="26" border="0" alt="Add event to MyCalendar"/> 540 541 </a> 541 542 <xsl:variable name="eventIcalName" select="concat($id,'.ics')"/> 542 <a href="{$export}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}&nocache=no&skinName=ical&contentType=text/calendar&contentName={$eventIcalName}" title="Download event as ical - for Outlook, PDAs, iCal, and other desktop calendars">543 <a href="{$export}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}&nocache=no&skinName=ical&contentType=text/calendar&contentName={$eventIcalName}" title="Download event as ical - for Outlook, PDAs, iCal, and other desktop calendars"> 543 544 <img src="{$resourcesRoot}/images/std-ical_icon.gif" width="20" height="26" border="0" alt="Download this event"/> 544 545 </a> … … 670 671 <xsl:variable name="id" select="id"/> 671 672 <xsl:variable name="subscriptionId" select="subscription/id"/> 673 <xsl:variable name="calendarId" select="calendar/id"/> 672 674 <xsl:variable name="guid" select="guid"/> 673 675 <xsl:variable name="recurrenceId" select="recurrenceId"/> … … 696 698 <xsl:otherwise> 697 699 <td class="{$dateRangeStyle} right"> 698 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}">700 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}"> 699 701 <xsl:choose> 700 702 <xsl:when test="start/allday = 'true' and … … 713 715 </td> 714 716 <td class="{$dateRangeStyle} center"> 715 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}">-</a>717 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}">-</a> 716 718 </td> 717 719 <td class="{$dateRangeStyle} left"> 718 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}">720 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}"> 719 721 <xsl:choose> 720 722 <xsl:when test="end/allday = 'true' and … … 743 745 <xsl:choose> 744 746 <xsl:when test="/bedework/appvar[key='summaryMode']/value='details'"> 745 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}">747 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}"> 746 748 <strong><xsl:value-of select="summary"/>: </strong> 747 749 <xsl:value-of select="description"/>  … … 765 767 </xsl:when> 766 768 <xsl:otherwise> 767 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}">769 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}"> 768 770 <xsl:value-of select="summary"/>, <xsl:value-of select="location/address"/> 769 771 </a> … … 773 775 <td class="icons"> 774 776 <variable name="confId" select="/bedework/confirmationid"/> 775 <a href="{$privateCal}/addEventRef.do? eventId={$id}" title="Add event to MyCalendar" target="myCalendar">777 <a href="{$privateCal}/addEventRef.do?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}" title="Add event to MyCalendar" target="myCalendar"> 776 778 <img class="addref" src="{$resourcesRoot}/images/add2mycal-icon-small.gif" width="12" height="16" border="0" alt="Add event to MyCalendar"/> 777 779 </a> 778 780 <xsl:variable name="eventIcalName" select="concat($id,'.ics')"/> 779 <a href="{$export}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}&nocache=no&skinName=ical&contentType=text/calendar&contentName={$eventIcalName}" title="Download event as ical - for Outlook, PDAs, iCal, and other desktop calendars">781 <a href="{$export}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}&nocache=no&skinName=ical&contentType=text/calendar&contentName={$eventIcalName}" title="Download event as ical - for Outlook, PDAs, iCal, and other desktop calendars"> 780 782 <img src="{$resourcesRoot}/images/std-ical_icon_small.gif" width="12" height="16" border="0" alt="Download event as ical - for Outlook, PDAs, iCal, and other desktop calendars"/> 781 783 </a> … … 857 859 <xsl:param name="dayPos"/> 858 860 <xsl:variable name="subscriptionId" select="subscription/id"/> 861 <xsl:variable name="calendarId" select="calendar/id"/> 859 862 <xsl:variable name="guid" select="guid"/> 860 863 <xsl:variable name="recurrenceId" select="recurrenceId"/> … … 870 873 </xsl:variable> 871 874 <li> 872 <a href="{$eventView}?subid={$subscriptionId}& guid={$guid}&recurrenceId={$recurrenceId}" class="{$eventClass}">875 <a href="{$eventView}?subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId}" class="{$eventClass}"> 873 876 <xsl:value-of select="summary"/> 874 877 <xsl:variable name="eventTipClass"> trunk/calendar3/docs/todo.txt
r176 r207 1 1 Todo 2 2 3 -------------------------------------------------------------------------------- 4 Remove references to getEvent(id) 5 -------------------------------------------------------------------------------- 6 Changes caused by use of calendar id. 7 The last round of changes were caused by the need to make the guid unique only 8 within the context of a calendar collection. This requires that the calendar 9 id be part of the event key. 10 11 All of the url for fetching single events need to change. There are about 8 of 12 them in the public default stylesheet. 13 14 The changes were relatively simple: 15 Change all occurrences of 16 subid={$subscriptionId}& 17 to 18 subid={$subscriptionId}&calid={$calendarId}& 19 In 2-3 places you need to define calendarId. Look for occurences of 20 <xsl:variable name="subscriptionId" select="subscription/id"/> 21 and immediately following add 22 <xsl:variable name="calendarId" select="calendar/id"/> 23 24 A further change is to look for the addEventRef.do url and change the text 25 eventId={$id} 26 to 27 subid={$subscriptionId}&calid={$calendarId}&guid={$guid}&recurrenceId={$recurrenceId} 28 that is, make it the same form as the others. (I found 2 of these) 29 30 These changes will also be required in the user client stylesheet. 3 31 -------------------------------------------------------------------------------- 4 32 Lost the exrules from the recurrence info hbm - add them trunk/calendar3/icalendar/src/org/bedework/icalendar/BwEventUtil.java
r2 r207 55 55 package org.bedework.icalendar; 56 56 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwCategory; 58 59 import org.bedework.calfacade.BwDateTime; … … 132 133 * 133 134 * @param cb IcalCallback object 135 * @param cal 134 136 * @param evs Events we already converted - used to check for overrides. 135 137 * @param val VEvent object … … 139 141 */ 140 142 public static EventInfo toEvent(IcalCallback cb, 143 BwCalendar cal, 141 144 Collection evs, 142 145 VEvent val, … … 232 235 * expansions etc. 233 236 */ 234 Collection eis = cb.getEvent( guid, rid, null,237 Collection eis = cb.getEvent(cal, guid, rid, 235 238 CalFacadeDefs.retrieveRecurMaster); 236 239 if ((eis == null) || (eis.size() == 0)) { trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalCallback.java
r50 r207 55 55 package org.bedework.icalendar; 56 56 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwCategory; 58 59 import org.bedework.calfacade.BwLocation; … … 109 110 * event with overrides. 110 111 * 112 * @param cal calendar to search 111 113 * @param guid 112 114 * @param rid 113 * @param seqnum114 115 * @param recurRetrieval Takes value defined in CalFacadeDefs. 115 116 * @return Collection of EventInfo 116 117 * @throws CalFacadeException 117 118 */ 118 public Collection getEvent(String guid, String rid, 119 Integer seqnum, 119 public Collection getEvent(BwCalendar cal, String guid, String rid, 120 120 int recurRetrieval) throws CalFacadeException; 121 121 trunk/calendar3/icalendar/src/org/bedework/icalendar/IcalTranslator.java
r170 r207 55 55 package org.bedework.icalendar; 56 56 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwEvent; 58 59 import org.bedework.calfacade.BwUser; … … 263 264 * a collection of events which may be empty. 264 265 * 266 * @param cal calendar 265 267 * @param val 266 268 * @return Collection 267 269 * @throws CalFacadeException 268 270 */ 269 public Collection fromIcal( String val) throws CalFacadeException {271 public Collection fromIcal(BwCalendar cal, String val) throws CalFacadeException { 270 272 try { 271 273 CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 272 274 273 return fromIcal( bldr.build(new UnfoldingReader(new StringReader(val))));275 return fromIcal(cal, bldr.build(new UnfoldingReader(new StringReader(val)))); 274 276 } catch (ParserException pe) { 275 277 if (debug) { … … 286 288 /** Convert the Icalendar reader to a Collection of Calendar objects 287 289 * 290 * @param cal calendar 288 291 * @param rdr 289 292 * @return Collection 290 293 * @throws CalFacadeException 291 294 */ 292 public Collection fromIcal( Reader rdr) throws CalFacadeException {295 public Collection fromIcal(BwCalendar cal, Reader rdr) throws CalFacadeException { 293 296 try { 294 297 System.setProperty("ical4j.unfolding.relaxed", "true"); 295 298 CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); 296 299 297 return fromIcal( bldr.build(new UnfoldingReader(rdr)));300 return fromIcal(cal, bldr.build(new UnfoldingReader(rdr))); 298 301 } catch (ParserException pe) { 299 302 if (debug) { … … 310 313 /** Convert the Calendar to a Collection of calendar objects. 311 314 * 315 * @param cal calendar 312 316 * @param val 313 317 * @return Collection 314 318 * @throws CalFacadeException 315 319 */ 316 public Collection fromIcal( Calendar val) throws CalFacadeException {320 public Collection fromIcal(BwCalendar cal, Calendar val) throws CalFacadeException { 317 321 Vector objs = new Vector(); 318 322 … … 329 333 330 334 if (o instanceof VEvent) { 331 EventInfo ev = BwEventUtil.toEvent(cb, objs, (VEvent)o, debug);335 EventInfo ev = BwEventUtil.toEvent(cb, cal, objs, (VEvent)o, debug); 332 336 333 337 if (ev != null) { trunk/calendar3/synchml/src/edu/rpi/cct/uwcal/synchml/common/Synchml.java
r2 r207 256 256 */ 257 257 public boolean updateEvent(VEvent val) throws CalFacadeException { 258 updateEvent(BwEventUtil.toEvent(svci.getIcalCallback(), null, val, debug).getEvent()); 258 // FIXME - We need a subscription to the calendar we are synching - second par 259 updateEvent(BwEventUtil.toEvent(svci.getIcalCallback(), null, null, val, debug).getEvent()); 259 260 260 261 return true; … … 269 270 */ 270 271 public boolean deleteEvent(VEvent val) throws CalFacadeException { 271 return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(), null, val, debug).getEvent()); 272 // FIXME - We need a subscription to the calendar we are synching - second par 273 return deleteEvent(BwEventUtil.toEvent(svci.getIcalCallback(), null, null, val, debug).getEvent()); 272 274 } 273 275 … … 353 355 354 356 String evData = synchData.getEventData(); 355 Collection c = trans.fromIcal(evData); 357 // FIXME - We need a subscription to the calendar we are synching - second par 358 Collection c = trans.fromIcal(null, evData); 356 359 if (c.size() != 1) { 357 360 throw new CalFacadeException("Invalid event data: " + evData); … … 438 441 */ 439 442 public boolean addEvent(BwEvent val) throws CalFacadeException { 440 svci.addEvent(val, null); 443 // FIXME - We need a subscription to the calendar we are synching - first par 444 svci.addEvent(null, val, null); 441 445 442 446 return true; … … 479 483 */ 480 484 public BwEvent findEvent(String val) throws CalFacadeException { 481 Collection eis = svci.getEvent(val, null, CalFacadeDefs.retrieveRecurMaster); 485 // FIXME - We need a subscription (first par) to the calendar (second par) 486 Collection eis = svci.getEvent(null, null, val, null, CalFacadeDefs.retrieveRecurMaster); 482 487 if ((eis == null) || (eis.size() == 0)) { 483 488 return null; … … 520 525 ev.setSummary("Temp"); 521 526 522 svci.addEvent(ev, null); 527 // FIXME - We need a subscription to the calendar we are synching - first par 528 svci.addEvent(null, ev, null); 523 529 524 530 return ev.getGuid(); trunk/calendar3/test/src/org/bedework/tests/calsvc/CalSvcTestUtil.java
r2 r207 505 505 } 506 506 507 // if (calendar == null) { 508 ev.setCalendar(svci.getCalendar()); 509 // } 510 511 svci.addEvent(ev, null); 507 svci.addEvent(svci.getCalendar(), ev, null); 512 508 log("Created event, id=" + ev.getId()); 513 509 return ev.getId(); trunk/calendar3/test/src/org/bedework/tests/calsvc/CalSvcTestWrapper.java
r2 r207 357 357 } 358 358 359 addEvent( ev, null);359 addEvent(null, ev, null); 360 360 361 361 return ev.getId(); trunk/calendar3/test/src/org/bedework/tests/ical/IcalTranslatorTest.java
r2 r207 55 55 package org.bedework.tests.ical; 56 56 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwEvent; 58 59 import org.bedework.calfacade.BwLocation; … … 207 208 System.out.println("==========================================="); 208 209 209 Collection c = makeEvents(icalTrans, icalText); 210 BwCalendar cal = svciUtil.getSvci(privateUser1).getCalendar(); 211 Collection c = makeEvents(icalTrans, cal, icalText); 210 212 Iterator it = c.iterator(); 211 213 … … 225 227 * ==================================================================== */ 226 228 227 /* *Get a Collection of EventInfo229 /* Get a Collection of EventInfo 228 230 * 229 231 * @param icalTrans 232 * @param cal 230 233 * @param calText 231 234 * @return Collection … … 233 236 */ 234 237 private Collection makeEvents(IcalTranslator icalTrans, 238 BwCalendar cal, 235 239 String[] calText) throws Throwable { 236 240 StringBuffer sb = new StringBuffer(); … … 243 247 svciUtil.open(privateUser1); 244 248 try { 245 return icalTrans.fromIcal( sb.toString());249 return icalTrans.fromIcal(cal, sb.toString()); 246 250 } finally { 247 251 svciUtil.close(privateUser1); trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java
r128 r207 160 160 161 161 if (form.getAddingEvent()) { 162 svci.addEvent(event , null);162 svci.addEvent(event.getCalendar(), event, null); 163 163 } else { 164 164 svci.updateEvent(event); trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventAction.java
r55 r207 131 131 } 132 132 133 svci.addEvent(ev , null);133 svci.addEvent(ev.getCalendar(), ev, null); 134 134 135 135 form.resetNewEvent(); trunk/calendar3/webclient/src/org/bedework/webclient/BwAddEventRefAction.java
r55 r207 56 56 57 57 import org.bedework.appcommon.BedeworkDefs; 58 import org.bedework.calfacade.BwEvent;59 58 import org.bedework.calfacade.BwEventProxy; 60 59 import org.bedework.calfacade.svc.EventInfo; … … 83 82 } 84 83 85 int id = form.getEventId();86 87 if (id < 0) {88 // Do nothing89 form.getErr().emit("org.bedework.client.error.nosuchevent", id);90 return "doNothing";91 }92 93 84 CalSvcI svci = form.fetchSvci(); 94 85 95 EventInfo ei = svci.getEvent(id);86 EventInfo ei = findEvent(request, form); 96 87 97 88 if (ei == null) { 98 89 // Do nothing 99 form.getErr().emit("org.bedework.client.error.nosuchevent", id);100 90 return "doNothing"; 101 91 } … … 104 94 * the appropriate fields from the target 105 95 */ 106 BwEvent proxy = BwEventProxy.makeAnnotation(ei.getEvent(),96 BwEventProxy proxy = BwEventProxy.makeAnnotation(ei.getEvent(), 107 97 ei.getEvent().getOwner()); 108 98 109 svci.addEvent( proxy, null);99 svci.addEvent(null, proxy.getTarget(), null); 110 100 111 101 form.getMsg().emit("org.bedework.client.message.added.eventrefs", 1); trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
r163 r207 79 79 import org.bedework.calsvci.CalSvcIPars; 80 80 81 import edu.rpi.sss.util.Util;82 83 81 import edu.rpi.sss.util.jsp.JspUtil; 84 82 import edu.rpi.sss.util.jsp.SessionListener; … … 371 369 } 372 370 } 373 374 String guid = request.getParameter("guid"); 375 376 if (Util.checkNull(guid) != null) { 371 372 int calId = getIntReqPar(request, "calid", -1); 373 BwCalendar cal = null; 374 375 if (calId < 0) { 376 form.getErr().emit("org.bedework.client.error.missingsubscriptionid"); 377 return null; 378 } 379 380 cal = svci.getCalendar(calId); 381 382 if (cal == null) { 383 // Assume no access 384 form.getErr().emit("org.bedework.client.error.noaccess"); 385 return null; 386 } 387 388 String guid = getReqPar(request, "guid"); 389 390 if (guid != null) { 377 391 if (debug) { 378 392 debugMsg("Get event by guid"); 379 393 } 380 String rid = Util.checkNull(request.getParameter("recurrenceId"));394 String rid = getReqPar(request, "recurrenceId"); 381 395 int retMethod = CalFacadeDefs.retrieveRecurMaster; 382 Collection evs = svci.getEvent( guid, rid, retMethod);396 Collection evs = svci.getEvent(sub, cal, guid, rid, retMethod); 383 397 if (debug) { 384 398 debugMsg("Get event by guid found " + evs.size()); … … 397 411 debugMsg("Get event by guid found " + ev.getEvent()); 398 412 } 399 400 ev.setSubscription(sub);401 413 402 414 return ev; trunk/calendar3/webcommon/src/org/bedework/webcommon/misc/UploadAction.java
r55 r207 55 55 package org.bedework.webcommon.misc; 56 56 57 import org.bedework.calfacade.BwCalendar; 57 58 import org.bedework.calfacade.BwEvent; 58 59 import org.bedework.calfacade.svc.EventInfo; … … 90 91 } 91 92 93 CalSvcI svci = form.fetchSvci(); 94 BwCalendar cal = null; 95 96 int calId = getIntReqPar(request, "calId", -1); 97 if (calId >= 0) { 98 cal = svci.getCalendar(calId); 99 } 100 101 if (cal == null) { 102 form.getErr().emit("org.bedework.client.error.missingcalendar"); 103 return null; 104 } 105 92 106 FormFile upFile = form.getUploadFile(); 93 107 … … 105 119 InputStream is = upFile.getInputStream(); 106 120 107 CalSvcI svci = form.fetchSvci();108 109 121 IcalTranslator trans = new IcalTranslator(svci.getIcalCallback(), debug); 110 122 111 Collection objs = trans.fromIcal( new InputStreamReader(is));123 Collection objs = trans.fromIcal(cal, new InputStreamReader(is)); 112 124 113 125 Iterator it = objs.iterator(); … … 121 133 122 134 if (ei.getNewEvent()) { 123 svci.addEvent( ev, ei.getOverrides());135 svci.addEvent(cal, ev, ei.getOverrides()); 124 136 } else { 125 137 svci.updateEvent(ev);
