<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14488] CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14488">14488</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-02-28 08:38:15 -0800 (Sat, 28 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Checkpoint: group sharee reconcile.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresqlpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresql_directorypy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_directory.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresql_externalpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_external.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationhome_syncpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtestaccountsgroupAccountsxml">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/groupAccounts.xml</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtesttest_home_syncpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingstore_apipy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/store_api.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingtestutilpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/test/util.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtestaccountsaugmentsxml">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/augments.xml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -14,8 +14,6 @@
</span><span class="cx"> # See the License for the specific language governing permissions and
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><del>-from txdav.caldav.datastore.sql_attachment import Attachment, DropBoxAttachment, \
- AttachmentLink, ManagedAttachment
</del><span class="cx">
</span><span class="cx">
</span><span class="cx"> """
</span><span class="lines">@@ -63,7 +61,10 @@
</span><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
</span><span class="cx"> from txdav.caldav.datastore.scheduling.utils import uidFromCalendarUserAddress
</span><del>-from txdav.caldav.datastore.sql_directory import GroupAttendeeRecord
</del><ins>+ffrom txdav.caldav.datastore.sql_attachment import Attachment, DropBoxAttachment, \
+ AttachmentLink, ManagedAttachment
+rom txdav.caldav.datastore.sql_directory import GroupAttendeeRecord,\
+ GroupShareeRecord
</ins><span class="cx"> from txdav.caldav.datastore.util import normalizationLookup
</span><span class="cx"> from txdav.caldav.datastore.util import CalendarObjectBase
</span><span class="cx"> from txdav.caldav.datastore.util import dropboxIDFromCalendarObject
</span><span class="lines">@@ -79,6 +80,7 @@
</span><span class="cx"> UnknownTimezone, SetComponentOptions
</span><span class="cx"> from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
</span><span class="cx"> CommonObjectResource, ECALENDARTYPE
</span><ins>+from txdav.common.datastore.sql_directory import GroupsRecord
</ins><span class="cx"> from txdav.common.datastore.sql_tables import _ATTACHMENTS_MODE_NONE, \
</span><span class="cx"> _ATTACHMENTS_MODE_READ, _ATTACHMENTS_MODE_WRITE, _BIND_MODE_DIRECT, \
</span><span class="cx"> _BIND_MODE_GROUP, _BIND_MODE_GROUP_READ, _BIND_MODE_GROUP_WRITE, \
</span><span class="lines">@@ -2315,6 +2317,14 @@
</span><span class="cx"> returnValue(invitations)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def groupSharees(self):
+ sharees = yield GroupShareeRecord.querysimple(self._txn, calendarID=self.id())
+ groups = set([sharee.groupID for sharee in sharees])
+ groups = (yield GroupsRecord.query(self._txn, GroupsRecord.groupID.In(groups))) if groups else []
+ returnValue({"groups": groups, "sharees": sharees})
+
+
</ins><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx"> "UNKNOWN" : 0,
</span><span class="cx"> "FREE" : 1,
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresql_directorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_directory.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_directory.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_directory.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -62,3 +62,12 @@
</span><span class="cx"> results.append((groupAttendeeRecord, groupsRecord,))
</span><span class="cx">
</span><span class="cx"> returnValue(results)
</span><ins>+
+
+
+class GroupShareeRecord(SerializableRecord, fromTable(schema.GROUP_SHAREE)):
+ """
+ @DynamicAttrs
+ L{Record} for L{schema.GROUP_SHAREE}.
+ """
+ pass
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoresql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_external.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_external.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/sql_external.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">
</span><span class="cx"> from txdav.caldav.datastore.sql import CalendarHome, Calendar, CalendarObject
</span><span class="cx"> from txdav.caldav.datastore.sql_attachment import Attachment, AttachmentLink
</span><del>-from txdav.caldav.datastore.sql_directory import GroupAttendeeRecord
</del><ins>+from txdav.caldav.datastore.sql_directory import GroupAttendeeRecord, GroupShareeRecord
</ins><span class="cx"> from txdav.caldav.icalendarstore import ComponentUpdateState, ComponentRemoveState
</span><span class="cx"> from txdav.common.datastore.sql_directory import GroupsRecord
</span><span class="cx"> from txdav.common.datastore.sql_external import CommonHomeExternal, CommonHomeChildExternal, \
</span><span class="lines">@@ -194,10 +194,16 @@
</span><span class="cx"> """
</span><span class="cx"> SQL-based implementation of L{ICalendar}.
</span><span class="cx"> """
</span><del>- pass
</del><span class="cx">
</span><ins>+ @inlineCallbacks
+ def groupSharees(self):
+ results = yield self._txn.store().conduit.send_homechild_group_sharees(self)
+ results["groups"] = [GroupsRecord.deserialize(items) for items in results["groups"]]
+ results["sharees"] = [GroupShareeRecord.deserialize(items) for items in results["sharees"]]
+ returnValue(results)
</ins><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> class CalendarObjectExternal(CommonObjectResourceExternal, CalendarObject):
</span><span class="cx"> """
</span><span class="cx"> SQL-based implementation of L{ICalendarObject}.
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationhome_syncpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/home_sync.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -179,13 +179,10 @@
</span><span class="cx"> # Delegates reconcile
</span><span class="cx"> yield self.delegateReconcile()
</span><span class="cx">
</span><del>- # TODO: shared collections reconcile
</del><ins>+ # Shared collections reconcile (including group sharees)
</ins><span class="cx"> yield self.sharedByCollectionsReconcile()
</span><span class="cx"> yield self.sharedToCollectionsReconcile()
</span><span class="cx">
</span><del>- # TODO: group sharee reconcile
- pass
-
</del><span class="cx"> # Notifications
</span><span class="cx"> yield self.notificationsReconcile()
</span><span class="cx">
</span><span class="lines">@@ -977,6 +974,9 @@
</span><span class="cx"> yield self.makeSharedByCollections(records[:50], calendar.localResourceID)
</span><span class="cx"> records = records[50:]
</span><span class="cx">
</span><ins>+ # Get groups from remote pod
+ yield self.syncGroupSharees(calendar.remoteResourceID, calendar.localResourceID)
+
</ins><span class="cx"> # Update the remote pod to switch over the shares
</span><span class="cx"> yield self.updatedRemoteSharedByCollections(calendar.remoteResourceID, bindUID)
</span><span class="cx">
</span><span class="lines">@@ -1043,6 +1043,23 @@
</span><span class="cx">
</span><span class="cx"> @inTransactionWrapper
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def syncGroupSharees(self, txn, remote_id, local_id):
+ """
+ Sync the group sharees for a remote share.
+ """
+ remote_home = yield self._remoteHome(txn)
+ remote_calendar = yield remote_home.childWithID(remote_id)
+ results = yield remote_calendar.groupSharees()
+ groups = dict([(group.groupID, group.groupUID,) for group in results["groups"]])
+ for share in results["sharees"]:
+ local_group = yield txn.groupByUID(groups[share.groupID])
+ share.groupID = local_group.groupID
+ share.calendarID = local_id
+ yield share.insert(txn)
+
+
+ @inTransactionWrapper
+ @inlineCallbacks
</ins><span class="cx"> def updatedRemoteSharedByCollections(self, txn, remote_id, bindUID):
</span><span class="cx"> """
</span><span class="cx"> Get all the existing L{CalendarBindRecord}'s from the remote store.
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtestaccountsaugmentsxml"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/augments.xml (0 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/augments.xml         (rev 0)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/augments.xml        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 2009-2015 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<!DOCTYPE augments SYSTEM "../../../conf/auth/augments.dtd">
+
+<augments>
+        <record>
+         <uid>user01</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user02</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user03</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user04</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user05</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user06</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user07</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user08</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user09</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>user10</uid>
+         <server-id>A</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser01</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser02</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser03</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser04</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser05</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser06</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser07</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser08</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser09</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+        <record>
+         <uid>puser10</uid>
+         <server-id>B</server-id>
+         <enable-calendar>true</enable-calendar>
+         <enable-addressbook>true</enable-addressbook>
+        </record>
+</augments>
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtestaccountsgroupAccountsxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/groupAccounts.xml (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/groupAccounts.xml        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/accounts/groupAccounts.xml        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -137,4 +137,74 @@
</span><span class="cx">          <member-uid>group03</member-uid>
</span><span class="cx">          <member-uid>user10</member-uid>
</span><span class="cx">         </record>
</span><ins>+        <record type="user">
+         <uid>puser01</uid>
+         <short-name>puser01</short-name>
+         <password>puser01</password>
+         <full-name>Puser 01</full-name>
+         <email>puser01@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser02</uid>
+         <short-name>puser02</short-name>
+         <password>puser02</password>
+         <full-name>Puser 02</full-name>
+         <email>puser02@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser03</uid>
+         <short-name>puser03</short-name>
+         <password>puser03</password>
+         <full-name>Puser 03</full-name>
+         <email>puser03@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser04</uid>
+         <short-name>puser04</short-name>
+         <password>puser04</password>
+         <full-name>Puser 04</full-name>
+         <email>puser04@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser05</uid>
+         <short-name>puser05</short-name>
+         <password>puser05</password>
+         <full-name>Puser 05</full-name>
+         <email>puser05@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser06</uid>
+         <short-name>puser06</short-name>
+         <password>puser06</password>
+         <full-name>Puser 06</full-name>
+         <email>puser06@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser07</uid>
+         <short-name>puser07</short-name>
+         <password>puser07</password>
+         <full-name>Puser 07</full-name>
+         <email>puser07@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser08</uid>
+         <short-name>puser08</short-name>
+         <password>puser08</password>
+         <full-name>Puser 08</full-name>
+         <email>puser08@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser09</uid>
+         <short-name>puser09</short-name>
+         <password>puser09</password>
+         <full-name>Puser 09</full-name>
+         <email>puser09@example.com</email>
+        </record>
+        <record type="user">
+         <uid>puser10</uid>
+         <short-name>puser10</short-name>
+         <password>puser10</password>
+         <full-name>Puser 10</full-name>
+         <email>puser10@example.com</email>
+        </record>
</ins><span class="cx"> </directory>
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingmigrationtesttest_home_syncpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -23,12 +23,13 @@
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from twistedcaldav.ical import Component, normalize_iCalStr
</span><span class="cx"> from txdav.caldav.datastore.sql import ManagedAttachment
</span><ins>+from txdav.caldav.datastore.sql_directory import GroupShareeRecord
</ins><span class="cx"> from txdav.common.datastore.podding.migration.home_sync import CrossPodHomeSync
</span><span class="cx"> from txdav.common.datastore.podding.migration.sync_metadata import CalendarMigrationRecord, \
</span><span class="cx"> AttachmentMigrationRecord
</span><span class="cx"> from txdav.common.datastore.podding.test.util import MultiStoreConduitTest
</span><span class="cx"> from txdav.common.datastore.sql_directory import DelegateRecord, \
</span><del>- ExternalDelegateGroupsRecord, DelegateGroupsRecord
</del><ins>+ ExternalDelegateGroupsRecord, DelegateGroupsRecord, GroupsRecord
</ins><span class="cx"> from txdav.common.datastore.sql_notification import NotificationCollection
</span><span class="cx"> from txdav.common.datastore.sql_tables import schema, _HOME_STATUS_EXTERNAL, \
</span><span class="cx"> _BIND_MODE_READ, _HOME_STATUS_MIGRATING
</span><span class="lines">@@ -983,21 +984,55 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def _createShare(self, shareFrom, shareTo):
</del><ins>+ def setUp(self):
+ self.accounts = FilePath(__file__).sibling("accounts").child("groupAccounts.xml")
+ self.augments = FilePath(__file__).sibling("accounts").child("augments.xml")
+ yield super(TestSharingSync, self).setUp()
+ yield self.populate()
+
+
+ def configure(self):
+ super(TestSharingSync, self).configure()
+ config.Sharing.Enabled = True
+ config.Sharing.Calendars.Enabled = True
+ config.Sharing.Calendars.Groups.Enabled = True
+ config.Sharing.Calendars.Groups.ReconciliationDelaySeconds = 0
+
+
+ @inlineCallbacks
+ def populate(self):
+ yield populateCalendarsFrom(self.requirements, self.theStoreUnderTest(0))
+
+ requirements = {
+ "user01" : None,
+ "user02" : None,
+ "user06" : None,
+ "user07" : None,
+ "user08" : None,
+ "user09" : None,
+ "user10" : None,
+ }
+
+
+ @inlineCallbacks
+ def _createShare(self, shareFrom, shareTo, accept=True):
</ins><span class="cx"> # Invite
</span><span class="cx"> txnindex = 1 if shareFrom[0] == "p" else 0
</span><span class="cx"> home = yield self.homeUnderTest(txn=self.theTransactionUnderTest(txnindex), name=shareFrom, create=True)
</span><span class="cx"> calendar = yield home.childWithName("calendar")
</span><span class="cx"> shareeView = yield calendar.inviteUIDToShare(shareTo, _BIND_MODE_READ, "summary")
</span><del>- inviteUID = shareeView.shareUID()
</del><span class="cx"> yield self.commitTransaction(txnindex)
</span><span class="cx">
</span><span class="cx"> # Accept
</span><del>- txnindex = 1 if shareTo[0] == "p" else 0
- shareeHome = yield self.homeUnderTest(txn=self.theTransactionUnderTest(txnindex), name=shareTo)
- shareeView = yield shareeHome.acceptShare(inviteUID)
- sharedName = shareeView.name()
- yield self.commitTransaction(txnindex)
</del><ins>+ if accept:
+ inviteUID = shareeView.shareUID()
+ txnindex = 1 if shareTo[0] == "p" else 0
+ shareeHome = yield self.homeUnderTest(txn=self.theTransactionUnderTest(txnindex), name=shareTo)
+ shareeView = yield shareeHome.acceptShare(inviteUID)
+ sharedName = shareeView.name()
+ yield self.commitTransaction(txnindex)
+ else:
+ sharedName = None
</ins><span class="cx">
</span><span class="cx"> returnValue(sharedName)
</span><span class="cx">
</span><span class="lines">@@ -1073,7 +1108,42 @@
</span><span class="cx"> yield self.commitTransaction(1)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def test_group_shared_collections_reconcile(self):
+ """
+ Test that L{sharedCollectionsReconcile} copies over the full set of delegates and caches associated groups..
+ """
</ins><span class="cx">
</span><ins>+ # Create home
+ yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
+ yield self.commitTransaction(0)
+
+ # Shared by migrating user
+ yield self._createShare("user01", "group02", accept=False)
+
+ # Sync from remote side
+ syncer = CrossPodHomeSync(self.theStoreUnderTest(1), "user01")
+ yield syncer.loadRecord()
+ yield syncer.sync()
+ changes = yield syncer.sharedByCollectionsReconcile()
+ self.assertEqual(changes, 3)
+ changes = yield syncer.sharedToCollectionsReconcile()
+ self.assertEqual(changes, 0)
+
+ # Local calendar exists with shares
+ home1 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(1), name="user01", status=_HOME_STATUS_MIGRATING)
+ calendar1 = yield home1.childWithName("calendar")
+ invites1 = yield calendar1.sharingInvites()
+ self.assertEqual(len(invites1), 3)
+ sharee = yield GroupShareeRecord.querysimple(self.theTransactionUnderTest(1), calendarID=calendar1.id())
+ self.assertEqual(len(sharee), 1)
+ group = yield GroupsRecord.querysimple(self.theTransactionUnderTest(1), groupID=sharee[0].groupID)
+ self.assertEqual(len(group), 1)
+ self.assertEqual(group[0].groupUID, "group02")
+ yield self.commitTransaction(1)
+
+
+
</ins><span class="cx"> class TestGroupAttendeeSync(MultiStoreConduitTest):
</span><span class="cx"> """
</span><span class="cx"> GroupAttendeeReconciliation tests
</span><span class="lines">@@ -1155,7 +1225,6 @@
</span><span class="cx"> "user08" : None,
</span><span class="cx"> "user09" : None,
</span><span class="cx"> "user10" : None,
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingstore_apipy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/store_api.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/store_api.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/store_api.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -169,6 +169,7 @@
</span><span class="cx"> UtilityConduitMixin._make_simple_action(StoreAPIConduitMixin, "homechild_search", "search")
</span><span class="cx"> UtilityConduitMixin._make_simple_action(StoreAPIConduitMixin, "homechild_sharing_records", "sharingBindRecords", transform_recv_result=StoreAPIConduitMixin._to_serialize_dict_value)
</span><span class="cx"> UtilityConduitMixin._make_simple_action(StoreAPIConduitMixin, "homechild_migrate_sharing_records", "migrateBindRecords")
</span><ins>+UtilityConduitMixin._make_simple_action(StoreAPIConduitMixin, "homechild_group_sharees", "groupSharees", transform_recv_result=StoreAPIConduitMixin._to_serialize_dict_list_serialized_value)
</ins><span class="cx">
</span><span class="cx"> # Calls on L{CommonObjectResource} objects
</span><span class="cx"> UtilityConduitMixin._make_simple_action(StoreAPIConduitMixin, "objectresource_loadallobjects", "loadAllObjects", classMethod=True, transform_recv_result=UtilityConduitMixin._to_serialize_list)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastorepoddingtestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/test/util.py (14487 => 14488)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/test/util.py        2015-02-27 22:12:30 UTC (rev 14487)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/podding/test/util.py        2015-02-28 16:38:15 UTC (rev 14488)
</span><span class="lines">@@ -129,6 +129,7 @@
</span><span class="cx"> theStores = []
</span><span class="cx"> activeTransactions = []
</span><span class="cx"> accounts = None
</span><ins>+ augments = None
</ins><span class="cx">
</span><span class="cx"> def __init__(self, methodName='runTest'):
</span><span class="cx"> txweb2.dav.test.util.TestCase.__init__(self, methodName)
</span><span class="lines">@@ -156,6 +157,7 @@
</span><span class="cx"> serversDB=serversDB,
</span><span class="cx"> storeBuilder=self.theStoreBuilders[i],
</span><span class="cx"> accounts=self.accounts,
</span><ins>+ augments=self.augments,
</ins><span class="cx"> )
</span><span class="cx"> self.theStores[i] = self.store
</span><span class="cx"> else:
</span><span class="lines">@@ -165,6 +167,7 @@
</span><span class="cx"> self.mktemp(),
</span><span class="cx"> serversDB=serversDB,
</span><span class="cx"> accounts=self.accounts,
</span><ins>+ augments=self.augments,
</ins><span class="cx"> )
</span><span class="cx"> self.theStores[i].setDirectoryService(directory)
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>