[CalendarServer-changes] [11873] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:23:45 PDT 2014


Revision: 11873
          http://trac.calendarserver.org//changeset/11873
Author:   cdaboo at apple.com
Date:     2013-11-01 16:46:07 -0700 (Fri, 01 Nov 2013)
Log Message:
-----------
Merge branch that separates iSchedule and podding behaviors.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/twistedcaldav/extensions.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/scheduler.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/delivery.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/remoteservers.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/resource.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_delivery.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/scheduler.py

Property Changed:
----------------
    CalendarServer/trunk/


Property changes on: CalendarServer/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11612
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
   + /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -636,11 +636,23 @@
             addSystemEventTrigger("after", "startup", timezoneStdService.onStartup)
 
     #
-    # iSchedule service
+    # iSchedule service for podding
     #
+    if config.Servers.Enabled:
+        log.info("Setting up iSchedule podding inbox resource: {cls}", cls=iScheduleResourceClass)
+
+        ischedule = iScheduleResourceClass(
+            root,
+            newStore,
+            podding=True
+        )
+        root.putChild(config.Servers.InboxName, ischedule)
+
+    #
+    # iSchedule service (not used for podding)
+    #
     if config.Scheduling.iSchedule.Enabled:
-        log.info("Setting up iSchedule inbox resource: {cls}",
-                      cls=iScheduleResourceClass)
+        log.info("Setting up iSchedule inbox resource: {cls}", cls=iScheduleResourceClass)
 
         ischedule = iScheduleResourceClass(
             root,
@@ -651,8 +663,7 @@
         # Do DomainKey resources
         DKIMUtils.validConfiguration(config)
         if config.Scheduling.iSchedule.DKIM.Enabled:
-            log.info("Setting up domainkey resource: {res}",
-                res=DomainKeyResource)
+            log.info("Setting up domainkey resource: {res}", res=DomainKeyResource)
             domain = config.Scheduling.iSchedule.DKIM.Domain if config.Scheduling.iSchedule.DKIM.Domain else config.ServerHostName
             dk = DomainKeyResource(
                 domain,

Modified: CalendarServer/trunk/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/extensions.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/twistedcaldav/extensions.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -494,13 +494,13 @@
             size = child.contentLength()
             lastModified = child.lastModified()
             rtypes = []
-            fullrtype = child.resourceType()
+            fullrtype = child.resourceType() if hasattr(child, "resourceType") else None
             if fullrtype is not None:
                 for rtype in fullrtype.children:
                     rtypes.append(rtype.name)
             if rtypes:
                 rtypes = "(%s)" % (", ".join(rtypes),)
-            if child.isCollection():
+            if child.isCollection() if hasattr(child, "isCollection") else False:
                 contentType = rtypes
             else:
                 mimeType = child.contentType()
@@ -1004,6 +1004,7 @@
     return tokens, context, applyTo, clientLimit, propElement
 
 
+
 def validateTokens(tokens):
     """
     Make sure there is at least one token longer than one character

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -806,9 +806,10 @@
     # Support multiple hosts within a domain
     #
     "Servers" : {
-        "Enabled": False, # Multiple servers/partitions enabled or not
-        "ConfigFile": "localservers.xml", # File path for server information
-        "MaxClients": 5, # Pool size for connections to each partition
+        "Enabled": False,                   # Multiple servers/partitions enabled or not
+        "ConfigFile": "localservers.xml",   # File path for server information
+        "MaxClients": 5,                    # Pool size for connections to each partition
+        "InboxName": "podding",             # Name for top-level inbox resource
     },
     "ServerPartitionID": "", # Unique ID for this server's partition instance.
 
@@ -1045,9 +1046,10 @@
         configDict = ConfigDict(configDict)
         # Now check for Includes and parse and add each of those
         if "Includes" in configDict:
+            configRoot = os.path.join(configDict.ServerRoot, configDict.ConfigRoot)
             for include in configDict.Includes:
                 # Includes are not relative to ConfigRoot
-                path = _expandPath(include)
+                path = _expandPath(fullServerPath(configRoot, include))
                 if os.path.exists(path):
                     additionalDict = ConfigDict(self._parseConfigFromFile(path))
                     if additionalDict:

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/scheduler.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/scheduler.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/scheduler.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -101,6 +101,14 @@
                 "No principal for originator",
             ))
         else:
+            if not (originatorPrincipal.calendarsEnabled() and originatorPrincipal.thisServer()):
+                log.err("Originator not enabled or hosted on this server: %s" % (self.originator,))
+                raise HTTPError(self.errorResponse(
+                    responsecode.FORBIDDEN,
+                    self.errorElements["originator-denied"],
+                    "Originator cannot be scheduled",
+                ))
+
             self.originator = LocalCalendarUser(self.originator, originatorPrincipal)
 
 
@@ -127,7 +135,7 @@
             else:
                 # Map recipient to their inbox
                 inbox = None
-                if principal.calendarsEnabled() and principal.thisServer():
+                if principal.calendarsEnabled():
                     if principal.locallyHosted():
                         recipient_home = yield self.txn.calendarHomeWithUID(principal.uid, create=True)
                         if recipient_home:
@@ -138,7 +146,7 @@
                 if inbox:
                     results.append(calendarUserFromPrincipal(recipient, principal, inbox))
                 else:
-                    log.error("No schedule inbox for principal: %s" % (principal,))
+                    log.error("Recipient not enabled for calendaring: %s" % (principal,))
                     results.append(InvalidCalendarUser(recipient))
 
         self.recipients = results

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/delivery.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/delivery.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/delivery.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -72,6 +72,7 @@
 class ScheduleViaISchedule(DeliveryService):
 
     domainServerMap = {}
+    servermgr = None
 
     @classmethod
     def serviceType(cls):
@@ -82,9 +83,7 @@
     @inlineCallbacks
     def matchCalendarUserAddress(cls, cuaddr):
 
-        # TODO: here is where we would attempt service discovery based on the cuaddr.
-
-        # Only handle mailtos:
+        # Handle mailtos:
         if cuaddr.lower().startswith("mailto:"):
             domain = extractEmailDomain(cuaddr)
             server = (yield cls.serverForDomain(domain))
@@ -100,25 +99,30 @@
     def serverForDomain(cls, domain):
         if domain not in cls.domainServerMap:
 
-            # First check built-in list of remote servers
-            servermgr = IScheduleServers()
-            server = servermgr.mapDomain(domain)
-            if server is not None:
-                cls.domainServerMap[domain] = server
-            else:
-                # Lookup domain
-                result = (yield lookupServerViaSRV(domain))
-                if result is None:
+            if config.Scheduling.iSchedule.Enabled:
+
+                # First check built-in list of remote servers
+                if cls.servermgr is None:
+                    cls.servermgr = IScheduleServers()
+                server = cls.servermgr.mapDomain(domain)
+                if server is not None:
+                    cls.domainServerMap[domain] = server
+                else:
                     # Lookup domain
-                    result = (yield lookupServerViaSRV(domain, service="_ischedule"))
+                    result = (yield lookupServerViaSRV(domain))
                     if result is None:
-                        cls.domainServerMap[domain] = None
+                        # Lookup domain
+                        result = (yield lookupServerViaSRV(domain, service="_ischedule"))
+                        if result is None:
+                            cls.domainServerMap[domain] = None
+                        else:
+                            # Create the iSchedule server record for this server
+                            cls.domainServerMap[domain] = IScheduleServerRecord(uri="http://%s:%s/.well-known/ischedule" % result)
                     else:
                         # Create the iSchedule server record for this server
-                        cls.domainServerMap[domain] = IScheduleServerRecord(uri="http://%s:%s/.well-known/ischedule" % result)
-                else:
-                    # Create the iSchedule server record for this server
-                    cls.domainServerMap[domain] = IScheduleServerRecord(uri="https://%s:%s/.well-known/ischedule" % result)
+                        cls.domainServerMap[domain] = IScheduleServerRecord(uri="https://%s:%s/.well-known/ischedule" % result)
+            else:
+                cls.domainServerMap[domain] = None
 
         returnValue(cls.domainServerMap[domain])
 
@@ -189,9 +193,12 @@
 
         partition = recipient.principal.partitionURI()
         if partition not in self.partitionedServers:
-            self.partitionedServers[partition] = IScheduleServerRecord(uri=joinURL(partition, "/ischedule"))
-            self.partitionedServers[partition].unNormalizeAddresses = False
-            self.partitionedServers[partition].moreHeaders.append(recipient.principal.server().secretHeader())
+            self.partitionedServers[partition] = IScheduleServerRecord(
+                uri=joinURL(partition, config.Servers.InboxName),
+                unNormalizeAddresses=False,
+                moreHeaders=[recipient.principal.server().secretHeader(), ],
+                podding=True,
+            )
 
         return self.partitionedServers[partition]
 
@@ -203,9 +210,12 @@
 
         serverURI = recipient.principal.serverURI()
         if serverURI not in self.otherServers:
-            self.otherServers[serverURI] = IScheduleServerRecord(uri=joinURL(serverURI, "/ischedule"))
-            self.otherServers[serverURI].unNormalizeAddresses = not recipient.principal.server().isImplicit
-            self.otherServers[serverURI].moreHeaders.append(recipient.principal.server().secretHeader())
+            self.otherServers[serverURI] = IScheduleServerRecord(
+                uri=joinURL(serverURI, config.Servers.InboxName),
+                unNormalizeAddresses=not recipient.principal.server().isImplicit,
+                moreHeaders=[recipient.principal.server().secretHeader(), ],
+                podding=True,
+            )
 
         return self.otherServers[serverURI]
 
@@ -222,6 +232,7 @@
         self.refreshOnly = refreshOnly
         self.headers = None
         self.data = None
+        self.original_organizer = None
 
 
     @inlineCallbacks
@@ -365,7 +376,8 @@
 
         # The Originator must be the ORGANIZER (for a request) or ATTENDEE (for a reply)
         originator = self.scheduler.organizer.cuaddr if self.scheduler.isiTIPRequest else self.scheduler.attendee
-        originator = normalizeCUAddress(originator, normalizationLookup, self.scheduler.txn.directoryService().recordWithCalendarUserAddress, toUUID=False)
+        if self.server.unNormalizeAddresses:
+            originator = normalizeCUAddress(originator, normalizationLookup, self.scheduler.txn.directoryService().recordWithCalendarUserAddress, toUUID=False)
         self.headers.addRawHeader("Originator", utf8String(originator))
         self.sign_headers.append("Originator")
 
@@ -414,15 +426,15 @@
         """
 
         if self.data is None:
+
             # Need to remap cuaddrs from urn:uuid
-            if self.server.unNormalizeAddresses and self.scheduler.method == "PUT":
-                normalizedCalendar = self.scheduler.calendar.duplicate()
+            normalizedCalendar = self.scheduler.calendar.duplicate()
+            self.original_organizer = normalizedCalendar.getOrganizer()
+            if self.server.unNormalizeAddresses:
                 normalizedCalendar.normalizeCalendarUserAddresses(
                     normalizationLookup,
                     self.scheduler.txn.directoryService().recordWithCalendarUserAddress,
                     toUUID=False)
-            else:
-                normalizedCalendar = self.scheduler.calendar
 
             # For VFREEBUSY we need to strip out ATTENDEEs that do not match the recipient list
             if self.scheduler.isfreebusy:
@@ -445,13 +457,12 @@
         f = Factory()
         f.protocol = HTTPClientProtocol
         if ssl:
-            ep = GAIEndpoint(reactor, host, port,
-                             _configuredClientContextFactory())
+            ep = GAIEndpoint(reactor, host, port, _configuredClientContextFactory())
         else:
             ep = GAIEndpoint(reactor, host, port)
         proto = (yield ep.connect(f))
 
-        if config.Scheduling.iSchedule.DKIM.Enabled:
+        if not self.server.podding() and config.Scheduling.iSchedule.DKIM.Enabled:
             domain, selector, key_file, algorithm, useDNSKey, useHTTPKey, usePrivateExchangeKey, expire = DKIMUtils.getConfiguration(config)
             request = DKIMRequest(
                 "POST",
@@ -503,6 +514,14 @@
             calendar_data = response.childOfType(CalendarData)
             if calendar_data:
                 calendar_data = str(calendar_data)
+                if self.server.unNormalizeAddresses and self.original_organizer is not None:
+                    # Need to restore original ORGANIZER value if it got unnormalized
+                    calendar = Component.fromString(calendar_data)
+                    organizers = calendar.getAllPropertiesInAnyComponent("ORGANIZER", depth=1)
+                    for organizer in organizers:
+                        organizer.setValue(self.original_organizer)
+                    calendar_data = str(calendar)
+
             error = response.childOfType(Error)
             if error:
                 error = error.children

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/remoteservers.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/remoteservers.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/remoteservers.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -138,7 +138,7 @@
     """
     Contains server-to-server details.
     """
-    def __init__(self, uri=None):
+    def __init__(self, uri=None, unNormalizeAddresses=True, moreHeaders=[], podding=False):
         """
         @param recordType: record type for directory entry.
         """
@@ -148,8 +148,9 @@
         self.allow_to = True
         self.domains = []
         self.client_hosts = []
-        self.unNormalizeAddresses = True
-        self.moreHeaders = []
+        self.unNormalizeAddresses = unNormalizeAddresses
+        self.moreHeaders = moreHeaders
+        self._podding = podding
 
         if uri:
             self.uri = uri
@@ -160,6 +161,10 @@
         return (self.ssl, self.host, self.port, self.path,)
 
 
+    def podding(self):
+        return self._podding
+
+
     def redirect(self, location):
         """
         Permanent redirect for the lifetime of this record.

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/resource.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/resource.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/resource.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -52,7 +52,7 @@
     Extends L{DAVResource} to provide iSchedule inbox functionality.
     """
 
-    def __init__(self, parent, store):
+    def __init__(self, parent, store, podding=False):
         """
         @param parent: the parent resource of this one.
         """
@@ -62,6 +62,7 @@
 
         self.parent = parent
         self._newStore = store
+        self._podding = podding
 
 
     def deadProperties(self):
@@ -109,12 +110,12 @@
     def render(self, request):
         output = """<html>
 <head>
-<title>Server To Server Inbox Resource</title>
+<title>%(rtype)s Inbox Resource</title>
 </head>
 <body>
-<h1>Server To Server Inbox Resource.</h1>
+<h1>%(rtype)s Inbox Resource.</h1>
 </body
-</html>"""
+</html>""" % {"rtype" : "Podding" if self._podding else "iSchedule", }
 
         response = Response(200, {}, output)
         response.headers.setHeader("content-type", MimeType("text", "html"))
@@ -126,7 +127,7 @@
         The iSchedule GET method.
         """
 
-        if not request.args:
+        if not request.args or self._podding:
             # Do normal GET behavior
             return self.render(request)
 
@@ -220,7 +221,7 @@
         txn = transactionFromRequest(request, self._newStore)
 
         # This is a server-to-server scheduling operation.
-        scheduler = IScheduleScheduler(txn, None)
+        scheduler = IScheduleScheduler(txn, None, podding=self._podding)
 
         originator = self.loadOriginatorFromRequestHeaders(request)
         recipients = self.loadRecipientsFromRequestHeaders(request)
@@ -236,7 +237,8 @@
         else:
             yield txn.commit()
         response = result.response()
-        response.headers.addRawHeader(ISCHEDULE_CAPABILITIES, str(config.Scheduling.iSchedule.SerialNumber))
+        if not self._podding:
+            response.headers.addRawHeader(ISCHEDULE_CAPABILITIES, str(config.Scheduling.iSchedule.SerialNumber))
         returnValue(response)
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/scheduler.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -119,6 +119,9 @@
 
 
 class IScheduleScheduler(RemoteScheduler):
+    """
+    Handles iSchedule and podding requests.
+    """
 
     scheduleResponse = IScheduleResponseQueue
 
@@ -138,6 +141,11 @@
         "max-recipients": (ischedule_namespace, "max-recipients"),
     }
 
+    def __init__(self, txn, originator_uid, logItems=None, noAttendeeRefresh=False, podding=False):
+        super(IScheduleScheduler, self).__init__(txn, originator_uid, logItems=logItems, noAttendeeRefresh=noAttendeeRefresh)
+        self._podding = podding
+
+
     @inlineCallbacks
     def doSchedulingViaPOST(self, remoteAddr, headers, body, originator, recipients):
         """
@@ -148,7 +156,7 @@
         self.headers = headers
         self.verified = False
 
-        if config.Scheduling.iSchedule.DKIM.Enabled:
+        if not self._podding and config.Scheduling.iSchedule.DKIM.Enabled:
             verifier = DKIMVerifier(self.headers, body, protocol_debug=config.Scheduling.iSchedule.DKIM.ProtocolDebug)
             try:
                 yield verifier.verify()
@@ -174,11 +182,16 @@
 
         calendar = Component.fromString(body)
 
-        if self.headers.getRawHeaders('x-calendarserver-itip-refreshonly', ("F"))[0] == "T":
+        if self._podding and self.headers.getRawHeaders('x-calendarserver-itip-refreshonly', ("F"))[0] == "T":
             self.txn.doing_attendee_refresh = 1
 
         # Normalize recipient addresses
-        recipients = [normalizeCUAddress(recipient, normalizationLookup, self.txn.directoryService().recordWithCalendarUserAddress) for recipient in recipients]
+        results = []
+        for recipient in recipients:
+            normalized = normalizeCUAddress(recipient, normalizationLookup, self.txn.directoryService().recordWithCalendarUserAddress)
+            self.recipientsNormalizationMap[normalized] = recipient
+            results.append(normalized)
+        recipients = results
 
         result = (yield super(IScheduleScheduler, self).doSchedulingViaPOST(originator, recipients, calendar))
         returnValue(result)

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_delivery.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_delivery.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/ischedule/test/test_delivery.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -42,6 +42,7 @@
         Make sure we do an exact comparison on EmailDomain
         """
 
+        self.patch(config.Scheduling.iSchedule, "Enabled", True)
         self.patch(config.Scheduling.iSchedule, "RemoteServers", "")
 
         # Only mailtos:
@@ -64,3 +65,9 @@
         self.assertFalse(result)
         result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:user")
         self.assertFalse(result)
+
+        # Test when not enabled
+        ScheduleViaISchedule.domainServerMap = {}
+        self.patch(config.Scheduling.iSchedule, "Enabled", False)
+        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:user at example.com")
+        self.assertFalse(result)

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/scheduler.py	2013-11-01 23:21:53 UTC (rev 11872)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/scheduler.py	2013-11-01 23:46:07 UTC (rev 11873)
@@ -142,6 +142,7 @@
 
         self.originator = None
         self.recipients = None
+        self.recipientsNormalizationMap = {}
         self.calendar = None
         self.organizer = None
         self.attendee = None
@@ -232,51 +233,6 @@
         returnValue(result)
 
 
-    @inlineCallbacks
-    def loadFromRequestData(self):
-        self.loadOriginatorFromRequestDetails()
-        self.loadRecipientsFromCalendarData()
-
-
-    def loadOriginatorFromRequestDetails(self):
-        # Get the originator who is the authenticated user
-        originatorPrincipal = self.txn.directoryService().recordWithUID(self.originator_uid)
-
-        # Pick the canonical CUA:
-        originator = originatorPrincipal.canonicalCalendarUserAddress() if originatorPrincipal else ""
-
-        if not originator:
-            log.error("%s request must have Originator" % (self.method,))
-            raise HTTPError(self.errorResponse(
-                responsecode.FORBIDDEN,
-                self.errorElements["originator-missing"],
-                "Missing originator",
-            ))
-        else:
-            self.originator = originator
-
-
-    def loadRecipientsFromCalendarData(self):
-
-        # Get the ATTENDEEs
-        attendees = list()
-        unique_set = set()
-        for attendee, _ignore in self.calendar.getAttendeesByInstance():
-            if attendee not in unique_set:
-                attendees.append(attendee)
-                unique_set.add(attendee)
-
-        if not attendees:
-            log.error("%s request must have at least one Recipient" % (self.method,))
-            raise HTTPError(self.errorResponse(
-                responsecode.FORBIDDEN,
-                self.errorElements["recipient-missing"],
-                "Must have recipients",
-            ))
-        else:
-            self.recipients = list(attendees)
-
-
     def preProcessCalendarData(self):
         """
         After loading calendar data from the request, do some optional processing of it. This method will be
@@ -474,7 +430,7 @@
         freebusy = self.checkForFreeBusy()
 
         # Prepare for multiple responses
-        responses = self.scheduleResponse(self.method, responsecode.OK)
+        responses = self.scheduleResponse(self.method, responsecode.OK, self.mapRecipientAddress)
 
         # Loop over each recipient and aggregate into lists by service types.
         caldav_recipients = []
@@ -577,7 +533,11 @@
         return requestor.generateSchedulingResponses()
 
 
+    def mapRecipientAddress(self, cuaddr):
+        return self.recipientsNormalizationMap.get(cuaddr, cuaddr)
 
+
+
 class RemoteScheduler(Scheduler):
 
     def checkOrganizer(self):
@@ -703,7 +663,7 @@
     response_description_element = davxml.ResponseDescription
     calendar_data_element = caldavxml.CalendarData
 
-    def __init__(self, method, success_response):
+    def __init__(self, method, success_response, recipient_mapper=None):
         """
         @param method: the name of the method generating the queue.
         @param success_response: the response to return in lieu of a
@@ -712,6 +672,7 @@
         self.responses = []
         self.method = method
         self.success_response = success_response
+        self.recipient_mapper = recipient_mapper
         self.location = None
 
 
@@ -745,6 +706,9 @@
         else:
             raise AssertionError("Unknown data type: %r" % (what,))
 
+        if self.recipient_mapper is not None:
+            recipient = self.recipient_mapper(recipient)
+
         if not suppressErrorLog and code > 400: # Error codes only
             self.log.error("Error during %s for %s: %s" % (self.method, recipient, message))
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/e5227f15/attachment.html>


More information about the calendarserver-changes mailing list