[CalendarServer-changes] [4251] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed May 13 09:34:20 PDT 2009


Revision: 4251
          http://trac.macosforge.org/projects/calendarserver/changeset/4251
Author:   cdaboo at apple.com
Date:     2009-05-13 09:34:20 -0700 (Wed, 13 May 2009)
Log Message:
-----------
Handle the case where Attendee's client creates a "fake" master out of an overridden instance.

Modified Paths:
--------------
    CalendarServer/trunk/run
    CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
    CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
    CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py

Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run	2009-05-13 16:21:55 UTC (rev 4250)
+++ CalendarServer/trunk/run	2009-05-13 16:34:20 UTC (rev 4251)
@@ -727,7 +727,7 @@
 
 caldavtester="${top}/CalDAVTester";
 
-svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 4221;
+svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 4250;
 
 #
 # PyFlakes

Modified: CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2009-05-13 16:21:55 UTC (rev 4250)
+++ CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2009-05-13 16:34:20 UTC (rev 4251)
@@ -275,13 +275,43 @@
                 for exdate in master.properties("EXDATE"):
                     exdates.update([normalizeToUTC(value) for value in exdate.value()])
                
-            return exdates, map
+            return exdates, map, master
         
-        exdates1, map1 = mapComponents(self.calendar1)
+        exdates1, map1, master1 = mapComponents(self.calendar1)
         set1 = set(map1.keys())
-        exdates2, map2 = mapComponents(self.calendar2)
+        exdates2, map2, master2 = mapComponents(self.calendar2)
         set2 = set(map2.keys())
 
+        # Handle case where iCal breaks events without a master component
+        if master2 is not None and master1 is None:
+            master2Start = master2.getStartDateUTC()
+            key2 = (master2.name(), master2.propertyValue("UID"), master2Start)
+            if key2 not in set1:
+                # The DTSTART in the fake master does not match a RECURRENCE-ID in the real data.
+                # We have to do a brute force search for the component that matches based on DTSTART
+                for component1 in self.calendar1.subcomponents():
+                    if component1.name() == "VTIMEZONE":
+                        continue
+                    if master2Start == component1.getStartDateUTC():
+                        break
+                else:
+                    # Nothing matches - this has to be treated as an error
+                    log.debug("attendeeMerge: Unable to match fake master component: %s" % (key2,))
+                    return False, False, (), None
+            else:
+                component1 = self.calendar1.overriddenComponent(master2Start)
+            
+            # Take the recurrence ID from component1 and fix map2/set2
+            key2 = (master2.name(), master2.propertyValue("UID"), None)
+            component2 = map2[key2]
+            del map2[key2]
+            
+            rid1 = component1.getRecurrenceIDUTC()
+            newkey2 = (master2.name(), master2.propertyValue("UID"), rid1)
+            map2[newkey2] = component2
+            set2.remove(key2)
+            set2.add(newkey2)
+    
         # All the components in calendar1 must be in calendar2 unless they are CANCELLED
         result = set1 - set2
         for key in result:

Modified: CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py	2009-05-13 16:21:55 UTC (rev 4250)
+++ CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py	2009-05-13 16:34:20 UTC (rev 4251)
@@ -316,11 +316,12 @@
             if accountingEnabled("iTIP", self.organizer.principal):
                 emitAccounting(
                     "iTIP", self.organizer.principal,
-                    "Originator: %s\nRecipients:\n%sServer Instance:%s\n\n%s"
+                    "Originator: %s\nRecipients:\n%sServer Instance:%s\nMethod:%s\n\n%s"
                     % (
                         str(self.originator),
                         str("".join(["    %s\n" % (recipient,) for recipient in self.recipients])),
                         str(self.request.serverInstance),
+                        str(self.method),
                         str(self.calendar)
                     )
                 )

Modified: CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py	2009-05-13 16:21:55 UTC (rev 4250)
+++ CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py	2009-05-13 16:34:20 UTC (rev 4251)
@@ -2503,6 +2503,145 @@
             )
             self.assertEqual(diffResult, result, msg="%s: actual result: (%s)" % (description, ", ".join([str(i).replace("\r", "") for i in diffResult]),))
 
+    def test_attendee_merge_fake_master(self):
+
+        
+        data = (
+            (
+                "#1.1 Single overridden component, partstat change - ok",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+RECURRENCE-ID:20080601T120000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                "mailto:user2 at example.com",
+                (True, True, ('20080601T120000Z',), """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2 at example.com
+ORGANIZER;CN=User 01:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""")
+            ),
+            (
+                "#1.2 Single overridden component DTSTART different, partstat change - ok",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T130000Z
+DTEND:20080601T140000Z
+RECURRENCE-ID:20080601T120000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T130000Z
+DTEND:20080601T140000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                "mailto:user2 at example.com",
+                (True, True, ('20080601T120000Z',), """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080601T120000Z
+DTSTART:20080601T130000Z
+DTEND:20080601T140000Z
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2 at example.com
+ORGANIZER;CN=User 01:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""")
+            ),
+            (
+                "#1.3 Single overridden component DTSTART different, partstat change - DTSTART bad",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T130000Z
+DTEND:20080601T140000Z
+RECURRENCE-ID:20080601T120000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                "mailto:user2 at example.com",
+                (False, False, (), None,)
+            ),
+        )
+
+        for description, calendar1, calendar2, attendee, result in data:
+            differ = iCalDiff(Component.fromString(calendar1), Component.fromString(calendar2), False)
+            diffResult = differ.attendeeMerge(attendee)
+            diffResult = (
+                diffResult[0],
+                diffResult[1],
+                tuple(diffResult[2]),
+                str(diffResult[3]).replace("\r", "") if diffResult[3] else None,
+            )
+            self.assertEqual(diffResult, result, msg="%s: actual result: (%s)" % (description, ", ".join([str(i).replace("\r", "") for i in diffResult]),))
+
     def test_what_is_different(self):
         
         data1 = (
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090513/46f1999e/attachment.html>


More information about the calendarserver-changes mailing list