[CalendarServer-changes] [8733] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 20 19:09:34 PST 2012


Revision: 8733
          http://trac.macosforge.org/projects/calendarserver/changeset/8733
Author:   sagen at apple.com
Date:     2012-02-20 19:09:34 -0800 (Mon, 20 Feb 2012)
Log Message:
-----------
Adds compatibility mode when podding with v1 server, allowing /path-based CUAs in scheduling replies.  Also, prefer /path-based CUAs over http(s) form.

Modified Paths:
--------------
    CalendarServer/trunk/conf/caldavd-test.plist
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
    CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
    CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/conf/caldavd-test.plist	2012-02-21 03:09:34 UTC (rev 8733)
@@ -815,6 +815,8 @@
         <false/>
         <key>AttendeeRefreshBatch</key>
         <integer>0</integer>
+        <key>V1Compatibility</key> <!-- Allow /path-based CUAs in scheduling replies -->
+        <false/>
 
 		<key>AutoSchedule</key>
 		<dict>

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -2539,36 +2539,45 @@
                 if toUUID:
                     # Always re-write value to urn:uuid
                     prop.setValue("urn:uuid:%s" % (guid,))
-                    
+
                 # If it is already a non-UUID address leave it be
                 elif cuaddr.startswith("urn:uuid:"):
                     if oldemail:
                         # Use the EMAIL parameter if it exists
                         newaddr = oldemail
                     else:
-                        # Pick the first mailto, or failing that the first http, or failing that the first one
+                        # Pick the first mailto,
+                        # or failing that the first path one,
+                        # or failing that the first http one,
+                        # or failing that the first one
                         first_mailto = None
+                        first_path = None
                         first_http = None
                         first = None
                         for addr in cuaddrs:
                             if addr.startswith("mailto:"):
                                 first_mailto = addr
                                 break
+                            elif addr.startswith("/"):
+                                if not first_path:
+                                    first_path = addr
                             elif addr.startswith("http:"):
                                 if not first_http:
                                     first_http = addr
                             elif not first:
                                 first = addr
-                        
+
                         if first_mailto:
                             newaddr = first_mailto
+                        elif first_path:
+                            newaddr = first_path
                         elif first_http:
                             newaddr = first_http
                         elif first:
                             newaddr = first
                         else:
                             newaddr = None
-                    
+
                     # Make the change
                     if newaddr:
                         prop.setValue(newaddr)

Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -332,7 +332,7 @@
         # Get some useful information from the calendar
         yield self.extractCalendarData()        
 
-        self.originator = self.attendee = attendee.cuaddr
+        self.originator = self.attendee = attendee.principal.canonicalCalendarUserAddress()
         self.attendeePrincipal = attendee.principal
         
         result = (yield self.scheduleWithOrganizer())

Modified: CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -309,9 +309,18 @@
                 if principal is None:
                     return (None, None, None)
                 else:
-                    return (principal.record.fullName,
-                        principal.record.guid,
-                        principal.record.calendarUserAddresses)
+                    # TODO: remove V1Compatibility when V1 migration is complete
+                    if config.Scheduling.Options.V1Compatibility:
+                        # Allow /principals-form CUA
+                        return (principal.record.fullName.decode("utf-8"),
+                            principal.record.guid,
+                            principal.calendarUserAddresses()
+                        )
+                    else:
+                        return (principal.record.fullName.decode("utf-8"),
+                            principal.record.guid,
+                            principal.record.calendarUserAddresses
+                        )
 
             normalizedCalendar = self.scheduler.calendar.duplicate()
             normalizedCalendar.normalizeCalendarUserAddresses(lookupFunction, toUUID=False)

Modified: CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -852,12 +852,19 @@
                 if principal is None:
                     return (None, None, None)
                 else:
-                    return (
-                        principal.record.fullName.decode("utf-8"),
-                        principal.record.guid,
-                        principal.record.calendarUserAddresses
-                    )
-    
+                    # TODO: remove V1Compatibility when V1 migration is complete
+                    if config.Scheduling.Options.V1Compatibility:
+                        # Allow /principals-form CUA
+                        return (principal.record.fullName.decode("utf-8"),
+                            principal.record.guid,
+                            principal.calendarUserAddresses()
+                        )
+                    else:
+                        return (principal.record.fullName.decode("utf-8"),
+                            principal.record.guid,
+                            principal.record.calendarUserAddresses
+                        )
+
             self.calendar.normalizeCalendarUserAddresses(lookupFunction)
 
     def checkAuthorization(self):

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -644,6 +644,7 @@
             "AttendeeRefreshBatchIntervalSeconds" :   5,    # Time between attendee batch refreshes
             "UIDLockTimeoutSeconds"               :  60,    # Time for implicit UID lock timeout
             "UIDLockExpirySeconds"                : 300,    # Expiration time for UID lock,
+            "V1Compatibility"                     : False,  # Allow /path-based CUAs in scheduling replies
             
             "AutoSchedule" : {
                 "Enabled"                         : True,   # Auto-scheduling will never occur if set to False

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-02-20 22:24:07 UTC (rev 8732)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-02-21 03:09:34 UTC (rev 8733)
@@ -5975,3 +5975,54 @@
         for title, expected, body in data:
             ical = Component.fromString(body)
             self.assertEquals(expected, ical.hasInstancesAfter(cutoff))
+
+
+    def test_normalizeCalendarUserAddresses(self):
+        """
+        Ensure mailto is preferred, followed by path form, then http form
+        """
+
+        data = """BEGIN:VCALENDAR
+VERSION:2.0
+DTSTART:20071114T000000Z
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20071114T000000Z
+ATTENDEE:urn:uuid:foo
+ATTENDEE:urn:uuid:bar
+ATTENDEE:urn:uuid:baz
+DTSTAMP:20071114T000000Z
+END:VEVENT
+END:VCALENDAR
+"""
+
+        component = Component.fromString(data)
+
+        def lookupFunction(cuaddr):
+            return {
+                "urn:uuid:foo" : (
+                    "Foo",
+                    "foo",
+                    ("urn:uuid:foo", "http://example.com/foo", "/foo")
+                ),
+                "urn:uuid:bar" : (
+                    "Bar",
+                    "bar",
+                    ("urn:uuid:bar", "mailto:bar at example.com", "http://example.com/bar", "/bar")
+                ),
+                "urn:uuid:baz" : (
+                    "BaZ",
+                    "baz",
+                    ("urn:uuid:baz", "http://example.com/baz")
+                ),
+            }[cuaddr]
+
+        component.normalizeCalendarUserAddresses(lookupFunction, toUUID=False)
+
+        self.assertEquals("mailto:bar at example.com",
+            component.getAttendeeProperty(("mailto:bar at example.com",)).value())
+        self.assertEquals("/foo",
+            component.getAttendeeProperty(("/foo",)).value())
+        self.assertEquals("http://example.com/baz",
+            component.getAttendeeProperty(("http://example.com/baz",)).value())
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120220/af64b4a9/attachment-0001.html>


More information about the calendarserver-changes mailing list