Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Make sure missing schedule-object state results in a recalculation of…

… the proper state to aid migration from non-implicit.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@8015 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information
cyrusdaboo committed Aug 25, 2011
1 parent b43ab78 commit cb913d3a9e9fa0ffeb546727511708eda55e36b1
@@ -67,7 +67,7 @@ def testImplicitSchedulingPUT(self, request, resource, resource_uri, calendar, i
self.internal_request = internal_request

existing_resource = resource.exists()
is_scheduling_object = self.checkSchedulingObjectResource(resource)
is_scheduling_object = (yield self.checkSchedulingObjectResource(resource))
existing_type = "schedule" if is_scheduling_object else "calendar"
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"

@@ -114,8 +114,8 @@ def testImplicitSchedulingMOVE(self, request, srcresource, srccal, src_uri, dest
new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"

dest_exists = destresource.exists()
dest_is_implicit = self.checkSchedulingObjectResource(destresource)
src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
dest_is_implicit = (yield self.checkSchedulingObjectResource(destresource))
src_is_implicit = (yield self.checkSchedulingObjectResource(srcresource)) or new_type == "schedule"

if srccal and destcal:
if src_is_implicit and dest_exists or dest_is_implicit:
@@ -148,8 +148,8 @@ def testImplicitSchedulingCOPY(self, request, srcresource, srccal, src_uri, dest

new_type = "schedule" if (yield self.checkImplicitState()) else "calendar"

dest_is_implicit = self.checkSchedulingObjectResource(destresource)
src_is_implicit = self.checkSchedulingObjectResource(srcresource) or new_type == "schedule"
dest_is_implicit = (yield self.checkSchedulingObjectResource(destresource))
src_is_implicit = (yield self.checkSchedulingObjectResource(srcresource)) or new_type == "schedule"

if srccal and destcal:
if src_is_implicit or dest_is_implicit:
@@ -181,15 +181,36 @@ def testImplicitSchedulingDELETE(self, request, resource, calendar, internal_req

yield self.checkImplicitState()

is_scheduling_object = self.checkSchedulingObjectResource(resource)
is_scheduling_object = (yield self.checkSchedulingObjectResource(resource))
resource_type = "schedule" if is_scheduling_object else "calendar"
self.action = "remove" if resource_type == "schedule" else "none"

returnValue((self.action != "none", False,))

@inlineCallbacks
def checkSchedulingObjectResource(self, resource):

return resource.isScheduleObject if resource and resource.exists() else False
if resource and resource.exists():
implicit = resource.isScheduleObject
if implicit is not None:
returnValue(implicit)
else:
calendar = (yield self.resource.iCalendarForUser(self.request))
# Get the ORGANIZER and verify it is the same for all components
try:
organizer = calendar.validOrganizerForScheduling()
except ValueError:
# We have different ORGANIZERs in the same iCalendar object - this is an error
returnValue(False)
organizerPrincipal = resource.principalForCalendarUserAddress(organizer) if organizer else None
implicit = organizerPrincipal != None
log.debug("Implicit - checked scheduling object resource state for UID: '%s', result: %s" % (
calendar.resourceUID(),
implicit,
))
returnValue(implicit)

returnValue(False)

@inlineCallbacks
def checkImplicitState(self):
@@ -439,11 +439,18 @@ def _set_accessMode(self, value):
accessMode = property(_get_accessMode, _set_accessMode)

def _get_isScheduleObject(self):
return str(self.properties().get(PropertyName.fromElement(customxml.TwistedSchedulingObjectResource), "false")) == "true"
"""
If the property is not present, then return None, else return a bool based on the
str "true" or "false" value.
"""
prop = self.properties().get(PropertyName.fromElement(customxml.TwistedSchedulingObjectResource))
if prop is not None:
prop = str(prop) == "true"
return prop

def _set_isScheduleObject(self, value):
pname = PropertyName.fromElement(customxml.TwistedSchedulingObjectResource)
if value:
if value is not None:
self.properties()[pname] = customxml.TwistedSchedulingObjectResource.fromString("true" if value else "false")
elif pname in self.properties():
del self.properties()[pname]
@@ -175,7 +175,7 @@ class CommonTests(CommonCommonTests):
}
metadata3 = {
"accessMode": "PUBLIC",
"isScheduleObject": True,
"isScheduleObject": None,
"scheduleTag": "abc",
"scheduleEtags": (),
"hasPrivateComment": True,
@@ -174,7 +174,7 @@ create table CALENDAR_OBJECT (
ORGANIZER_OBJECT integer references CALENDAR_OBJECT,
RECURRANCE_MAX date, -- maximum date that recurrences have been expanded to.
ACCESS integer default 0 not null,
SCHEDULE_OBJECT boolean default false not null,
SCHEDULE_OBJECT boolean default false,
SCHEDULE_TAG varchar(36) default null,
SCHEDULE_ETAGS text default null,
PRIVATE_COMMENTS boolean default false not null,
@@ -479,5 +479,5 @@ create table CALENDARSERVER (
unique(NAME)
);

insert into CALENDARSERVER values ('VERSION', '3');
insert into CALENDARSERVER values ('VERSION', '4');

0 comments on commit cb913d3

Please sign in to comment.
You can’t perform that action at this time.