[CalendarServer-changes] [3223] CalendarServer/trunk/twistedcaldav/scheduling
source_changes at macosforge.org
source_changes at macosforge.org
Thu Oct 23 19:57:36 PDT 2008
Revision: 3223
http://trac.macosforge.org/projects/calendarserver/changeset/3223
Author: cdaboo at apple.com
Date: 2008-10-23 19:57:36 -0700 (Thu, 23 Oct 2008)
Log Message:
-----------
Use SCHEDULE-STATUS codes as defined in new cadlav scheduling spec.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
CalendarServer/trunk/twistedcaldav/scheduling/imip.py
CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
CalendarServer/trunk/twistedcaldav/scheduling/itip.py
CalendarServer/trunk/twistedcaldav/scheduling/processing.py
CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
Modified: CalendarServer/trunk/twistedcaldav/scheduling/caldav.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/caldav.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/caldav.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -35,6 +35,7 @@
from twistedcaldav.scheduling.cuaddress import LocalCalendarUser,\
RemoteCalendarUser
from twistedcaldav.scheduling.delivery import DeliveryService
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
from twistedcaldav.scheduling.processing import ImplicitProcessor,\
ImplicitProcessorException
@@ -105,7 +106,7 @@
except AccessDeniedError:
log.err("Could not access Inbox for recipient: %s" % (recipient.cuaddr,))
err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-permissions")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="3.8;No authority")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
# Process next recipient
continue
@@ -149,7 +150,7 @@
if autoprocessed:
# No need to write the inbox item as it has already been auto-processed
- responses.add(recipient.cuaddr, responsecode.OK, reqstatus="2.0;Success")
+ responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_DELIVERED)
returnValue(True)
else:
# Copy calendar to inbox
@@ -168,10 +169,10 @@
# FIXME: Bare except
log.err("Could not store data in Inbox : %s" % (recipient.inbox,))
err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-permissions")))
- responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="3.8;No authority")
+ responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
returnValue(False)
else:
- responses.add(recipient.cuaddr, responsecode.OK, reqstatus="2.0;Success")
+ responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_DELIVERED)
# Store CALDAV:originator property
child.writeDeadProperty(caldavxml.Originator(davxml.HRef(self.scheduler.originator.cuaddr)))
@@ -208,10 +209,10 @@
except:
log.err("Could not determine free busy information: %s" % (recipient.cuaddr,))
err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-permissions")))
- responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="3.8;No authority")
+ responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_AUTHORITY)
returnValue(False)
else:
- responses.add(recipient.cuaddr, responsecode.OK, reqstatus="2.0;Success", calendar=fbresult)
+ responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.SUCCESS, calendar=fbresult)
returnValue(True)
@inlineCallbacks
Modified: CalendarServer/trunk/twistedcaldav/scheduling/imip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/imip.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/imip.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -27,6 +27,7 @@
from twistedcaldav.config import config
from twistedcaldav.log import Logger
from twistedcaldav.scheduling.delivery import DeliveryService
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
"""
Class that handles delivery of scheduling messages via iMIP.
@@ -70,17 +71,17 @@
# Generated failed response for this recipient
log.err("Could not do server-to-imip request : %s %s" % (self, e))
err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="5.1;Service unavailable")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
else:
- self.responses.add(recipient.cuaddr, responsecode.OK, reqstatus="2.0;Success")
+ self.responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.MESSAGE_SENT)
except Exception, e:
# Generated failed responses for each recipient
log.err("Could not do server-to-imip request : %s %s" % (self, e))
for recipient in self.recipients:
err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="5.1;Service unavailable")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
def postToGateway(self, fromAddr, toAddr, caldata, reactor=None):
if reactor is None:
Modified: CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -34,6 +34,7 @@
from twistedcaldav.log import Logger
from twistedcaldav.scheduling.delivery import DeliveryService
from twistedcaldav.scheduling.ischeduleservers import IScheduleServers
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
from twistedcaldav.util import utf8String
"""
@@ -75,7 +76,7 @@
if not server:
# Cannot do server-to-server for this recipient.
err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-allowed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="5.3;No scheduling support for user")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.NO_USER_SUPPORT)
# Process next recipient
continue
@@ -83,13 +84,13 @@
if not server.allow_to:
# Cannot do server-to-server outgoing requests for this server.
err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-allowed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="5.1;Service unavailable")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
# Process next recipient
continue
groups.setdefault(server, []).append(recipient)
-
+
if len(groups) == 0:
return
@@ -142,7 +143,7 @@
log.err("Could not do server-to-server request : %s %s" % (self, e))
for recipient in self.recipients:
err = HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "recipient-failed")))
- self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="5.1;Service unavailable")
+ self.responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.SERVICE_UNAVAILABLE)
def _generateHeaders(self):
self.headers = Headers()
Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -294,6 +294,14 @@
partstat_changed = False
private_comment_changed = False
+ # Get REQUEST-STATUS as we need to write that into the saved ATTENDEE property
+ reqstatus = tuple(from_component.properties("REQUEST-STATUS"))
+ assert len(reqstatus) <= 1, "There must be zero or REQUEST-STATUS properties in a REPLY\n%s" % (str(from_component),)
+ if reqstatus:
+ reqstatus = ";".join(reqstatus[0].value()[0:2])
+ else:
+ reqstatus = iTIPRequestStatus.SUCCESS
+
# Get attendee in from_component - there MUST be only one
attendees = tuple(from_component.properties("ATTENDEE"))
assert len(attendees) == 1, "There must be one and only one ATTENDEE property in a REPLY\n%s" % (str(from_component),)
@@ -304,7 +312,8 @@
existing_attendee = to_component.getAttendeeProperty((attendee.value(),))
if existing_attendee:
oldpartstat = existing_attendee.params().get("PARTSTAT", ("NEEDS-ACTION",))[0]
- existing_attendee.params().setdefault("PARTSTAT", [partstat])[0] = partstat
+ existing_attendee.params()["PARTSTAT"] = [partstat]
+ existing_attendee.params()["SCHEDULE-STATUS"] = [reqstatus]
partstat_changed = (oldpartstat != partstat)
# Handle attendee comments
@@ -580,3 +589,22 @@
# Property Parameters
itip.removePropertyParameters("ATTENDEE", ("SCHEDULE-AGENT", "SCHEDULE-STATUS",))
itip.removePropertyParameters("ORGANIZER", ("SCHEDULE-STATUS",))
+
+class iTIPRequestStatus(object):
+ """
+ String constants for various iTIP status codes we use.
+ """
+
+ MESSAGE_PENDING = "1.0;Scheduling message send is pending"
+ MESSAGE_SENT = "1.1;Scheduling message has been sent"
+ MESSAGE_DELIVERED = "1.2;Scheduling message has been delivered"
+
+ SUCCESS = "2.0;Success"
+
+ INVALID_CALENDAR_USER = "3.7;Invalid Calendar User"
+ NO_AUTHORITY = "3.8;No authority"
+
+ BAD_REQUEST = "5.0;Service cannot handle request"
+ SERVICE_UNAVAILABLE = "5.1;Service unavailable"
+ INVALID_SERVICE = "5.2;Invalid calendar service"
+ NO_USER_SUPPORT = "5.3;No scheduling support for user"
Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -24,7 +24,7 @@
from twistedcaldav.log import Logger
from twistedcaldav.method import report_common
from twistedcaldav.method.report import NumberOfMatchesWithinLimits
-from twistedcaldav.scheduling.itip import iTipProcessing
+from twistedcaldav.scheduling.itip import iTipProcessing, iTIPRequestStatus
from twisted.internet import reactor
import datetime
import time
@@ -253,7 +253,7 @@
# Must have a calendar if auto-replying
if default is None and self.recipient.principal.autoSchedule():
log.error("No default calendar for auto-replying recipient: '%s'." % (self.recipient.cuaddr,))
- raise ImplicitProcessorException("5.3;No scheduling support for user")
+ raise ImplicitProcessorException(iTIPRequestStatus.NO_USER_SUPPORT)
if default:
log.debug("ImplicitProcessing - originator '%s' to recipient '%s' ignoring METHOD:REQUEST, UID: '%s' - new processed" % (self.originator.cuaddr, self.recipient.cuaddr, self.uid))
@@ -494,7 +494,7 @@
# Fake a SCHEDULE-STATUS on the ORGANIZER property
if made_changes:
- calendar.setParameterToValueForPropertyWithValue("SCHEDULE-STATUS", "2.0;Success", "ORGANIZER", None)
+ calendar.setParameterToValueForPropertyWithValue("SCHEDULE-STATUS", iTIPRequestStatus.MESSAGE_DELIVERED, "ORGANIZER", None)
returnValue((made_changes, partstat,))
Modified: CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2008-10-24 01:46:43 UTC (rev 3222)
+++ CalendarServer/trunk/twistedcaldav/scheduling/scheduler.py 2008-10-24 02:57:36 UTC (rev 3223)
@@ -27,6 +27,7 @@
from twistedcaldav import caldavxml
from twistedcaldav.accounting import accountingEnabled, emitAccounting
from twistedcaldav.caldavxml import caldav_namespace, TimeRange
+from twistedcaldav.config import config
from twistedcaldav.customxml import calendarserver_namespace
from twistedcaldav.ical import Component
from twistedcaldav.log import Logger, LoggingMixIn
@@ -37,7 +38,7 @@
from twistedcaldav.scheduling.imip import ScheduleViaIMip
from twistedcaldav.scheduling.ischedule import ScheduleViaISchedule
from twistedcaldav.scheduling.ischeduleservers import IScheduleServers
-from twistedcaldav.config import config
+from twistedcaldav.scheduling.itip import iTIPRequestStatus
import itertools
import re
@@ -294,7 +295,7 @@
for recipient in self.recipients:
if self.fakeTheResult:
- responses.add(recipient.cuaddr, responsecode.OK, reqstatus="2.0;Success")
+ responses.add(recipient.cuaddr, responsecode.OK, reqstatus=iTIPRequestStatus.SUCCESS if freebusy else iTIPRequestStatus.MESSAGE_DELIVERED)
elif isinstance(recipient, LocalCalendarUser):
caldav_recipients.append(recipient)
@@ -307,7 +308,7 @@
else:
err = HTTPError(ErrorResponse(responsecode.NOT_FOUND, (caldav_namespace, "recipient-exists")))
- responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus="3.7;Invalid Calendar User")
+ responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.INVALID_CALENDAR_USER)
# Now process local recipients
if caldav_recipients:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081023/531f761b/attachment-0001.html>
More information about the calendarserver-changes
mailing list