[CalendarServer-changes] [13301] CalendarServer/trunk/calendarserver/tools/calverify.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 16 12:52:51 PDT 2014


Revision: 13301
          http://trac.calendarserver.org//changeset/13301
Author:   cdaboo at apple.com
Date:     2014-04-16 12:52:50 -0700 (Wed, 16 Apr 2014)
Log Message:
-----------
Still need to handle http:// style cu-addresses.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/calverify.py

Modified: CalendarServer/trunk/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/calverify.py	2014-04-16 19:52:22 UTC (rev 13300)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py	2014-04-16 19:52:50 UTC (rev 13301)
@@ -395,6 +395,7 @@
         self.reactor = reactor
         self.config = config
         self._directory = store.directoryService()
+        self._principalCollection = self.rootResource().getChild("principals")
 
         self.cuaCache = {}
 
@@ -1219,23 +1220,31 @@
     def noPrincipalPathCUAddresses(self, component, doFix):
 
         @inlineCallbacks
+        def recordWithCalendarUserAddress(address):
+            principal = yield self._principalCollection.principalForCalendarUserAddress(address)
+            returnValue(principal.record)
+
+        @inlineCallbacks
         def lookupFunction(cuaddr, recordFunction, conf):
 
-            # Return cached results, if any.
+            # Return cached results, if any.add
             if cuaddr in self.cuaCache:
                 returnValue(self.cuaCache[cuaddr])
 
             result = yield normalizationLookup(cuaddr, recordFunction, conf)
-            _ignore_name, guid, _ignore_cuaddrs = result
+            _ignore_name, guid, _ignore_cutype, _ignore_cuaddrs = result
             if guid is None:
                 if cuaddr.find("__uids__") != -1:
                     guid = cuaddr[cuaddr.find("__uids__/") + 9:][:36]
-                    result = "", guid, set()
+                    result = ("", guid, "", set(),)
 
             # Cache the result
             self.cuaCache[cuaddr] = result
             returnValue(result)
 
+        x = component.resourceUID()
+        if x == "BAD10":
+            x = None
         for subcomponent in component.subcomponents():
             if subcomponent.name() in ignoredComponents:
                 continue
@@ -1246,13 +1255,13 @@
                 # http(s) principals need to be converted to urn:uuid
                 if cuaddr.startswith("http"):
                     if doFix:
-                        yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                        yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
                     else:
                         raise InvalidICalendarDataError("iCalendar ORGANIZER starts with 'http(s)'")
                 elif cuaddr.startswith("mailto:"):
-                    if (yield lookupFunction(cuaddr, self.directoryService().recordWithCalendarUserAddress, self.config))[1] is not None:
+                    if (yield lookupFunction(cuaddr, recordWithCalendarUserAddress, self.config))[1] is not None:
                         if doFix:
-                            yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                            yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
                         else:
                             raise InvalidICalendarDataError("iCalendar ORGANIZER starts with 'mailto:' and record exists")
                 else:
@@ -1260,7 +1269,7 @@
                         if doFix:
                             # Add back in mailto: then re-normalize to urn:uuid if possible
                             organizer.setValue("mailto:%s" % (cuaddr,))
-                            yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                            yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
 
                             # Remove any SCHEDULE-AGENT=NONE
                             if organizer.parameterValue("SCHEDULE-AGENT", "SERVER") == "NONE":
@@ -1283,13 +1292,13 @@
                 # http(s) principals need to be converted to urn:uuid
                 if cuaddr.startswith("http"):
                     if doFix:
-                        yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                        yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
                     else:
                         raise InvalidICalendarDataError("iCalendar ATTENDEE starts with 'http(s)'")
                 elif cuaddr.startswith("mailto:"):
-                    if (yield lookupFunction(cuaddr, self.directoryService().recordWithCalendarUserAddress, self.config))[1] is not None:
+                    if (yield lookupFunction(cuaddr, recordWithCalendarUserAddress, self.config))[1] is not None:
                         if doFix:
-                            yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                            yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
                         else:
                             raise InvalidICalendarDataError("iCalendar ATTENDEE starts with 'mailto:' and record exists")
                 else:
@@ -1297,7 +1306,7 @@
                         if doFix:
                             # Add back in mailto: then re-normalize to urn:uuid if possible
                             attendee.setValue("mailto:%s" % (cuaddr,))
-                            yield component.normalizeCalendarUserAddresses(lookupFunction, self.directoryService().recordWithCalendarUserAddress)
+                            yield component.normalizeCalendarUserAddresses(lookupFunction, recordWithCalendarUserAddress)
                         else:
                             raise InvalidICalendarDataError("iCalendar ATTENDEE missing mailto:")
 
@@ -1310,7 +1319,10 @@
                         else:
                             raise InvalidICalendarDataError("iCalendar ATTENDEE CALENDARSERVER-OLD-CUA not base64")
 
+        if component.resourceUID() == "BAD10":
+            x = "bad"
 
+
     def attendeesWithoutOrganizer(self, component, doFix):
         """
         Look for events with ATTENDEE properties and no ORGANIZER property.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140416/0429e3ae/attachment-0001.html>


More information about the calendarserver-changes mailing list